Changes in uspace/lib/c/generic/vfs/vfs.c [8fd04ba9:15f3c3f] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/vfs/vfs.c
r8fd04ba9 r15f3c3f 51 51 #include <assert.h> 52 52 #include <str.h> 53 #include < devmap.h>53 #include <loc.h> 54 54 #include <ipc/vfs.h> 55 #include <ipc/ devmap.h>55 #include <ipc/loc.h> 56 56 57 57 static FIBRIL_MUTEX_INITIALIZE(vfs_mutex); … … 142 142 } 143 143 144 int mount(const char *fs_name, const char *mp, const char *fq dn,144 int mount(const char *fs_name, const char *mp, const char *fqsn, 145 145 const char *opts, unsigned int flags) 146 146 { 147 147 int null_id = -1; 148 char null[ DEVMAP_NAME_MAXLEN];149 150 if (str_cmp(fq dn, "") == 0) {148 char null[LOC_NAME_MAXLEN]; 149 150 if (str_cmp(fqsn, "") == 0) { 151 151 /* No device specified, create a fresh 152 152 null/%d device instead */ 153 null_id = devmap_null_create();153 null_id = loc_null_create(); 154 154 155 155 if (null_id == -1) 156 156 return ENOMEM; 157 157 158 snprintf(null, DEVMAP_NAME_MAXLEN, "null/%d", null_id);159 fq dn = null;160 } 161 162 devmap_handle_t devmap_handle;163 int res = devmap_device_get_handle(fqdn, &devmap_handle, flags);158 snprintf(null, LOC_NAME_MAXLEN, "null/%d", null_id); 159 fqsn = null; 160 } 161 162 service_id_t service_id; 163 int res = loc_service_get_id(fqsn, &service_id, flags); 164 164 if (res != EOK) { 165 165 if (null_id != -1) 166 devmap_null_destroy(null_id);166 loc_null_destroy(null_id); 167 167 168 168 return res; … … 173 173 if (!mpa) { 174 174 if (null_id != -1) 175 devmap_null_destroy(null_id);175 loc_null_destroy(null_id); 176 176 177 177 return ENOMEM; … … 181 181 182 182 sysarg_t rc_orig; 183 aid_t req = async_send_2(exch, VFS_IN_MOUNT, devmap_handle, flags, NULL);183 aid_t req = async_send_2(exch, VFS_IN_MOUNT, service_id, flags, NULL); 184 184 sysarg_t rc = async_data_write_start(exch, (void *) mpa, mpa_size); 185 185 if (rc != EOK) { … … 189 189 190 190 if (null_id != -1) 191 devmap_null_destroy(null_id);191 loc_null_destroy(null_id); 192 192 193 193 if (rc_orig == EOK) … … 204 204 205 205 if (null_id != -1) 206 devmap_null_destroy(null_id);206 loc_null_destroy(null_id); 207 207 208 208 if (rc_orig == EOK) … … 219 219 220 220 if (null_id != -1) 221 devmap_null_destroy(null_id);221 loc_null_destroy(null_id); 222 222 223 223 if (rc_orig == EOK) … … 235 235 236 236 if (null_id != -1) 237 devmap_null_destroy(null_id);237 loc_null_destroy(null_id); 238 238 239 239 if (rc_orig == EOK) … … 248 248 249 249 if ((rc != EOK) && (null_id != -1)) 250 devmap_null_destroy(null_id);250 loc_null_destroy(null_id); 251 251 252 252 return (int) rc; … … 335 335 ipc_call_t answer; 336 336 aid_t req = async_send_4(exch, VFS_IN_OPEN_NODE, node->fs_handle, 337 node-> devmap_handle, node->index, oflag, &answer);337 node->service_id, node->index, oflag, &answer); 338 338 339 339 vfs_exchange_end(exch); … … 415 415 else 416 416 return -1; 417 }418 419 /** Read entire buffer.420 *421 * In face of short reads this function continues reading until either422 * the entire buffer is read or no more data is available (at end of file).423 *424 * @param fildes File descriptor425 * @param buf Buffer, @a nbytes bytes long426 * @param nbytes Number of bytes to read427 *428 * @return On success, positive number of bytes read.429 * On failure, negative error code from read().430 */431 ssize_t read_all(int fildes, void *buf, size_t nbyte)432 {433 ssize_t cnt = 0;434 size_t nread = 0;435 uint8_t *bp = (uint8_t *) buf;436 437 do {438 bp += cnt;439 nread += cnt;440 cnt = read(fildes, bp, nbyte - nread);441 } while (cnt > 0 && (nbyte - nread - cnt) > 0);442 443 if (cnt < 0)444 return cnt;445 446 return nread + cnt;447 }448 449 /** Write entire buffer.450 *451 * This function fails if it cannot write exactly @a len bytes to the file.452 *453 * @param fildes File descriptor454 * @param buf Data, @a nbytes bytes long455 * @param nbytes Number of bytes to write456 *457 * @return EOK on error, return value from write() if writing458 * failed.459 */460 ssize_t write_all(int fildes, const void *buf, size_t nbyte)461 {462 ssize_t cnt = 0;463 ssize_t nwritten = 0;464 const uint8_t *bp = (uint8_t *) buf;465 466 do {467 bp += cnt;468 nwritten += cnt;469 cnt = write(fildes, bp, nbyte - nwritten);470 } while (cnt > 0 && ((ssize_t )nbyte - nwritten - cnt) > 0);471 472 if (cnt < 0)473 return cnt;474 475 if ((ssize_t)nbyte - nwritten - cnt > 0)476 return EIO;477 478 return nbyte;479 417 } 480 418 … … 811 749 } 812 750 813 if (!stat. device) {751 if (!stat.service) { 814 752 errno = ENOENT; 815 753 return NULL; 816 754 } 817 755 818 return devmap_device_connect(mgmt, stat.device, 0);756 return loc_service_connect(mgmt, stat.service, 0); 819 757 } 820 758 … … 826 764 if (rc == EOK) { 827 765 node->fs_handle = stat.fs_handle; 828 node-> devmap_handle = stat.devmap_handle;766 node->service_id = stat.service_id; 829 767 node->index = stat.index; 830 768 }
Note:
See TracChangeset
for help on using the changeset viewer.