Changeset d2c8533 in mainline for uspace/srv/fs


Ignore:
Timestamp:
2017-05-08T20:38:47Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f066a87
Parents:
582a0b8
Message:

File system probing groundwork. Only MFS can do it for now.

Location:
uspace/srv/fs
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/cdfs/cdfs_ops.c

    r582a0b8 rd2c8533  
    10211021}
    10221022
     1023static int cdfs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info)
     1024{
     1025        return ENOTSUP;
     1026}
     1027
    10231028static int cdfs_mounted(service_id_t service_id, const char *opts,
    10241029    fs_index_t *index, aoff64_t *size, unsigned int *lnkcnt)
     
    12971302
    12981303vfs_out_ops_t cdfs_ops = {
     1304        .fsprobe = cdfs_fsprobe,
    12991305        .mounted = cdfs_mounted,
    13001306        .unmounted = cdfs_unmounted,
  • uspace/srv/fs/exfat/exfat_ops.c

    r582a0b8 rd2c8533  
    10501050}
    10511051*/
    1052  
     1052
     1053static int exfat_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info)
     1054{
     1055        return ENOTSUP;
     1056}
     1057
    10531058static int
    10541059exfat_mounted(service_id_t service_id, const char *opts, fs_index_t *index,
     
    15711576
    15721577vfs_out_ops_t exfat_ops = {
     1578        .fsprobe = exfat_fsprobe,
    15731579        .mounted = exfat_mounted,
    15741580        .unmounted = exfat_unmounted,
  • uspace/srv/fs/ext4fs/ext4fs_ops.c

    r582a0b8 rd2c8533  
    915915 * VFS operations.
    916916 */
     917
     918/** Probe operation.
     919 *
     920 * Try to get information about specified filesystem from device.
     921 *
     922 * @param sevice_id Service ID
     923 * @param info Place to store information
     924 *
     925 * @return Error code
     926 */
     927static int ext4fs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info)
     928{
     929        return ENOTSUP;
     930}
    917931
    918932/** Mount operation.
     
    15201534 */
    15211535vfs_out_ops_t ext4fs_ops = {
     1536        .fsprobe = ext4fs_fsprobe,
    15221537        .mounted = ext4fs_mounted,
    15231538        .unmounted = ext4fs_unmounted,
  • uspace/srv/fs/fat/fat_ops.c

    r582a0b8 rd2c8533  
    912912 * FAT VFS_OUT operations.
    913913 */
     914
     915static int fat_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info)
     916{
     917        return ENOTSUP;
     918}
    914919
    915920static int
     
    15081513
    15091514vfs_out_ops_t fat_ops = {
     1515        .fsprobe = fat_fsprobe,
    15101516        .mounted = fat_mounted,
    15111517        .unmounted = fat_unmounted,
  • uspace/srv/fs/locfs/locfs_ops.c

    r582a0b8 rd2c8533  
    455455}
    456456
     457static int locfs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info)
     458{
     459        return ENOTSUP;
     460}
     461
    457462static int locfs_mounted(service_id_t service_id, const char *opts,
    458463    fs_index_t *index, aoff64_t *size, unsigned *lnkcnt)
     
    763768
    764769vfs_out_ops_t locfs_ops = {
     770        .fsprobe = locfs_fsprobe,
    765771        .mounted = locfs_mounted,
    766772        .unmounted = locfs_unmounted,
  • uspace/srv/fs/mfs/mfs_ops.c

    r582a0b8 rd2c8533  
    140140}
    141141
    142 static int
    143 mfs_mounted(service_id_t service_id, const char *opts, fs_index_t *index,
    144     aoff64_t *size, unsigned *linkcnt)
    145 {
    146         enum cache_mode cmode;
     142/** Read the superblock.
     143 */
     144static int mfs_read_sb(service_id_t service_id, struct mfs_sb_info **rsbi)
     145{
    147146        struct mfs_superblock *sb = NULL;
    148147        struct mfs3_superblock *sb3 = NULL;
    149         struct mfs_sb_info *sbi = NULL;
    150         struct mfs_instance *instance = NULL;
     148        struct mfs_sb_info *sbi;
     149        size_t bsize;
    151150        bool native, longnames;
    152151        mfs_version_t version;
    153152        uint16_t magic;
    154153        int rc;
    155 
    156         /* Check for option enabling write through. */
    157         if (str_cmp(opts, "wtcache") == 0)
    158                 cmode = CACHE_MODE_WT;
    159         else
    160                 cmode = CACHE_MODE_WB;
    161 
    162         /* initialize libblock */
    163         rc = block_init(service_id, 4096);
    164         if (rc != EOK)
    165                 return rc;
    166154
    167155        /* Allocate space for generic MFS superblock */
     
    172160        }
    173161
    174         /* Allocate space for filesystem instance */
    175         instance = malloc(sizeof(*instance));
    176         if (!instance) {
    177                 rc = ENOMEM;
    178                 goto out_error;
    179         }
    180 
    181162        sb = malloc(MFS_SUPERBLOCK_SIZE);
    182163        if (!sb) {
    183164                rc = ENOMEM;
     165                goto out_error;
     166        }
     167
     168        rc = block_get_bsize(service_id, &bsize);
     169        if (rc != EOK) {
     170                rc = EIO;
     171                goto out_error;
     172        }
     173
     174        /* We don't support other block size than 512 */
     175        if (bsize != 512) {
     176                rc = ENOTSUP;
    184177                goto out_error;
    185178        }
     
    269262        }
    270263
     264        mfsdebug("read superblock successful\n");
     265
     266        free(sb);
     267        *rsbi = sbi;
     268        return EOK;
     269
     270out_error:
     271        if (sb)
     272                free(sb);
     273        if (sbi)
     274                free(sbi);
     275        return rc;
     276}
     277
     278
     279static int mfs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info)
     280{
     281        struct mfs_sb_info *sbi = NULL;
     282        int rc;
     283
     284        /* Initialize libblock */
     285        rc = block_init(service_id, 4096);
     286        if (rc != EOK)
     287                return rc;
     288
     289        /* Read the superblock */
     290        rc = mfs_read_sb(service_id, &sbi);
     291        block_fini(service_id);
     292
     293        return rc;
     294}
     295
     296static int
     297mfs_mounted(service_id_t service_id, const char *opts, fs_index_t *index,
     298    aoff64_t *size, unsigned *linkcnt)
     299{
     300        enum cache_mode cmode;
     301        struct mfs_sb_info *sbi = NULL;
     302        struct mfs_instance *instance = NULL;
     303        int rc;
     304
     305        /* Check for option enabling write through. */
     306        if (str_cmp(opts, "wtcache") == 0)
     307                cmode = CACHE_MODE_WT;
     308        else
     309                cmode = CACHE_MODE_WB;
     310
     311        /* Initialize libblock */
     312        rc = block_init(service_id, 4096);
     313        if (rc != EOK)
     314                return rc;
     315
     316        /* Allocate space for filesystem instance */
     317        instance = malloc(sizeof(*instance));
     318        if (!instance) {
     319                rc = ENOMEM;
     320                goto out_error;
     321        }
     322
     323        /* Read the superblock */
     324        rc = mfs_read_sb(service_id, &sbi);
     325        if (rc != EOK)
     326                goto out_error;
     327
    271328        rc = block_cache_init(service_id, sbi->block_size, 0, cmode);
    272329        if (rc != EOK) {
     
    298355        *linkcnt = 1;
    299356
    300         free(sb);
    301 
    302357        return mfs_node_put(fn);
    303358
    304359out_error:
    305360        block_fini(service_id);
    306         if (sb)
    307                 free(sb);
    308361        if (sbi)
    309362                free(sbi);
     
    12051258
    12061259vfs_out_ops_t mfs_ops = {
     1260        .fsprobe = mfs_fsprobe,
    12071261        .mounted = mfs_mounted,
    12081262        .unmounted = mfs_unmounted,
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    r582a0b8 rd2c8533  
    421421 */
    422422
     423static int tmpfs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info)
     424{
     425        return ENOTSUP;
     426}
     427
    423428static int
    424429tmpfs_mounted(service_id_t service_id, const char *opts,
     
    652657
    653658vfs_out_ops_t tmpfs_ops = {
     659        .fsprobe = tmpfs_fsprobe,
    654660        .mounted = tmpfs_mounted,
    655661        .unmounted = tmpfs_unmounted,
  • uspace/srv/fs/udf/udf_ops.c

    r582a0b8 rd2c8533  
    299299};
    300300
     301static int udf_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info)
     302{
     303        return ENOTSUP;
     304}
     305
    301306static int udf_mounted(service_id_t service_id, const char *opts,
    302307    fs_index_t *index, aoff64_t *size, unsigned *linkcnt)
     
    547552
    548553vfs_out_ops_t udf_ops = {
     554        .fsprobe = udf_fsprobe,
    549555        .mounted = udf_mounted,
    550556        .unmounted = udf_unmounted,
Note: See TracChangeset for help on using the changeset viewer.