Changeset 00c2de63 in mainline for uspace/srv/fs/fat/fat_ops.c
- Timestamp:
- 2011-07-29T14:50:22Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b6759f4
- Parents:
- 6c69d19 (diff), 7ae249d (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_ops.c
r6c69d19 r00c2de63 85 85 static aoff64_t fat_size_get(fs_node_t *); 86 86 static unsigned fat_lnkcnt_get(fs_node_t *); 87 static char fat_plb_get_char(unsigned);88 87 static bool fat_is_directory(fs_node_t *); 89 88 static bool fat_is_file(fs_node_t *node); … … 901 900 } 902 901 903 char fat_plb_get_char(unsigned pos)904 {905 return fat_reg.plb_ro[pos % PLB_SIZE];906 }907 908 902 bool fat_is_directory(fs_node_t *fn) 909 903 { … … 936 930 .size_get = fat_size_get, 937 931 .lnkcnt_get = fat_lnkcnt_get, 938 .plb_get_char = fat_plb_get_char,939 932 .is_directory = fat_is_directory, 940 933 .is_file = fat_is_file, … … 943 936 944 937 /* 945 * VFSoperations.938 * FAT VFS_OUT operations. 946 939 */ 947 940 948 void fat_mounted(ipc_callid_t rid, ipc_call_t *request) 949 { 950 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 941 static int 942 fat_mounted(devmap_handle_t devmap_handle, const char *opts, fs_index_t *index, 943 aoff64_t *size, unsigned *linkcnt) 944 { 951 945 enum cache_mode cmode; 952 946 fat_bs_t *bs; 953 954 /* Accept the mount options */ 955 char *opts; 956 int rc = async_data_write_accept((void **) &opts, true, 0, 0, 0, NULL); 957 958 if (rc != EOK) { 959 async_answer_0(rid, rc); 960 return; 961 } 962 947 int rc; 948 963 949 /* Check for option enabling write through. */ 964 950 if (str_cmp(opts, "wtcache") == 0) … … 967 953 cmode = CACHE_MODE_WB; 968 954 969 free(opts);970 971 955 /* initialize libblock */ 972 956 rc = block_init(EXCHANGE_SERIALIZE, devmap_handle, BS_SIZE); 973 if (rc != EOK) { 974 async_answer_0(rid, rc); 975 return; 976 } 957 if (rc != EOK) 958 return rc; 977 959 978 960 /* prepare the boot block */ … … 980 962 if (rc != EOK) { 981 963 block_fini(devmap_handle); 982 async_answer_0(rid, rc); 983 return; 964 return rc; 984 965 } 985 966 … … 989 970 if (BPS(bs) != BS_SIZE) { 990 971 block_fini(devmap_handle); 991 async_answer_0(rid, ENOTSUP); 992 return; 972 return ENOTSUP; 993 973 } 994 974 … … 997 977 if (rc != EOK) { 998 978 block_fini(devmap_handle); 999 async_answer_0(rid, rc); 1000 return; 979 return rc; 1001 980 } 1002 981 … … 1006 985 (void) block_cache_fini(devmap_handle); 1007 986 block_fini(devmap_handle); 1008 async_answer_0(rid, rc); 1009 return; 987 return rc; 1010 988 } 1011 989 … … 1014 992 (void) block_cache_fini(devmap_handle); 1015 993 block_fini(devmap_handle); 1016 async_answer_0(rid, rc); 1017 return; 994 return rc; 1018 995 } 1019 996 … … 1024 1001 block_fini(devmap_handle); 1025 1002 fat_idx_fini_by_devmap_handle(devmap_handle); 1026 async_answer_0(rid, ENOMEM); 1027 return; 1003 return ENOMEM; 1028 1004 } 1029 1005 fs_node_initialize(rfn); … … 1034 1010 block_fini(devmap_handle); 1035 1011 fat_idx_fini_by_devmap_handle(devmap_handle); 1036 async_answer_0(rid, ENOMEM); 1037 return; 1012 return ENOMEM; 1038 1013 } 1039 1014 fat_node_initialize(rootp); … … 1046 1021 block_fini(devmap_handle); 1047 1022 fat_idx_fini_by_devmap_handle(devmap_handle); 1048 async_answer_0(rid, ENOMEM); 1049 return; 1023 return ENOMEM; 1050 1024 } 1051 1025 assert(ridxp->index == 0); … … 1064 1038 fibril_mutex_unlock(&ridxp->lock); 1065 1039 1066 async_answer_3(rid, EOK, ridxp->index, rootp->size, rootp->lnkcnt); 1067 } 1068 1069 void fat_mount(ipc_callid_t rid, ipc_call_t *request) 1070 { 1071 libfs_mount(&fat_libfs_ops, fat_reg.fs_handle, rid, request); 1072 } 1073 1074 void fat_unmounted(ipc_callid_t rid, ipc_call_t *request) 1075 { 1076 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 1040 *index = ridxp->index; 1041 *size = rootp->size; 1042 *linkcnt = rootp->lnkcnt; 1043 1044 return EOK; 1045 } 1046 1047 static int fat_unmounted(devmap_handle_t devmap_handle) 1048 { 1077 1049 fs_node_t *fn; 1078 1050 fat_node_t *nodep; … … 1080 1052 1081 1053 rc = fat_root_get(&fn, devmap_handle); 1082 if (rc != EOK) { 1083 async_answer_0(rid, rc); 1084 return; 1085 } 1054 if (rc != EOK) 1055 return rc; 1086 1056 nodep = FAT_NODE(fn); 1087 1057 … … 1092 1062 if (nodep->refcnt != 2) { 1093 1063 (void) fat_node_put(fn); 1094 async_answer_0(rid, EBUSY); 1095 return; 1064 return EBUSY; 1096 1065 } 1097 1066 … … 1112 1081 block_fini(devmap_handle); 1113 1082 1114 async_answer_0(rid, EOK); 1115 } 1116 1117 void fat_unmount(ipc_callid_t rid, ipc_call_t *request) 1118 { 1119 libfs_unmount(&fat_libfs_ops, rid, request); 1120 } 1121 1122 void fat_lookup(ipc_callid_t rid, ipc_call_t *request) 1123 { 1124 libfs_lookup(&fat_libfs_ops, fat_reg.fs_handle, rid, request); 1125 } 1126 1127 void fat_read(ipc_callid_t rid, ipc_call_t *request) 1128 { 1129 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 1130 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 1131 aoff64_t pos = 1132 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request)); 1083 return EOK; 1084 } 1085 1086 static int 1087 fat_read(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t pos, 1088 size_t *rbytes) 1089 { 1133 1090 fs_node_t *fn; 1134 1091 fat_node_t *nodep; … … 1139 1096 1140 1097 rc = fat_node_get(&fn, devmap_handle, index); 1141 if (rc != EOK) { 1142 async_answer_0(rid, rc); 1143 return; 1144 } 1145 if (!fn) { 1146 async_answer_0(rid, ENOENT); 1147 return; 1148 } 1098 if (rc != EOK) 1099 return rc; 1100 if (!fn) 1101 return ENOENT; 1149 1102 nodep = FAT_NODE(fn); 1150 1103 … … 1154 1107 fat_node_put(fn); 1155 1108 async_answer_0(callid, EINVAL); 1156 async_answer_0(rid, EINVAL); 1157 return; 1109 return EINVAL; 1158 1110 } 1159 1111 … … 1178 1130 fat_node_put(fn); 1179 1131 async_answer_0(callid, rc); 1180 async_answer_0(rid, rc); 1181 return; 1132 return rc; 1182 1133 } 1183 1134 (void) async_data_read_finalize(callid, … … 1186 1137 if (rc != EOK) { 1187 1138 fat_node_put(fn); 1188 async_answer_0(rid, rc); 1189 return; 1139 return rc; 1190 1140 } 1191 1141 } … … 1244 1194 rc = fat_node_put(fn); 1245 1195 async_answer_0(callid, rc != EOK ? rc : ENOENT); 1246 async_answer_1(rid, rc != EOK ? rc : ENOENT, 0);1247 return ;1196 *rbytes = 0; 1197 return rc != EOK ? rc : ENOENT; 1248 1198 1249 1199 err: 1250 1200 (void) fat_node_put(fn); 1251 1201 async_answer_0(callid, rc); 1252 async_answer_0(rid, rc); 1253 return; 1202 return rc; 1254 1203 1255 1204 hit: … … 1259 1208 1260 1209 rc = fat_node_put(fn); 1261 async_answer_1(rid, rc, (sysarg_t)bytes); 1262 } 1263 1264 void fat_write(ipc_callid_t rid, ipc_call_t *request) 1265 { 1266 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 1267 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 1268 aoff64_t pos = 1269 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request)); 1210 *rbytes = bytes; 1211 return rc; 1212 } 1213 1214 static int 1215 fat_write(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t pos, 1216 size_t *wbytes, aoff64_t *nsize) 1217 { 1270 1218 fs_node_t *fn; 1271 1219 fat_node_t *nodep; 1272 1220 fat_bs_t *bs; 1273 size_t bytes , size;1221 size_t bytes; 1274 1222 block_t *b; 1275 1223 aoff64_t boundary; … … 1278 1226 1279 1227 rc = fat_node_get(&fn, devmap_handle, index); 1280 if (rc != EOK) { 1281 async_answer_0(rid, rc); 1282 return; 1283 } 1284 if (!fn) { 1285 async_answer_0(rid, ENOENT); 1286 return; 1287 } 1228 if (rc != EOK) 1229 return rc; 1230 if (!fn) 1231 return ENOENT; 1288 1232 nodep = FAT_NODE(fn); 1289 1233 … … 1293 1237 (void) fat_node_put(fn); 1294 1238 async_answer_0(callid, EINVAL); 1295 async_answer_0(rid, EINVAL); 1296 return; 1239 return EINVAL; 1297 1240 } 1298 1241 … … 1322 1265 (void) fat_node_put(fn); 1323 1266 async_answer_0(callid, rc); 1324 async_answer_0(rid, rc); 1325 return; 1267 return rc; 1326 1268 } 1327 1269 rc = fat_block_get(&b, bs, nodep, pos / BPS(bs), flags); … … 1329 1271 (void) fat_node_put(fn); 1330 1272 async_answer_0(callid, rc); 1331 async_answer_0(rid, rc); 1332 return; 1273 return rc; 1333 1274 } 1334 1275 (void) async_data_write_finalize(callid, … … 1338 1279 if (rc != EOK) { 1339 1280 (void) fat_node_put(fn); 1340 async_answer_0(rid, rc); 1341 return; 1281 return rc; 1342 1282 } 1343 1283 if (pos + bytes > nodep->size) { … … 1345 1285 nodep->dirty = true; /* need to sync node */ 1346 1286 } 1347 size = nodep->size; 1287 *wbytes = bytes; 1288 *nsize = nodep->size; 1348 1289 rc = fat_node_put(fn); 1349 async_answer_2(rid, rc, bytes, nodep->size); 1350 return; 1290 return rc; 1351 1291 } else { 1352 1292 /* … … 1364 1304 (void) fat_node_put(fn); 1365 1305 async_answer_0(callid, rc); 1366 async_answer_0(rid, rc); 1367 return; 1306 return rc; 1368 1307 } 1369 1308 /* zero fill any gaps */ … … 1373 1312 (void) fat_node_put(fn); 1374 1313 async_answer_0(callid, rc); 1375 async_answer_0(rid, rc); 1376 return; 1314 return rc; 1377 1315 } 1378 1316 rc = _fat_block_get(&b, bs, devmap_handle, lcl, NULL, … … 1382 1320 (void) fat_node_put(fn); 1383 1321 async_answer_0(callid, rc); 1384 async_answer_0(rid, rc); 1385 return; 1322 return rc; 1386 1323 } 1387 1324 (void) async_data_write_finalize(callid, … … 1392 1329 (void) fat_free_clusters(bs, devmap_handle, mcl); 1393 1330 (void) fat_node_put(fn); 1394 async_answer_0(rid, rc); 1395 return; 1331 return rc; 1396 1332 } 1397 1333 /* … … 1403 1339 (void) fat_free_clusters(bs, devmap_handle, mcl); 1404 1340 (void) fat_node_put(fn); 1405 async_answer_0(rid, rc);1406 return;1407 }1408 nodep->size = size = pos + bytes;1341 return rc; 1342 } 1343 *nsize = nodep->size = pos + bytes; 1344 rc = fat_node_put(fn); 1409 1345 nodep->dirty = true; /* need to sync node */ 1410 rc = fat_node_put(fn); 1411 async_answer_2(rid, rc, bytes, size); 1412 return; 1413 } 1414 } 1415 1416 void fat_truncate(ipc_callid_t rid, ipc_call_t *request) 1417 { 1418 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 1419 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 1420 aoff64_t size = 1421 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request)); 1346 *wbytes = bytes; 1347 return rc; 1348 } 1349 } 1350 1351 static int 1352 fat_truncate(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t size) 1353 { 1422 1354 fs_node_t *fn; 1423 1355 fat_node_t *nodep; … … 1426 1358 1427 1359 rc = fat_node_get(&fn, devmap_handle, index); 1428 if (rc != EOK) { 1429 async_answer_0(rid, rc); 1430 return; 1431 } 1432 if (!fn) { 1433 async_answer_0(rid, ENOENT); 1434 return; 1435 } 1360 if (rc != EOK) 1361 return rc; 1362 if (!fn) 1363 return ENOENT; 1436 1364 nodep = FAT_NODE(fn); 1437 1365 … … 1477 1405 out: 1478 1406 fat_node_put(fn); 1479 async_answer_0(rid, rc); 1480 return; 1481 } 1482 1483 void fat_close(ipc_callid_t rid, ipc_call_t *request) 1484 { 1485 async_answer_0(rid, EOK); 1486 } 1487 1488 void fat_destroy(ipc_callid_t rid, ipc_call_t *request) 1489 { 1490 devmap_handle_t devmap_handle = (devmap_handle_t)IPC_GET_ARG1(*request); 1491 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); 1407 return rc; 1408 } 1409 1410 static int fat_close(devmap_handle_t devmap_handle, fs_index_t index) 1411 { 1412 return EOK; 1413 } 1414 1415 static int fat_destroy(devmap_handle_t devmap_handle, fs_index_t index) 1416 { 1492 1417 fs_node_t *fn; 1493 1418 fat_node_t *nodep; … … 1495 1420 1496 1421 rc = fat_node_get(&fn, devmap_handle, index); 1497 if (rc != EOK) { 1498 async_answer_0(rid, rc); 1499 return; 1500 } 1501 if (!fn) { 1502 async_answer_0(rid, ENOENT); 1503 return; 1504 } 1422 if (rc != EOK) 1423 return rc; 1424 if (!fn) 1425 return ENOENT; 1505 1426 1506 1427 nodep = FAT_NODE(fn); … … 1512 1433 1513 1434 rc = fat_destroy_node(fn); 1514 async_answer_0(rid, rc); 1515 } 1516 1517 void fat_open_node(ipc_callid_t rid, ipc_call_t *request) 1518 { 1519 libfs_open_node(&fat_libfs_ops, fat_reg.fs_handle, rid, request); 1520 } 1521 1522 void fat_stat(ipc_callid_t rid, ipc_call_t *request) 1523 { 1524 libfs_stat(&fat_libfs_ops, fat_reg.fs_handle, rid, request); 1525 } 1526 1527 void fat_sync(ipc_callid_t rid, ipc_call_t *request) 1528 { 1529 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 1530 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 1531 1435 return rc; 1436 } 1437 1438 static int fat_sync(devmap_handle_t devmap_handle, fs_index_t index) 1439 { 1532 1440 fs_node_t *fn; 1533 1441 int rc = fat_node_get(&fn, devmap_handle, index); 1534 if (rc != EOK) { 1535 async_answer_0(rid, rc); 1536 return; 1537 } 1538 if (!fn) { 1539 async_answer_0(rid, ENOENT); 1540 return; 1541 } 1442 if (rc != EOK) 1443 return rc; 1444 if (!fn) 1445 return ENOENT; 1542 1446 1543 1447 fat_node_t *nodep = FAT_NODE(fn); … … 1547 1451 1548 1452 fat_node_put(fn); 1549 async_answer_0(rid, rc); 1550 } 1453 return rc; 1454 } 1455 1456 vfs_out_ops_t fat_ops = { 1457 .mounted = fat_mounted, 1458 .unmounted = fat_unmounted, 1459 .read = fat_read, 1460 .write = fat_write, 1461 .truncate = fat_truncate, 1462 .close = fat_close, 1463 .destroy = fat_destroy, 1464 .sync = fat_sync, 1465 }; 1551 1466 1552 1467 /**
Note:
See TracChangeset
for help on using the changeset viewer.