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