Changeset 5664cf64 in mainline
- Timestamp:
- 2011-11-07T07:22:54Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 052e82d
- Parents:
- 3569955 (diff), 7b5f4c9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/mount/mount.c
r3569955 r5664cf64 30 30 #include <stdlib.h> 31 31 #include <vfs/vfs.h> 32 #include <adt/list.h> 32 33 #include <errno.h> 33 34 #include <getopt.h> 35 #include <inttypes.h> 34 36 #include "config.h" 35 37 #include "util.h" … … 60 62 } 61 63 return; 64 } 65 66 static void print_mtab_list(void) 67 { 68 LIST_INITIALIZE(mtab_list); 69 get_mtab_list(&mtab_list); 70 71 mtab_ent_t *old_ent = NULL; 72 73 list_foreach(mtab_list, cur) { 74 mtab_ent_t *mtab_ent = list_get_instance(cur, mtab_ent_t, 75 link); 76 77 if (old_ent) 78 free(old_ent); 79 80 old_ent = mtab_ent; 81 82 printf("%s", mtab_ent->fs_name); 83 if (mtab_ent->instance) 84 printf("/%d", mtab_ent->instance); 85 printf(" on %s ", mtab_ent->mp); 86 87 if (str_size(mtab_ent->opts) > 0) 88 printf("opts=%s ", mtab_ent->opts); 89 90 printf("(service=%" PRIun ")\n", mtab_ent->service_id); 91 } 92 93 if (old_ent) 94 free(old_ent); 62 95 } 63 96 … … 94 127 t_argv = &argv[0]; 95 128 96 if ((argc < 3) || (argc > 5)) {129 if ((argc == 2) || (argc > 5)) { 97 130 printf("%s: invalid number of arguments. Try `mount --help'\n", 98 131 cmdname); 99 132 return CMD_FAILURE; 133 } 134 if (argc == 1) { 135 print_mtab_list(); 136 return CMD_SUCCESS; 100 137 } 101 138 if (argc > 3) -
uspace/dist/src/c/demos/tetris/screen.c
r3569955 r5664cf64 95 95 { 96 96 console_flush(console); 97 console_set_rgb_color(console, 0xffffff,98 use_color ? color : 0x000000);97 console_set_rgb_color(console, use_color ? color : 0x000000, 98 0xffffff); 99 99 } 100 100 … … 153 153 return false; 154 154 155 return ( ccap >= CONSOLE_CCAP_RGB);155 return ((ccap & CONSOLE_CAP_RGB) == CONSOLE_CAP_RGB); 156 156 } 157 157 -
uspace/lib/c/generic/vfs/vfs.c
r3569955 r5664cf64 831 831 } 832 832 833 int get_mtab_list(list_t *mtab_list) 834 { 835 sysarg_t rc; 836 aid_t req; 837 size_t i; 838 sysarg_t num_mounted_fs; 839 840 async_exch_t *exch = vfs_exchange_begin(); 841 842 req = async_send_0(exch, VFS_IN_MTAB_GET, NULL); 843 844 /* Ask VFS how many filesystems are mounted */ 845 rc = async_req_0_1(exch, VFS_IN_PING, &num_mounted_fs); 846 if (rc != EOK) 847 goto exit; 848 849 for (i = 0; i < num_mounted_fs; ++i) { 850 mtab_ent_t *mtab_ent; 851 852 mtab_ent = malloc(sizeof(mtab_ent_t)); 853 if (!mtab_ent) { 854 rc = ENOMEM; 855 goto exit; 856 } 857 858 memset(mtab_ent, 0, sizeof(mtab_ent_t)); 859 860 rc = async_data_read_start(exch, (void *) mtab_ent->mp, 861 MAX_PATH_LEN); 862 if (rc != EOK) 863 goto exit; 864 865 rc = async_data_read_start(exch, (void *) mtab_ent->opts, 866 MAX_MNTOPTS_LEN); 867 if (rc != EOK) 868 goto exit; 869 870 rc = async_data_read_start(exch, (void *) mtab_ent->fs_name, 871 FS_NAME_MAXLEN); 872 if (rc != EOK) 873 goto exit; 874 875 sysarg_t p[2]; 876 877 rc = async_req_0_2(exch, VFS_IN_PING, &p[0], &p[1]); 878 if (rc != EOK) 879 goto exit; 880 881 mtab_ent->instance = p[0]; 882 mtab_ent->service_id = p[1]; 883 884 link_initialize(&mtab_ent->link); 885 list_append(&mtab_ent->link, mtab_list); 886 } 887 888 exit: 889 async_wait_for(req, &rc); 890 vfs_exchange_end(exch); 891 return rc; 892 } 893 833 894 /** @} 834 895 */ -
uspace/lib/c/include/ipc/vfs.h
r3569955 r5664cf64 42 42 #define FS_NAME_MAXLEN 20 43 43 #define MAX_PATH_LEN (64 * 1024) 44 #define MAX_MNTOPTS_LEN 256 44 45 #define PLB_SIZE (2 * MAX_PATH_LEN) 45 46 … … 80 81 VFS_IN_DUP, 81 82 VFS_IN_WAIT_HANDLE, 83 VFS_IN_MTAB_GET, 82 84 } vfs_in_request_t; 83 85 -
uspace/lib/c/include/vfs/vfs.h
r3569955 r5664cf64 39 39 #include <ipc/vfs.h> 40 40 #include <ipc/loc.h> 41 #include <adt/list.h> 41 42 #include <stdio.h> 42 43 #include <async.h> 44 #include "vfs_mtab.h" 43 45 44 46 enum vfs_change_state_type { … … 55 57 56 58 extern int fd_wait(void); 59 extern int get_mtab_list(list_t *mtab_list); 57 60 58 61 extern async_exch_t *vfs_exchange_begin(void); -
uspace/srv/vfs/vfs.c
r3569955 r5664cf64 127 127 vfs_wait_handle(callid, &call); 128 128 break; 129 case VFS_IN_MTAB_GET: 130 vfs_get_mtab(callid, &call); 131 break; 129 132 default: 130 133 async_answer_0(callid, ENOTSUP); -
uspace/srv/vfs/vfs.h
r3569955 r5664cf64 150 150 extern list_t fs_list; /**< List of registered file systems. */ 151 151 152 extern fibril_mutex_t fs_mntlist_lock; 153 extern list_t fs_mntlist; /**< List of mounted file systems. */ 154 152 155 extern vfs_pair_t rootfs; /**< Root file system. */ 153 156 … … 162 165 extern uint8_t *plb; /**< Path Lookup Buffer */ 163 166 extern list_t plb_entries; /**< List of active PLB entries. */ 164 165 #define MAX_MNTOPTS_LEN 256166 167 167 168 /** Holding this rwlock prevents changes in file system namespace. */ … … 219 220 extern void vfs_rename(ipc_callid_t, ipc_call_t *); 220 221 extern void vfs_wait_handle(ipc_callid_t, ipc_call_t *); 222 extern void vfs_get_mtab(ipc_callid_t, ipc_call_t *); 221 223 222 224 #endif -
uspace/srv/vfs/vfs_ops.c
r3569955 r5664cf64 52 52 #include <assert.h> 53 53 #include <vfs/canonify.h> 54 #include <vfs/vfs_mtab.h> 55 56 FIBRIL_MUTEX_INITIALIZE(mtab_list_lock); 57 LIST_INITIALIZE(mtab_list); 58 static size_t mtab_size = 0; 54 59 55 60 /* Forward declarations of static functions. */ … … 68 73 }; 69 74 70 static voidvfs_mount_internal(ipc_callid_t rid, service_id_t service_id,75 static int vfs_mount_internal(ipc_callid_t rid, service_id_t service_id, 71 76 fs_handle_t fs_handle, char *mp, char *opts) 72 77 { … … 91 96 fibril_rwlock_write_unlock(&namespace_rwlock); 92 97 async_answer_0(rid, EBUSY); 93 return ;98 return EBUSY; 94 99 } 95 100 … … 99 104 fibril_rwlock_write_unlock(&namespace_rwlock); 100 105 async_answer_0(rid, rc); 101 return ;106 return rc; 102 107 } 103 108 … … 106 111 fibril_rwlock_write_unlock(&namespace_rwlock); 107 112 async_answer_0(rid, ENOMEM); 108 return ;113 return ENOMEM; 109 114 } 110 115 … … 135 140 fibril_rwlock_write_unlock(&namespace_rwlock); 136 141 async_answer_0(rid, rc); 137 return ;142 return rc; 138 143 } 139 144 async_wait_for(msg, &rc); … … 142 147 fibril_rwlock_write_unlock(&namespace_rwlock); 143 148 async_answer_0(rid, rc); 144 return ;149 return rc; 145 150 } 146 151 … … 166 171 fibril_rwlock_write_unlock(&namespace_rwlock); 167 172 async_answer_0(rid, rc); 168 return ;173 return rc; 169 174 } else { 170 175 /* … … 174 179 fibril_rwlock_write_unlock(&namespace_rwlock); 175 180 async_answer_0(rid, ENOENT); 176 return ;181 return ENOENT; 177 182 } 178 183 } … … 207 212 async_answer_0(rid, rc); 208 213 fibril_rwlock_write_unlock(&namespace_rwlock); 209 return ;214 return rc; 210 215 } 211 216 … … 222 227 fibril_rwlock_write_unlock(&namespace_rwlock); 223 228 async_answer_0(rid, rc); 224 return ;229 return rc; 225 230 } 226 231 … … 258 263 async_answer_0(rid, rc); 259 264 fibril_rwlock_write_unlock(&namespace_rwlock); 265 return rc; 260 266 } 261 267 … … 352 358 } 353 359 fibril_mutex_unlock(&fs_list_lock); 354 355 /* Acknowledge that we know fs_name. */ 356 async_answer_0(callid, EOK); 357 360 361 /* Add the filesystem info to the list of mounted filesystems */ 362 mtab_ent_t *mtab_ent = malloc(sizeof(mtab_ent_t)); 363 if (!mtab_ent) { 364 async_answer_0(callid, ENOMEM); 365 async_answer_0(rid, ENOMEM); 366 free(mp); 367 free(fs_name); 368 free(opts); 369 return; 370 } 371 358 372 /* Do the mount */ 359 vfs_mount_internal(rid, service_id, fs_handle, mp, opts); 373 rc = vfs_mount_internal(rid, service_id, fs_handle, mp, opts); 374 if (rc != EOK) { 375 async_answer_0(callid, ENOTSUP); 376 async_answer_0(rid, ENOTSUP); 377 free(mtab_ent); 378 free(mp); 379 free(opts); 380 free(fs_name); 381 return; 382 } 383 384 /* Add the filesystem info to the list of mounted filesystems */ 385 386 str_cpy(mtab_ent->mp, MAX_PATH_LEN, mp); 387 str_cpy(mtab_ent->fs_name, FS_NAME_MAXLEN, fs_name); 388 str_cpy(mtab_ent->opts, MAX_MNTOPTS_LEN, opts); 389 mtab_ent->instance = instance; 390 mtab_ent->service_id = service_id; 391 392 link_initialize(&mtab_ent->link); 393 394 fibril_mutex_lock(&mtab_list_lock); 395 list_append(&mtab_ent->link, &mtab_list); 396 mtab_size++; 397 fibril_mutex_unlock(&mtab_list_lock); 398 360 399 free(mp); 361 400 free(fs_name); 362 401 free(opts); 402 403 /* Acknowledge that we know fs_name. */ 404 async_answer_0(callid, EOK); 363 405 } 364 406 … … 433 475 */ 434 476 435 free(mp);436 437 477 exch = vfs_exchange_grab(mr_node->fs_handle); 438 478 rc = async_req_1_0(exch, VFS_OUT_UNMOUNTED, … … 442 482 if (rc != EOK) { 443 483 fibril_rwlock_write_unlock(&namespace_rwlock); 484 free(mp); 444 485 vfs_node_put(mr_node); 445 486 async_answer_0(rid, rc); … … 459 500 460 501 rc = vfs_lookup_internal(mp, L_MP, &mp_res, NULL); 461 free(mp);462 502 if (rc != EOK) { 463 503 fibril_rwlock_write_unlock(&namespace_rwlock); 504 free(mp); 464 505 vfs_node_put(mr_node); 465 506 async_answer_0(rid, rc); … … 470 511 if (!mp_node) { 471 512 fibril_rwlock_write_unlock(&namespace_rwlock); 513 free(mp); 472 514 vfs_node_put(mr_node); 473 515 async_answer_0(rid, ENOMEM); … … 482 524 if (rc != EOK) { 483 525 fibril_rwlock_write_unlock(&namespace_rwlock); 526 free(mp); 484 527 vfs_node_put(mp_node); 485 528 vfs_node_put(mr_node); … … 499 542 */ 500 543 vfs_node_forget(mr_node); 501 502 544 fibril_rwlock_write_unlock(&namespace_rwlock); 545 546 fibril_mutex_lock(&mtab_list_lock); 547 548 int found = 0; 549 550 list_foreach(mtab_list, cur) { 551 mtab_ent_t *mtab_ent = list_get_instance(cur, mtab_ent_t, 552 link); 553 554 if (str_cmp(mtab_ent->mp, mp) == 0) { 555 list_remove(&mtab_ent->link); 556 mtab_size--; 557 free(mtab_ent); 558 found = 1; 559 break; 560 } 561 } 562 assert(found); 563 fibril_mutex_unlock(&mtab_list_lock); 564 565 free(mp); 566 503 567 async_answer_0(rid, EOK); 504 568 } … … 1289 1353 } 1290 1354 1355 void vfs_get_mtab(ipc_callid_t rid, ipc_call_t *request) 1356 { 1357 ipc_callid_t callid; 1358 ipc_call_t data; 1359 sysarg_t rc = EOK; 1360 size_t len; 1361 1362 fibril_mutex_lock(&mtab_list_lock); 1363 1364 /* Send to the caller the number of mounted filesystems */ 1365 callid = async_get_call(&data); 1366 if (IPC_GET_IMETHOD(data) != VFS_IN_PING) { 1367 rc = ENOTSUP; 1368 async_answer_0(callid, rc); 1369 goto exit; 1370 } 1371 async_answer_1(callid, EOK, mtab_size); 1372 1373 list_foreach(mtab_list, cur) { 1374 mtab_ent_t *mtab_ent = list_get_instance(cur, mtab_ent_t, 1375 link); 1376 1377 rc = ENOTSUP; 1378 1379 if (!async_data_read_receive(&callid, &len)) { 1380 async_answer_0(callid, rc); 1381 goto exit; 1382 } 1383 1384 (void) async_data_read_finalize(callid, mtab_ent->mp, 1385 str_size(mtab_ent->mp)); 1386 1387 if (!async_data_read_receive(&callid, &len)) { 1388 async_answer_0(callid, rc); 1389 goto exit; 1390 } 1391 1392 (void) async_data_read_finalize(callid, mtab_ent->opts, 1393 str_size(mtab_ent->opts)); 1394 1395 if (!async_data_read_receive(&callid, &len)) { 1396 async_answer_0(callid, rc); 1397 goto exit; 1398 } 1399 1400 (void) async_data_read_finalize(callid, mtab_ent->fs_name, 1401 str_size(mtab_ent->fs_name)); 1402 1403 callid = async_get_call(&data); 1404 1405 if (IPC_GET_IMETHOD(data) != VFS_IN_PING) { 1406 async_answer_0(callid, rc); 1407 goto exit; 1408 } 1409 1410 rc = EOK; 1411 async_answer_2(callid, rc, mtab_ent->instance, 1412 mtab_ent->service_id); 1413 } 1414 1415 exit: 1416 fibril_mutex_unlock(&mtab_list_lock); 1417 async_answer_0(rid, rc); 1418 } 1419 1291 1420 /** 1292 1421 * @}
Note:
See TracChangeset
for help on using the changeset viewer.