Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat_ops.c

    r2ffaab5 rdfddfcd  
    5252#include <adt/list.h>
    5353#include <assert.h>
    54 #include <fibril_synch.h>
     54#include <fibril_sync.h>
    5555#include <sys/mman.h>
    5656#include <align.h>
     
    7171static int fat_match(fs_node_t **, fs_node_t *, const char *);
    7272static int fat_node_get(fs_node_t **, dev_handle_t, fs_index_t);
    73 static int fat_node_open(fs_node_t *);
    7473static int fat_node_put(fs_node_t *);
    7574static int fat_create_node(fs_node_t **, dev_handle_t, int);
     
    8483static bool fat_is_directory(fs_node_t *);
    8584static bool fat_is_file(fs_node_t *node);
    86 static dev_handle_t fat_device_get(fs_node_t *node);
    8785
    8886/*
     
    290288
    291289        *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 media
    298  * descriptor. This is used to rule out cases when a device obviously
    299  * 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 are
    345                  * set to one.
    346                  */
    347                 if ((e0 >> 8) != 0xff || e1 != 0xffff)
    348                         return ENOTSUP;
    349         }
    350 
    351290        return EOK;
    352291}
     
    468407}
    469408
    470 int fat_node_open(fs_node_t *fn)
    471 {
    472         /*
    473          * Opening a file is stateless, nothing
    474          * to be done here.
    475          */
    476         return EOK;
    477 }
    478 
    479409int fat_node_put(fs_node_t *fn)
    480410{
     
    937867}
    938868
    939 dev_handle_t fat_device_get(fs_node_t *node)
    940 {
    941         return 0;
    942 }
    943 
    944869/** libfs operations */
    945870libfs_ops_t fat_libfs_ops = {
     
    947872        .match = fat_match,
    948873        .node_get = fat_node_get,
    949         .node_open = fat_node_open,
    950874        .node_put = fat_node_put,
    951875        .create = fat_create_node,
     
    957881        .size_get = fat_size_get,
    958882        .lnkcnt_get = fat_lnkcnt_get,
    959         .plb_get_char = fat_plb_get_char,
     883        .plb_get_char = fat_plb_get_char,
    960884        .is_directory = fat_is_directory,
    961         .is_file = fat_is_file,
    962         .device_get = fat_device_get
     885        .is_file = fat_is_file
    963886};
    964887
     
    1034957        /* Initialize the block cache */
    1035958        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);
    1044959        if (rc != EOK) {
    1045960                block_fini(dev_handle);
Note: See TracChangeset for help on using the changeset viewer.