Changes in uspace/srv/fs/fat/fat_ops.c [2ffaab5:dfddfcd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_ops.c
r2ffaab5 rdfddfcd 52 52 #include <adt/list.h> 53 53 #include <assert.h> 54 #include <fibril_sync h.h>54 #include <fibril_sync.h> 55 55 #include <sys/mman.h> 56 56 #include <align.h> … … 71 71 static int fat_match(fs_node_t **, fs_node_t *, const char *); 72 72 static int fat_node_get(fs_node_t **, dev_handle_t, fs_index_t); 73 static int fat_node_open(fs_node_t *);74 73 static int fat_node_put(fs_node_t *); 75 74 static int fat_create_node(fs_node_t **, dev_handle_t, int); … … 84 83 static bool fat_is_directory(fs_node_t *); 85 84 static bool fat_is_file(fs_node_t *node); 86 static dev_handle_t fat_device_get(fs_node_t *node);87 85 88 86 /* … … 290 288 291 289 *nodepp = nodep; 292 return EOK;293 }294 295 /** Perform basic sanity checks on the file system.296 *297 * Verify if values of boot sector fields are sane. Also verify media298 * descriptor. This is used to rule out cases when a device obviously299 * does not contain a fat file system.300 */301 static int fat_sanity_check(fat_bs_t *bs, dev_handle_t dev_handle)302 {303 fat_cluster_t e0, e1;304 unsigned fat_no;305 int rc;306 307 /* Check number of FATs. */308 if (bs->fatcnt == 0)309 return ENOTSUP;310 311 /* Check total number of sectors. */312 313 if (bs->totsec16 == 0 && bs->totsec32 == 0)314 return ENOTSUP;315 316 if (bs->totsec16 != 0 && bs->totsec32 != 0 &&317 bs->totsec16 != bs->totsec32)318 return ENOTSUP;319 320 /* Check media descriptor. Must be between 0xf0 and 0xff. */321 if ((bs->mdesc & 0xf0) != 0xf0)322 return ENOTSUP;323 324 /* Check number of sectors per FAT. */325 if (bs->sec_per_fat == 0)326 return ENOTSUP;327 328 /* Check signature of each FAT. */329 330 for (fat_no = 0; fat_no < bs->fatcnt; fat_no++) {331 rc = fat_get_cluster(bs, dev_handle, fat_no, 0, &e0);332 if (rc != EOK)333 return EIO;334 335 rc = fat_get_cluster(bs, dev_handle, fat_no, 1, &e1);336 if (rc != EOK)337 return EIO;338 339 /* Check that first byte of FAT contains the media descriptor. */340 if ((e0 & 0xff) != bs->mdesc)341 return ENOTSUP;342 343 /*344 * Check that remaining bits of the first two entries are345 * set to one.346 */347 if ((e0 >> 8) != 0xff || e1 != 0xffff)348 return ENOTSUP;349 }350 351 290 return EOK; 352 291 } … … 468 407 } 469 408 470 int fat_node_open(fs_node_t *fn)471 {472 /*473 * Opening a file is stateless, nothing474 * to be done here.475 */476 return EOK;477 }478 479 409 int fat_node_put(fs_node_t *fn) 480 410 { … … 937 867 } 938 868 939 dev_handle_t fat_device_get(fs_node_t *node)940 {941 return 0;942 }943 944 869 /** libfs operations */ 945 870 libfs_ops_t fat_libfs_ops = { … … 947 872 .match = fat_match, 948 873 .node_get = fat_node_get, 949 .node_open = fat_node_open,950 874 .node_put = fat_node_put, 951 875 .create = fat_create_node, … … 957 881 .size_get = fat_size_get, 958 882 .lnkcnt_get = fat_lnkcnt_get, 959 .plb_get_char = 883 .plb_get_char = fat_plb_get_char, 960 884 .is_directory = fat_is_directory, 961 .is_file = fat_is_file, 962 .device_get = fat_device_get 885 .is_file = fat_is_file 963 886 }; 964 887 … … 1034 957 /* Initialize the block cache */ 1035 958 rc = block_cache_init(dev_handle, bps, 0 /* XXX */, cmode); 1036 if (rc != EOK) {1037 block_fini(dev_handle);1038 ipc_answer_0(rid, rc);1039 return;1040 }1041 1042 /* Do some simple sanity checks on the file system. */1043 rc = fat_sanity_check(bs, dev_handle);1044 959 if (rc != EOK) { 1045 960 block_fini(dev_handle);
Note:
See TracChangeset
for help on using the changeset viewer.