Changes in uspace/srv/fs/fat/fat_ops.c [c7bbf029:a93d79a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_ops.c
rc7bbf029 ra93d79a 42 42 #include <libfs.h> 43 43 #include <libblock.h> 44 #include <ipc/ipc.h> 44 45 #include <ipc/services.h> 45 46 #include <ipc/devmap.h> … … 55 56 #include <sys/mman.h> 56 57 #include <align.h> 57 #include <malloc.h>58 58 59 59 #define FAT_NODE(node) ((node) ? (fat_node_t *) (node)->data : NULL) … … 72 72 * Forward declarations of FAT libfs operations. 73 73 */ 74 static int fat_root_get(fs_node_t **, dev map_handle_t);74 static int fat_root_get(fs_node_t **, dev_handle_t); 75 75 static int fat_match(fs_node_t **, fs_node_t *, const char *); 76 static int fat_node_get(fs_node_t **, dev map_handle_t, fs_index_t);76 static int fat_node_get(fs_node_t **, dev_handle_t, fs_index_t); 77 77 static int fat_node_open(fs_node_t *); 78 78 static int fat_node_put(fs_node_t *); 79 static int fat_create_node(fs_node_t **, dev map_handle_t, int);79 static int fat_create_node(fs_node_t **, dev_handle_t, int); 80 80 static int fat_destroy_node(fs_node_t *); 81 81 static int fat_link(fs_node_t *, fs_node_t *, const char *); … … 88 88 static bool fat_is_directory(fs_node_t *); 89 89 static bool fat_is_file(fs_node_t *node); 90 static dev map_handle_t fat_device_get(fs_node_t *node);90 static dev_handle_t fat_device_get(fs_node_t *node); 91 91 92 92 /* … … 120 120 assert(node->dirty); 121 121 122 bs = block_bb_get(node->idx->dev map_handle);122 bs = block_bb_get(node->idx->dev_handle); 123 123 124 124 /* Read the block that contains the dentry of interest. */ 125 rc = _fat_block_get(&b, bs, node->idx->dev map_handle, node->idx->pfc,125 rc = _fat_block_get(&b, bs, node->idx->dev_handle, node->idx->pfc, 126 126 NULL, (node->idx->pdi * sizeof(fat_dentry_t)) / BPS(bs), 127 127 BLOCK_FLAGS_NONE); … … 145 145 } 146 146 147 static int fat_node_fini_by_dev map_handle(devmap_handle_t devmap_handle)147 static int fat_node_fini_by_dev_handle(dev_handle_t dev_handle) 148 148 { 149 149 link_t *lnk; … … 170 170 goto restart; 171 171 } 172 if (nodep->idx->dev map_handle != devmap_handle) {172 if (nodep->idx->dev_handle != dev_handle) { 173 173 fibril_mutex_unlock(&nodep->idx->lock); 174 174 fibril_mutex_unlock(&nodep->lock); … … 299 299 return rc; 300 300 301 bs = block_bb_get(idxp->dev map_handle);301 bs = block_bb_get(idxp->dev_handle); 302 302 303 303 /* Read the block that contains the dentry of interest. */ 304 rc = _fat_block_get(&b, bs, idxp->dev map_handle, idxp->pfc, NULL,304 rc = _fat_block_get(&b, bs, idxp->dev_handle, idxp->pfc, NULL, 305 305 (idxp->pdi * sizeof(fat_dentry_t)) / BPS(bs), BLOCK_FLAGS_NONE); 306 306 if (rc != EOK) { … … 323 323 */ 324 324 uint16_t clusters; 325 rc = fat_clusters_get(&clusters, bs, idxp->dev map_handle,325 rc = fat_clusters_get(&clusters, bs, idxp->dev_handle, 326 326 uint16_t_le2host(d->firstc)); 327 327 if (rc != EOK) { 328 (void) block_put(b);329 328 (void) fat_node_put(FS_NODE(nodep)); 330 329 return rc; … … 357 356 */ 358 357 359 int fat_root_get(fs_node_t **rfn, dev map_handle_t devmap_handle)360 { 361 return fat_node_get(rfn, dev map_handle, 0);358 int fat_root_get(fs_node_t **rfn, dev_handle_t dev_handle) 359 { 360 return fat_node_get(rfn, dev_handle, 0); 362 361 } 363 362 … … 370 369 unsigned blocks; 371 370 fat_dentry_t *d; 372 dev map_handle_t devmap_handle;371 dev_handle_t dev_handle; 373 372 block_t *b; 374 373 int rc; 375 374 376 375 fibril_mutex_lock(&parentp->idx->lock); 377 dev map_handle = parentp->idx->devmap_handle;376 dev_handle = parentp->idx->dev_handle; 378 377 fibril_mutex_unlock(&parentp->idx->lock); 379 378 380 bs = block_bb_get(dev map_handle);379 bs = block_bb_get(dev_handle); 381 380 blocks = parentp->size / BPS(bs); 382 381 for (i = 0; i < blocks; i++) { … … 403 402 /* hit */ 404 403 fat_node_t *nodep; 405 fat_idx_t *idx = fat_idx_get_by_pos(dev map_handle,404 fat_idx_t *idx = fat_idx_get_by_pos(dev_handle, 406 405 parentp->firstc, i * DPS(bs) + j); 407 406 if (!idx) { … … 436 435 437 436 /** Instantiate a FAT in-core node. */ 438 int fat_node_get(fs_node_t **rfn, dev map_handle_t devmap_handle, fs_index_t index)437 int fat_node_get(fs_node_t **rfn, dev_handle_t dev_handle, fs_index_t index) 439 438 { 440 439 fat_node_t *nodep; … … 442 441 int rc; 443 442 444 idxp = fat_idx_get_by_index(dev map_handle, index);443 idxp = fat_idx_get_by_index(dev_handle, index); 445 444 if (!idxp) { 446 445 *rfn = NULL; … … 493 492 } 494 493 495 int fat_create_node(fs_node_t **rfn, dev map_handle_t devmap_handle, int flags)494 int fat_create_node(fs_node_t **rfn, dev_handle_t dev_handle, int flags) 496 495 { 497 496 fat_idx_t *idxp; … … 501 500 int rc; 502 501 503 bs = block_bb_get(dev map_handle);502 bs = block_bb_get(dev_handle); 504 503 if (flags & L_DIRECTORY) { 505 504 /* allocate a cluster */ 506 rc = fat_alloc_clusters(bs, dev map_handle, 1, &mcl, &lcl);505 rc = fat_alloc_clusters(bs, dev_handle, 1, &mcl, &lcl); 507 506 if (rc != EOK) 508 507 return rc; 509 508 /* populate the new cluster with unused dentries */ 510 rc = fat_zero_cluster(bs, dev map_handle, mcl);509 rc = fat_zero_cluster(bs, dev_handle, mcl); 511 510 if (rc != EOK) { 512 (void) fat_free_clusters(bs, dev map_handle, mcl);511 (void) fat_free_clusters(bs, dev_handle, mcl); 513 512 return rc; 514 513 } … … 517 516 rc = fat_node_get_new(&nodep); 518 517 if (rc != EOK) { 519 (void) fat_free_clusters(bs, dev map_handle, mcl);518 (void) fat_free_clusters(bs, dev_handle, mcl); 520 519 return rc; 521 520 } 522 rc = fat_idx_get_new(&idxp, dev map_handle);523 if (rc != EOK) { 524 (void) fat_free_clusters(bs, dev map_handle, mcl);521 rc = fat_idx_get_new(&idxp, dev_handle); 522 if (rc != EOK) { 523 (void) fat_free_clusters(bs, dev_handle, mcl); 525 524 (void) fat_node_put(FS_NODE(nodep)); 526 525 return rc; … … 571 570 assert(!has_children); 572 571 573 bs = block_bb_get(nodep->idx->dev map_handle);572 bs = block_bb_get(nodep->idx->dev_handle); 574 573 if (nodep->firstc != FAT_CLST_RES0) { 575 574 assert(nodep->size); 576 575 /* Free all clusters allocated to the node. */ 577 rc = fat_free_clusters(bs, nodep->idx->dev map_handle,576 rc = fat_free_clusters(bs, nodep->idx->dev_handle, 578 577 nodep->firstc); 579 578 } … … 621 620 622 621 fibril_mutex_lock(&parentp->idx->lock); 623 bs = block_bb_get(parentp->idx->dev map_handle);622 bs = block_bb_get(parentp->idx->dev_handle); 624 623 625 624 blocks = parentp->size / BPS(bs); … … 660 659 return ENOSPC; 661 660 } 662 rc = fat_alloc_clusters(bs, parentp->idx->dev map_handle, 1, &mcl, &lcl);661 rc = fat_alloc_clusters(bs, parentp->idx->dev_handle, 1, &mcl, &lcl); 663 662 if (rc != EOK) { 664 663 fibril_mutex_unlock(&parentp->idx->lock); 665 664 return rc; 666 665 } 667 rc = fat_zero_cluster(bs, parentp->idx->dev map_handle, mcl);668 if (rc != EOK) { 669 (void) fat_free_clusters(bs, parentp->idx->dev map_handle, mcl);666 rc = fat_zero_cluster(bs, parentp->idx->dev_handle, mcl); 667 if (rc != EOK) { 668 (void) fat_free_clusters(bs, parentp->idx->dev_handle, mcl); 670 669 fibril_mutex_unlock(&parentp->idx->lock); 671 670 return rc; … … 673 672 rc = fat_append_clusters(bs, parentp, mcl, lcl); 674 673 if (rc != EOK) { 675 (void) fat_free_clusters(bs, parentp->idx->dev map_handle, mcl);674 (void) fat_free_clusters(bs, parentp->idx->dev_handle, mcl); 676 675 fibril_mutex_unlock(&parentp->idx->lock); 677 676 return rc; … … 723 722 (str_cmp((char *) d->name, FAT_NAME_DOT)) == 0) { 724 723 memset(d, 0, sizeof(fat_dentry_t)); 725 memcpy(d->name, FAT_NAME_DOT, FAT_NAME_LEN);726 memcpy(d->ext, FAT_EXT_PAD, FAT_EXT_LEN);724 str_cpy((char *) d->name, 8, FAT_NAME_DOT); 725 str_cpy((char *) d->ext, 3, FAT_EXT_PAD); 727 726 d->attr = FAT_ATTR_SUBDIR; 728 727 d->firstc = host2uint16_t_le(childp->firstc); … … 733 732 (str_cmp((char *) d->name, FAT_NAME_DOT_DOT) == 0)) { 734 733 memset(d, 0, sizeof(fat_dentry_t)); 735 memcpy(d->name, FAT_NAME_DOT_DOT, FAT_NAME_LEN);736 memcpy(d->ext, FAT_EXT_PAD, FAT_EXT_LEN);734 str_cpy((char *) d->name, 8, FAT_NAME_DOT_DOT); 735 str_cpy((char *) d->ext, 3, FAT_EXT_PAD); 737 736 d->attr = FAT_ATTR_SUBDIR; 738 737 d->firstc = (parentp->firstc == FAT_CLST_ROOT) ? … … 790 789 assert(childp->lnkcnt == 1); 791 790 fibril_mutex_lock(&childp->idx->lock); 792 bs = block_bb_get(childp->idx->dev map_handle);793 794 rc = _fat_block_get(&b, bs, childp->idx->dev map_handle, childp->idx->pfc,791 bs = block_bb_get(childp->idx->dev_handle); 792 793 rc = _fat_block_get(&b, bs, childp->idx->dev_handle, childp->idx->pfc, 795 794 NULL, (childp->idx->pdi * sizeof(fat_dentry_t)) / BPS(bs), 796 795 BLOCK_FLAGS_NONE); … … 813 812 fibril_mutex_unlock(&childp->idx->lock); 814 813 childp->lnkcnt = 0; 815 childp->refcnt++; /* keep the node in memory until destroyed */816 814 childp->dirty = true; 817 815 fibril_mutex_unlock(&childp->lock); … … 842 840 843 841 fibril_mutex_lock(&nodep->idx->lock); 844 bs = block_bb_get(nodep->idx->dev map_handle);842 bs = block_bb_get(nodep->idx->dev_handle); 845 843 846 844 blocks = nodep->size / BPS(bs); … … 916 914 } 917 915 918 dev map_handle_t fat_device_get(fs_node_t *node)916 dev_handle_t fat_device_get(fs_node_t *node) 919 917 { 920 918 return 0; … … 948 946 void fat_mounted(ipc_callid_t rid, ipc_call_t *request) 949 947 { 950 dev map_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);948 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 951 949 enum cache_mode cmode; 952 950 fat_bs_t *bs; … … 957 955 958 956 if (rc != EOK) { 959 async_answer_0(rid, rc);957 ipc_answer_0(rid, rc); 960 958 return; 961 959 } … … 970 968 971 969 /* initialize libblock */ 972 rc = block_init(dev map_handle, BS_SIZE);973 if (rc != EOK) { 974 async_answer_0(rid, rc);970 rc = block_init(dev_handle, BS_SIZE); 971 if (rc != EOK) { 972 ipc_answer_0(rid, rc); 975 973 return; 976 974 } 977 975 978 976 /* prepare the boot block */ 979 rc = block_bb_read(dev map_handle, BS_BLOCK);980 if (rc != EOK) { 981 block_fini(dev map_handle);982 async_answer_0(rid, rc);977 rc = block_bb_read(dev_handle, BS_BLOCK); 978 if (rc != EOK) { 979 block_fini(dev_handle); 980 ipc_answer_0(rid, rc); 983 981 return; 984 982 } 985 983 986 984 /* get the buffer with the boot sector */ 987 bs = block_bb_get(dev map_handle);985 bs = block_bb_get(dev_handle); 988 986 989 987 if (BPS(bs) != BS_SIZE) { 990 block_fini(dev map_handle);991 async_answer_0(rid, ENOTSUP);988 block_fini(dev_handle); 989 ipc_answer_0(rid, ENOTSUP); 992 990 return; 993 991 } 994 992 995 993 /* Initialize the block cache */ 996 rc = block_cache_init(dev map_handle, BPS(bs), 0 /* XXX */, cmode);997 if (rc != EOK) { 998 block_fini(dev map_handle);999 async_answer_0(rid, rc);994 rc = block_cache_init(dev_handle, BPS(bs), 0 /* XXX */, cmode); 995 if (rc != EOK) { 996 block_fini(dev_handle); 997 ipc_answer_0(rid, rc); 1000 998 return; 1001 999 } 1002 1000 1003 1001 /* Do some simple sanity checks on the file system. */ 1004 rc = fat_sanity_check(bs, dev map_handle);1005 if (rc != EOK) { 1006 (void) block_cache_fini(dev map_handle);1007 block_fini(dev map_handle);1008 async_answer_0(rid, rc);1009 return; 1010 } 1011 1012 rc = fat_idx_init_by_dev map_handle(devmap_handle);1013 if (rc != EOK) { 1014 (void) block_cache_fini(dev map_handle);1015 block_fini(dev map_handle);1016 async_answer_0(rid, rc);1002 rc = fat_sanity_check(bs, dev_handle); 1003 if (rc != EOK) { 1004 (void) block_cache_fini(dev_handle); 1005 block_fini(dev_handle); 1006 ipc_answer_0(rid, rc); 1007 return; 1008 } 1009 1010 rc = fat_idx_init_by_dev_handle(dev_handle); 1011 if (rc != EOK) { 1012 (void) block_cache_fini(dev_handle); 1013 block_fini(dev_handle); 1014 ipc_answer_0(rid, rc); 1017 1015 return; 1018 1016 } … … 1021 1019 fs_node_t *rfn = (fs_node_t *)malloc(sizeof(fs_node_t)); 1022 1020 if (!rfn) { 1023 (void) block_cache_fini(dev map_handle);1024 block_fini(dev map_handle);1025 fat_idx_fini_by_dev map_handle(devmap_handle);1026 async_answer_0(rid, ENOMEM);1021 (void) block_cache_fini(dev_handle); 1022 block_fini(dev_handle); 1023 fat_idx_fini_by_dev_handle(dev_handle); 1024 ipc_answer_0(rid, ENOMEM); 1027 1025 return; 1028 1026 } … … 1031 1029 if (!rootp) { 1032 1030 free(rfn); 1033 (void) block_cache_fini(dev map_handle);1034 block_fini(dev map_handle);1035 fat_idx_fini_by_dev map_handle(devmap_handle);1036 async_answer_0(rid, ENOMEM);1031 (void) block_cache_fini(dev_handle); 1032 block_fini(dev_handle); 1033 fat_idx_fini_by_dev_handle(dev_handle); 1034 ipc_answer_0(rid, ENOMEM); 1037 1035 return; 1038 1036 } 1039 1037 fat_node_initialize(rootp); 1040 1038 1041 fat_idx_t *ridxp = fat_idx_get_by_pos(dev map_handle, FAT_CLST_ROOTPAR, 0);1039 fat_idx_t *ridxp = fat_idx_get_by_pos(dev_handle, FAT_CLST_ROOTPAR, 0); 1042 1040 if (!ridxp) { 1043 1041 free(rfn); 1044 1042 free(rootp); 1045 (void) block_cache_fini(dev map_handle);1046 block_fini(dev map_handle);1047 fat_idx_fini_by_dev map_handle(devmap_handle);1048 async_answer_0(rid, ENOMEM);1043 (void) block_cache_fini(dev_handle); 1044 block_fini(dev_handle); 1045 fat_idx_fini_by_dev_handle(dev_handle); 1046 ipc_answer_0(rid, ENOMEM); 1049 1047 return; 1050 1048 } … … 1064 1062 fibril_mutex_unlock(&ridxp->lock); 1065 1063 1066 async_answer_3(rid, EOK, ridxp->index, rootp->size, rootp->lnkcnt);1064 ipc_answer_3(rid, EOK, ridxp->index, rootp->size, rootp->lnkcnt); 1067 1065 } 1068 1066 … … 1074 1072 void fat_unmounted(ipc_callid_t rid, ipc_call_t *request) 1075 1073 { 1076 dev map_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);1074 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 1077 1075 fs_node_t *fn; 1078 1076 fat_node_t *nodep; 1079 1077 int rc; 1080 1078 1081 rc = fat_root_get(&fn, dev map_handle);1082 if (rc != EOK) { 1083 async_answer_0(rid, rc);1079 rc = fat_root_get(&fn, dev_handle); 1080 if (rc != EOK) { 1081 ipc_answer_0(rid, rc); 1084 1082 return; 1085 1083 } … … 1092 1090 if (nodep->refcnt != 2) { 1093 1091 (void) fat_node_put(fn); 1094 async_answer_0(rid, EBUSY);1092 ipc_answer_0(rid, EBUSY); 1095 1093 return; 1096 1094 } … … 1107 1105 * stop using libblock for this instance. 1108 1106 */ 1109 (void) fat_node_fini_by_dev map_handle(devmap_handle);1110 fat_idx_fini_by_dev map_handle(devmap_handle);1111 (void) block_cache_fini(dev map_handle);1112 block_fini(dev map_handle);1113 1114 async_answer_0(rid, EOK);1107 (void) fat_node_fini_by_dev_handle(dev_handle); 1108 fat_idx_fini_by_dev_handle(dev_handle); 1109 (void) block_cache_fini(dev_handle); 1110 block_fini(dev_handle); 1111 1112 ipc_answer_0(rid, EOK); 1115 1113 } 1116 1114 … … 1127 1125 void fat_read(ipc_callid_t rid, ipc_call_t *request) 1128 1126 { 1129 dev map_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);1127 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 1130 1128 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 1131 1129 aoff64_t pos = … … 1138 1136 int rc; 1139 1137 1140 rc = fat_node_get(&fn, dev map_handle, index);1141 if (rc != EOK) { 1142 async_answer_0(rid, rc);1138 rc = fat_node_get(&fn, dev_handle, index); 1139 if (rc != EOK) { 1140 ipc_answer_0(rid, rc); 1143 1141 return; 1144 1142 } 1145 1143 if (!fn) { 1146 async_answer_0(rid, ENOENT);1144 ipc_answer_0(rid, ENOENT); 1147 1145 return; 1148 1146 } … … 1153 1151 if (!async_data_read_receive(&callid, &len)) { 1154 1152 fat_node_put(fn); 1155 async_answer_0(callid, EINVAL);1156 async_answer_0(rid, EINVAL);1157 return; 1158 } 1159 1160 bs = block_bb_get(dev map_handle);1153 ipc_answer_0(callid, EINVAL); 1154 ipc_answer_0(rid, EINVAL); 1155 return; 1156 } 1157 1158 bs = block_bb_get(dev_handle); 1161 1159 1162 1160 if (nodep->type == FAT_FILE) { … … 1177 1175 if (rc != EOK) { 1178 1176 fat_node_put(fn); 1179 async_answer_0(callid, rc);1180 async_answer_0(rid, rc);1177 ipc_answer_0(callid, rc); 1178 ipc_answer_0(rid, rc); 1181 1179 return; 1182 1180 } … … 1186 1184 if (rc != EOK) { 1187 1185 fat_node_put(fn); 1188 async_answer_0(rid, rc);1186 ipc_answer_0(rid, rc); 1189 1187 return; 1190 1188 } … … 1243 1241 miss: 1244 1242 rc = fat_node_put(fn); 1245 async_answer_0(callid, rc != EOK ? rc : ENOENT);1246 async_answer_1(rid, rc != EOK ? rc : ENOENT, 0);1243 ipc_answer_0(callid, rc != EOK ? rc : ENOENT); 1244 ipc_answer_1(rid, rc != EOK ? rc : ENOENT, 0); 1247 1245 return; 1248 1246 1249 1247 err: 1250 1248 (void) fat_node_put(fn); 1251 async_answer_0(callid, rc);1252 async_answer_0(rid, rc);1249 ipc_answer_0(callid, rc); 1250 ipc_answer_0(rid, rc); 1253 1251 return; 1254 1252 … … 1259 1257 1260 1258 rc = fat_node_put(fn); 1261 async_answer_1(rid, rc, (sysarg_t)bytes);1259 ipc_answer_1(rid, rc, (ipcarg_t)bytes); 1262 1260 } 1263 1261 1264 1262 void fat_write(ipc_callid_t rid, ipc_call_t *request) 1265 1263 { 1266 dev map_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);1264 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 1267 1265 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 1268 1266 aoff64_t pos = … … 1277 1275 int rc; 1278 1276 1279 rc = fat_node_get(&fn, dev map_handle, index);1280 if (rc != EOK) { 1281 async_answer_0(rid, rc);1277 rc = fat_node_get(&fn, dev_handle, index); 1278 if (rc != EOK) { 1279 ipc_answer_0(rid, rc); 1282 1280 return; 1283 1281 } 1284 1282 if (!fn) { 1285 async_answer_0(rid, ENOENT);1283 ipc_answer_0(rid, ENOENT); 1286 1284 return; 1287 1285 } … … 1292 1290 if (!async_data_write_receive(&callid, &len)) { 1293 1291 (void) fat_node_put(fn); 1294 async_answer_0(callid, EINVAL);1295 async_answer_0(rid, EINVAL);1296 return; 1297 } 1298 1299 bs = block_bb_get(dev map_handle);1292 ipc_answer_0(callid, EINVAL); 1293 ipc_answer_0(rid, EINVAL); 1294 return; 1295 } 1296 1297 bs = block_bb_get(dev_handle); 1300 1298 1301 1299 /* … … 1321 1319 if (rc != EOK) { 1322 1320 (void) fat_node_put(fn); 1323 async_answer_0(callid, rc);1324 async_answer_0(rid, rc);1321 ipc_answer_0(callid, rc); 1322 ipc_answer_0(rid, rc); 1325 1323 return; 1326 1324 } … … 1328 1326 if (rc != EOK) { 1329 1327 (void) fat_node_put(fn); 1330 async_answer_0(callid, rc);1331 async_answer_0(rid, rc);1328 ipc_answer_0(callid, rc); 1329 ipc_answer_0(rid, rc); 1332 1330 return; 1333 1331 } … … 1338 1336 if (rc != EOK) { 1339 1337 (void) fat_node_put(fn); 1340 async_answer_0(rid, rc);1338 ipc_answer_0(rid, rc); 1341 1339 return; 1342 1340 } … … 1347 1345 size = nodep->size; 1348 1346 rc = fat_node_put(fn); 1349 async_answer_2(rid, rc, bytes, nodep->size);1347 ipc_answer_2(rid, rc, bytes, nodep->size); 1350 1348 return; 1351 1349 } else { … … 1359 1357 nclsts = (ROUND_UP(pos + bytes, BPC(bs)) - boundary) / BPC(bs); 1360 1358 /* create an independent chain of nclsts clusters in all FATs */ 1361 rc = fat_alloc_clusters(bs, dev map_handle, nclsts, &mcl, &lcl);1359 rc = fat_alloc_clusters(bs, dev_handle, nclsts, &mcl, &lcl); 1362 1360 if (rc != EOK) { 1363 1361 /* could not allocate a chain of nclsts clusters */ 1364 1362 (void) fat_node_put(fn); 1365 async_answer_0(callid, rc);1366 async_answer_0(rid, rc);1363 ipc_answer_0(callid, rc); 1364 ipc_answer_0(rid, rc); 1367 1365 return; 1368 1366 } … … 1370 1368 rc = fat_fill_gap(bs, nodep, mcl, pos); 1371 1369 if (rc != EOK) { 1372 (void) fat_free_clusters(bs, dev map_handle, mcl);1370 (void) fat_free_clusters(bs, dev_handle, mcl); 1373 1371 (void) fat_node_put(fn); 1374 async_answer_0(callid, rc);1375 async_answer_0(rid, rc);1372 ipc_answer_0(callid, rc); 1373 ipc_answer_0(rid, rc); 1376 1374 return; 1377 1375 } 1378 rc = _fat_block_get(&b, bs, dev map_handle, lcl, NULL,1376 rc = _fat_block_get(&b, bs, dev_handle, lcl, NULL, 1379 1377 (pos / BPS(bs)) % SPC(bs), flags); 1380 1378 if (rc != EOK) { 1381 (void) fat_free_clusters(bs, dev map_handle, mcl);1379 (void) fat_free_clusters(bs, dev_handle, mcl); 1382 1380 (void) fat_node_put(fn); 1383 async_answer_0(callid, rc);1384 async_answer_0(rid, rc);1381 ipc_answer_0(callid, rc); 1382 ipc_answer_0(rid, rc); 1385 1383 return; 1386 1384 } … … 1390 1388 rc = block_put(b); 1391 1389 if (rc != EOK) { 1392 (void) fat_free_clusters(bs, dev map_handle, mcl);1390 (void) fat_free_clusters(bs, dev_handle, mcl); 1393 1391 (void) fat_node_put(fn); 1394 async_answer_0(rid, rc);1392 ipc_answer_0(rid, rc); 1395 1393 return; 1396 1394 } … … 1401 1399 rc = fat_append_clusters(bs, nodep, mcl, lcl); 1402 1400 if (rc != EOK) { 1403 (void) fat_free_clusters(bs, dev map_handle, mcl);1401 (void) fat_free_clusters(bs, dev_handle, mcl); 1404 1402 (void) fat_node_put(fn); 1405 async_answer_0(rid, rc);1403 ipc_answer_0(rid, rc); 1406 1404 return; 1407 1405 } … … 1409 1407 nodep->dirty = true; /* need to sync node */ 1410 1408 rc = fat_node_put(fn); 1411 async_answer_2(rid, rc, bytes, size);1409 ipc_answer_2(rid, rc, bytes, size); 1412 1410 return; 1413 1411 } … … 1416 1414 void fat_truncate(ipc_callid_t rid, ipc_call_t *request) 1417 1415 { 1418 dev map_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);1416 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 1419 1417 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 1420 1418 aoff64_t size = … … 1425 1423 int rc; 1426 1424 1427 rc = fat_node_get(&fn, dev map_handle, index);1428 if (rc != EOK) { 1429 async_answer_0(rid, rc);1425 rc = fat_node_get(&fn, dev_handle, index); 1426 if (rc != EOK) { 1427 ipc_answer_0(rid, rc); 1430 1428 return; 1431 1429 } 1432 1430 if (!fn) { 1433 async_answer_0(rid, ENOENT);1431 ipc_answer_0(rid, ENOENT); 1434 1432 return; 1435 1433 } 1436 1434 nodep = FAT_NODE(fn); 1437 1435 1438 bs = block_bb_get(dev map_handle);1436 bs = block_bb_get(dev_handle); 1439 1437 1440 1438 if (nodep->size == size) { … … 1463 1461 } else { 1464 1462 fat_cluster_t lastc; 1465 rc = fat_cluster_walk(bs, dev map_handle, nodep->firstc,1463 rc = fat_cluster_walk(bs, dev_handle, nodep->firstc, 1466 1464 &lastc, NULL, (size - 1) / BPC(bs)); 1467 1465 if (rc != EOK) … … 1477 1475 out: 1478 1476 fat_node_put(fn); 1479 async_answer_0(rid, rc);1477 ipc_answer_0(rid, rc); 1480 1478 return; 1481 1479 } … … 1483 1481 void fat_close(ipc_callid_t rid, ipc_call_t *request) 1484 1482 { 1485 async_answer_0(rid, EOK);1483 ipc_answer_0(rid, EOK); 1486 1484 } 1487 1485 1488 1486 void fat_destroy(ipc_callid_t rid, ipc_call_t *request) 1489 1487 { 1490 dev map_handle_t devmap_handle = (devmap_handle_t)IPC_GET_ARG1(*request);1488 dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); 1491 1489 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); 1492 1490 fs_node_t *fn; 1493 fat_node_t *nodep;1494 1491 int rc; 1495 1492 1496 rc = fat_node_get(&fn, dev map_handle, index);1497 if (rc != EOK) { 1498 async_answer_0(rid, rc);1493 rc = fat_node_get(&fn, dev_handle, index); 1494 if (rc != EOK) { 1495 ipc_answer_0(rid, rc); 1499 1496 return; 1500 1497 } 1501 1498 if (!fn) { 1502 async_answer_0(rid, ENOENT); 1503 return; 1504 } 1505 1506 nodep = FAT_NODE(fn); 1507 /* 1508 * We should have exactly two references. One for the above 1509 * call to fat_node_get() and one from fat_unlink(). 1510 */ 1511 assert(nodep->refcnt == 2); 1499 ipc_answer_0(rid, ENOENT); 1500 return; 1501 } 1512 1502 1513 1503 rc = fat_destroy_node(fn); 1514 async_answer_0(rid, rc);1504 ipc_answer_0(rid, rc); 1515 1505 } 1516 1506 … … 1527 1517 void fat_sync(ipc_callid_t rid, ipc_call_t *request) 1528 1518 { 1529 dev map_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);1519 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 1530 1520 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 1531 1521 1532 1522 fs_node_t *fn; 1533 int rc = fat_node_get(&fn, dev map_handle, index);1534 if (rc != EOK) { 1535 async_answer_0(rid, rc);1523 int rc = fat_node_get(&fn, dev_handle, index); 1524 if (rc != EOK) { 1525 ipc_answer_0(rid, rc); 1536 1526 return; 1537 1527 } 1538 1528 if (!fn) { 1539 async_answer_0(rid, ENOENT);1529 ipc_answer_0(rid, ENOENT); 1540 1530 return; 1541 1531 } … … 1547 1537 1548 1538 fat_node_put(fn); 1549 async_answer_0(rid, rc);1539 ipc_answer_0(rid, rc); 1550 1540 } 1551 1541
Note:
See TracChangeset
for help on using the changeset viewer.