Changeset d2c8533 in mainline
- Timestamp:
- 2017-05-08T20:38:47Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f066a87
- Parents:
- 582a0b8
- Location:
- uspace
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/init/init.c
r582a0b8 rd2c8533 320 320 srv_start("/srv/tmpfs"); 321 321 322 srv_start("/srv/mfs"); 323 322 324 srv_start("/srv/klog"); 323 325 srv_start("/srv/locfs"); -
uspace/lib/c/generic/vfs/vfs.c
r582a0b8 rd2c8533 347 347 return loc_service_connect(stat.service, iface, 0); 348 348 } 349 350 /** Determine if a device contains the specified file system type. If so, 351 * return identification information. 352 * 353 * @param fs_name File system name 354 * @param serv Service representing the mountee 355 * @param info Place to store volume identification information 356 * 357 * @return EOK on success or a negative error code 358 */ 359 int vfs_fsprobe(const char *fs_name, service_id_t serv, 360 vfs_fs_probe_info_t *info) 361 { 362 sysarg_t rc; 363 364 ipc_call_t answer; 365 async_exch_t *exch = vfs_exchange_begin(); 366 aid_t req = async_send_1(exch, VFS_IN_FSPROBE, serv, &answer); 367 368 rc = async_data_write_start(exch, (void *) fs_name, 369 str_size(fs_name)); 370 371 async_wait_for(req, &rc); 372 373 if (rc != EOK) { 374 vfs_exchange_end(exch); 375 return rc; 376 } 377 378 rc = async_data_read_start(exch, info, sizeof(*info)); 379 vfs_exchange_end(exch); 380 381 return rc; 382 } 383 349 384 350 385 /** Return a list of currently available file system types -
uspace/lib/c/include/ipc/vfs.h
r582a0b8 rd2c8533 41 41 42 42 #define FS_NAME_MAXLEN 20 43 #define FS_LABEL_MAXLEN 256 44 #define FS_VUID_MAXLEN 128 43 45 #define MAX_PATH_LEN (32 * 1024) 44 46 #define MAX_MNTOPTS_LEN 256 … … 62 64 } vfs_info_t; 63 65 66 /** Data returned by filesystem probe regarding a specific volume. */ 67 typedef struct { 68 char label[FS_LABEL_MAXLEN + 1]; 69 char vuid[FS_VUID_MAXLEN + 1]; 70 } vfs_fs_probe_info_t; 71 64 72 typedef enum { 65 73 VFS_IN_CLONE = IPC_FIRST_USER_METHOD, 74 VFS_IN_FSPROBE, 66 75 VFS_IN_FSTYPES, 67 76 VFS_IN_MOUNT, … … 85 94 VFS_OUT_CLOSE = IPC_FIRST_USER_METHOD, 86 95 VFS_OUT_DESTROY, 96 VFS_OUT_FSPROBE, 87 97 VFS_OUT_IS_EMPTY, 88 98 VFS_OUT_LINK, -
uspace/lib/c/include/vfs/vfs.h
r582a0b8 rd2c8533 88 88 extern async_exch_t *vfs_exchange_begin(void); 89 89 extern void vfs_exchange_end(async_exch_t *); 90 extern int vfs_fsprobe(const char *, service_id_t, vfs_fs_probe_info_t *); 90 91 extern int vfs_fstypes(vfs_fstypes_t *); 91 92 extern void vfs_fstypes_free(vfs_fstypes_t *); -
uspace/lib/fs/libfs.c
r582a0b8 rd2c8533 81 81 ipc_call_t *); 82 82 83 static void vfs_out_fsprobe(ipc_callid_t rid, ipc_call_t *req) 84 { 85 service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req); 86 int rc; 87 vfs_fs_probe_info_t info; 88 89 ipc_callid_t callid; 90 size_t size; 91 if ((!async_data_read_receive(&callid, &size)) || 92 (size != sizeof(info))) { 93 async_answer_0(callid, EIO); 94 async_answer_0(rid, EIO); 95 return; 96 } 97 98 memset(&info, 0, sizeof(info)); 99 rc = vfs_out_ops->fsprobe(service_id, &info); 100 if (rc != EOK) { 101 async_answer_0(callid, EIO); 102 async_answer_0(rid, rc); 103 return; 104 } 105 106 async_data_read_finalize(callid, &info, sizeof(info)); 107 async_answer_0(rid, EOK); 108 } 109 83 110 static void vfs_out_mounted(ipc_callid_t rid, ipc_call_t *req) 84 111 { … … 272 299 273 300 switch (IPC_GET_IMETHOD(call)) { 301 case VFS_OUT_FSPROBE: 302 vfs_out_fsprobe(callid, &call); 303 break; 274 304 case VFS_OUT_MOUNTED: 275 305 vfs_out_mounted(callid, &call); -
uspace/lib/fs/libfs.h
r582a0b8 rd2c8533 43 43 44 44 typedef struct { 45 int (* fsprobe)(service_id_t, vfs_fs_probe_info_t *); 45 46 int (* mounted)(service_id_t, const char *, fs_index_t *, aoff64_t *, 46 47 unsigned *); -
uspace/srv/fs/cdfs/cdfs_ops.c
r582a0b8 rd2c8533 1021 1021 } 1022 1022 1023 static int cdfs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 1024 { 1025 return ENOTSUP; 1026 } 1027 1023 1028 static int cdfs_mounted(service_id_t service_id, const char *opts, 1024 1029 fs_index_t *index, aoff64_t *size, unsigned int *lnkcnt) … … 1297 1302 1298 1303 vfs_out_ops_t cdfs_ops = { 1304 .fsprobe = cdfs_fsprobe, 1299 1305 .mounted = cdfs_mounted, 1300 1306 .unmounted = cdfs_unmounted, -
uspace/srv/fs/exfat/exfat_ops.c
r582a0b8 rd2c8533 1050 1050 } 1051 1051 */ 1052 1052 1053 static int exfat_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 1054 { 1055 return ENOTSUP; 1056 } 1057 1053 1058 static int 1054 1059 exfat_mounted(service_id_t service_id, const char *opts, fs_index_t *index, … … 1571 1576 1572 1577 vfs_out_ops_t exfat_ops = { 1578 .fsprobe = exfat_fsprobe, 1573 1579 .mounted = exfat_mounted, 1574 1580 .unmounted = exfat_unmounted, -
uspace/srv/fs/ext4fs/ext4fs_ops.c
r582a0b8 rd2c8533 915 915 * VFS operations. 916 916 */ 917 918 /** Probe operation. 919 * 920 * Try to get information about specified filesystem from device. 921 * 922 * @param sevice_id Service ID 923 * @param info Place to store information 924 * 925 * @return Error code 926 */ 927 static int ext4fs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 928 { 929 return ENOTSUP; 930 } 917 931 918 932 /** Mount operation. … … 1520 1534 */ 1521 1535 vfs_out_ops_t ext4fs_ops = { 1536 .fsprobe = ext4fs_fsprobe, 1522 1537 .mounted = ext4fs_mounted, 1523 1538 .unmounted = ext4fs_unmounted, -
uspace/srv/fs/fat/fat_ops.c
r582a0b8 rd2c8533 912 912 * FAT VFS_OUT operations. 913 913 */ 914 915 static int fat_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 916 { 917 return ENOTSUP; 918 } 914 919 915 920 static int … … 1508 1513 1509 1514 vfs_out_ops_t fat_ops = { 1515 .fsprobe = fat_fsprobe, 1510 1516 .mounted = fat_mounted, 1511 1517 .unmounted = fat_unmounted, -
uspace/srv/fs/locfs/locfs_ops.c
r582a0b8 rd2c8533 455 455 } 456 456 457 static int locfs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 458 { 459 return ENOTSUP; 460 } 461 457 462 static int locfs_mounted(service_id_t service_id, const char *opts, 458 463 fs_index_t *index, aoff64_t *size, unsigned *lnkcnt) … … 763 768 764 769 vfs_out_ops_t locfs_ops = { 770 .fsprobe = locfs_fsprobe, 765 771 .mounted = locfs_mounted, 766 772 .unmounted = locfs_unmounted, -
uspace/srv/fs/mfs/mfs_ops.c
r582a0b8 rd2c8533 140 140 } 141 141 142 static int 143 mfs_mounted(service_id_t service_id, const char *opts, fs_index_t *index, 144 aoff64_t *size, unsigned *linkcnt) 145 { 146 enum cache_mode cmode; 142 /** Read the superblock. 143 */ 144 static int mfs_read_sb(service_id_t service_id, struct mfs_sb_info **rsbi) 145 { 147 146 struct mfs_superblock *sb = NULL; 148 147 struct mfs3_superblock *sb3 = NULL; 149 struct mfs_sb_info *sbi = NULL;150 s truct mfs_instance *instance = NULL;148 struct mfs_sb_info *sbi; 149 size_t bsize; 151 150 bool native, longnames; 152 151 mfs_version_t version; 153 152 uint16_t magic; 154 153 int rc; 155 156 /* Check for option enabling write through. */157 if (str_cmp(opts, "wtcache") == 0)158 cmode = CACHE_MODE_WT;159 else160 cmode = CACHE_MODE_WB;161 162 /* initialize libblock */163 rc = block_init(service_id, 4096);164 if (rc != EOK)165 return rc;166 154 167 155 /* Allocate space for generic MFS superblock */ … … 172 160 } 173 161 174 /* Allocate space for filesystem instance */175 instance = malloc(sizeof(*instance));176 if (!instance) {177 rc = ENOMEM;178 goto out_error;179 }180 181 162 sb = malloc(MFS_SUPERBLOCK_SIZE); 182 163 if (!sb) { 183 164 rc = ENOMEM; 165 goto out_error; 166 } 167 168 rc = block_get_bsize(service_id, &bsize); 169 if (rc != EOK) { 170 rc = EIO; 171 goto out_error; 172 } 173 174 /* We don't support other block size than 512 */ 175 if (bsize != 512) { 176 rc = ENOTSUP; 184 177 goto out_error; 185 178 } … … 269 262 } 270 263 264 mfsdebug("read superblock successful\n"); 265 266 free(sb); 267 *rsbi = sbi; 268 return EOK; 269 270 out_error: 271 if (sb) 272 free(sb); 273 if (sbi) 274 free(sbi); 275 return rc; 276 } 277 278 279 static int mfs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 280 { 281 struct mfs_sb_info *sbi = NULL; 282 int rc; 283 284 /* Initialize libblock */ 285 rc = block_init(service_id, 4096); 286 if (rc != EOK) 287 return rc; 288 289 /* Read the superblock */ 290 rc = mfs_read_sb(service_id, &sbi); 291 block_fini(service_id); 292 293 return rc; 294 } 295 296 static int 297 mfs_mounted(service_id_t service_id, const char *opts, fs_index_t *index, 298 aoff64_t *size, unsigned *linkcnt) 299 { 300 enum cache_mode cmode; 301 struct mfs_sb_info *sbi = NULL; 302 struct mfs_instance *instance = NULL; 303 int rc; 304 305 /* Check for option enabling write through. */ 306 if (str_cmp(opts, "wtcache") == 0) 307 cmode = CACHE_MODE_WT; 308 else 309 cmode = CACHE_MODE_WB; 310 311 /* Initialize libblock */ 312 rc = block_init(service_id, 4096); 313 if (rc != EOK) 314 return rc; 315 316 /* Allocate space for filesystem instance */ 317 instance = malloc(sizeof(*instance)); 318 if (!instance) { 319 rc = ENOMEM; 320 goto out_error; 321 } 322 323 /* Read the superblock */ 324 rc = mfs_read_sb(service_id, &sbi); 325 if (rc != EOK) 326 goto out_error; 327 271 328 rc = block_cache_init(service_id, sbi->block_size, 0, cmode); 272 329 if (rc != EOK) { … … 298 355 *linkcnt = 1; 299 356 300 free(sb);301 302 357 return mfs_node_put(fn); 303 358 304 359 out_error: 305 360 block_fini(service_id); 306 if (sb)307 free(sb);308 361 if (sbi) 309 362 free(sbi); … … 1205 1258 1206 1259 vfs_out_ops_t mfs_ops = { 1260 .fsprobe = mfs_fsprobe, 1207 1261 .mounted = mfs_mounted, 1208 1262 .unmounted = mfs_unmounted, -
uspace/srv/fs/tmpfs/tmpfs_ops.c
r582a0b8 rd2c8533 421 421 */ 422 422 423 static int tmpfs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 424 { 425 return ENOTSUP; 426 } 427 423 428 static int 424 429 tmpfs_mounted(service_id_t service_id, const char *opts, … … 652 657 653 658 vfs_out_ops_t tmpfs_ops = { 659 .fsprobe = tmpfs_fsprobe, 654 660 .mounted = tmpfs_mounted, 655 661 .unmounted = tmpfs_unmounted, -
uspace/srv/fs/udf/udf_ops.c
r582a0b8 rd2c8533 299 299 }; 300 300 301 static int udf_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 302 { 303 return ENOTSUP; 304 } 305 301 306 static int udf_mounted(service_id_t service_id, const char *opts, 302 307 fs_index_t *index, aoff64_t *size, unsigned *linkcnt) … … 547 552 548 553 vfs_out_ops_t udf_ops = { 554 .fsprobe = udf_fsprobe, 549 555 .mounted = udf_mounted, 550 556 .unmounted = udf_unmounted, -
uspace/srv/vfs/vfs.h
r582a0b8 rd2c8533 206 206 207 207 extern int vfs_op_clone(int oldfd, int newfd, bool desc); 208 extern int vfs_op_fsprobe(const char *, service_id_t, vfs_fs_probe_info_t *); 208 209 extern int vfs_op_mount(int mpfd, unsigned servid, unsigned flags, unsigned instance, const char *opts, const char *fsname, int *outfd); 209 210 extern int vfs_op_mtab_get(void); -
uspace/srv/vfs/vfs_ipc.c
r582a0b8 rd2c8533 45 45 } 46 46 47 static void vfs_in_fsprobe(ipc_callid_t rid, ipc_call_t *request) 48 { 49 service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request); 50 char *fs_name = NULL; 51 ipc_callid_t callid; 52 vfs_fs_probe_info_t info; 53 size_t len; 54 int rc; 55 56 /* 57 * Now we expect the client to send us data with the name of the file 58 * system. 59 */ 60 rc = async_data_write_accept((void **) &fs_name, true, 0, 61 FS_NAME_MAXLEN, 0, NULL); 62 if (rc != EOK) { 63 async_answer_0(rid, rc); 64 return; 65 } 66 67 rc = vfs_op_fsprobe(fs_name, service_id, &info); 68 async_answer_0(rid, rc); 69 if (rc != EOK) 70 goto out; 71 72 /* Now we should get a read request */ 73 if (!async_data_read_receive(&callid, &len)) 74 goto out; 75 76 if (len > sizeof(info)) 77 len = sizeof(info); 78 (void) async_data_read_finalize(callid, &info, len); 79 80 out: 81 free(fs_name); 82 } 83 47 84 static void vfs_in_fstypes(ipc_callid_t rid, ipc_call_t *request) 48 85 { … … 297 334 vfs_in_clone(callid, &call); 298 335 break; 336 case VFS_IN_FSPROBE: 337 vfs_in_fsprobe(callid, &call); 338 break; 299 339 case VFS_IN_FSTYPES: 300 340 vfs_in_fstypes(callid, &call); -
uspace/srv/vfs/vfs_ops.c
r582a0b8 rd2c8533 190 190 } 191 191 192 int vfs_op_fsprobe(const char *fs_name, service_id_t sid, 193 vfs_fs_probe_info_t *info) 194 { 195 fs_handle_t fs_handle = 0; 196 sysarg_t rc; 197 int retval; 198 199 fibril_mutex_lock(&fs_list_lock); 200 fs_handle = fs_name_to_handle(0, fs_name, false); 201 fibril_mutex_unlock(&fs_list_lock); 202 203 if (fs_handle == 0) 204 return ENOFS; 205 206 /* Send probe request to the file system server */ 207 ipc_call_t answer; 208 async_exch_t *exch = vfs_exchange_grab(fs_handle); 209 aid_t msg = async_send_1(exch, VFS_OUT_FSPROBE, (sysarg_t) sid, 210 &answer); 211 if (msg == 0) 212 return EINVAL; 213 214 /* Read probe information */ 215 retval = async_data_read_start(exch, info, sizeof(*info)); 216 if (retval != EOK) { 217 async_forget(msg); 218 return retval; 219 } 220 221 async_wait_for(msg, &rc); 222 vfs_exchange_release(exch); 223 return rc; 224 } 225 192 226 int vfs_op_mount(int mpfd, unsigned service_id, unsigned flags, 193 227 unsigned instance, const char *opts, const char *fs_name, int *outfd) -
uspace/srv/volsrv/part.c
r582a0b8 rd2c8533 42 42 #include <stdlib.h> 43 43 #include <str.h> 44 #include <vfs/vfs.h> 44 45 45 46 #include "empty.h" … … 132 133 vol_part_t *part; 133 134 bool empty; 135 vfs_fs_probe_info_t info; 134 136 int rc; 135 137 … … 154 156 } 155 157 156 log_msg(LOG_DEFAULT, LVL_DEBUG, "Probe partition %s", part->svc_name); 157 rc = volsrv_part_is_empty(sid, &empty); 158 if (rc != EOK) { 159 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed determining if " 160 "partition is empty."); 161 goto error; 162 } 163 164 part->pcnt = empty ? vpc_empty : vpc_unknown; 158 log_msg(LOG_DEFAULT, LVL_NOTE, "Probe partition %s", part->svc_name); 159 rc = vfs_fsprobe("mfs", sid, &info); 160 if (rc == EOK) { 161 part->pcnt = vpc_fs; 162 part->fstype = fs_minix; 163 } else { 164 log_msg(LOG_DEFAULT, LVL_NOTE, "Partition does not contain " 165 "a recognized file system."); 166 167 rc = volsrv_part_is_empty(sid, &empty); 168 if (rc != EOK) { 169 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed determining if " 170 "partition is empty."); 171 goto error; 172 } 173 174 part->pcnt = empty ? vpc_empty : vpc_unknown; 175 } 176 165 177 list_append(&part->lparts, &vol_parts); 166 178
Note:
See TracChangeset
for help on using the changeset viewer.