Changeset eef306c in mainline


Ignore:
Timestamp:
2011-03-09T16:16:27Z (13 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
868ef40
Parents:
e2abab03
Message:

Check filesystem feature flags when mounting

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext2/libext2_filesystem.c

    re2abab03 reef306c  
    109109
    110110/**
     111 * Check feature flags
     112 *
     113 * @param fs Pointer to ext2_filesystem_t to check
     114 * @param read_only bool to set to true if the fs needs to be read-only
     115 * @return EOK on success or negative error code on failure
     116 */
     117int ext2_filesystem_check_flags(ext2_filesystem_t *fs, bool *o_read_only)
     118{
     119        // feature flags are present in rev 1 and later
     120        if (ext2_superblock_get_rev_major(fs->superblock) == 0) {
     121                *o_read_only = false;
     122                return 0;
     123        }
     124       
     125        uint32_t incompatible;
     126        uint32_t read_only;
     127       
     128        incompatible = ext2_superblock_get_features_incompatible(fs->superblock);
     129        read_only = ext2_superblock_get_features_read_only(fs->superblock);
     130       
     131        // unset any supported features
     132        incompatible &= ~EXT2_SUPPORTED_INCOMPATIBLE_FEATURES;
     133        read_only &= ~EXT2_SUPPORTED_READ_ONLY_FEATURES;
     134       
     135        if (incompatible > 0) {
     136                *o_read_only = true;
     137                return ENOTSUP;
     138        }
     139       
     140        if (read_only > 0) {
     141                *o_read_only = true;
     142        }
     143       
     144        return EOK;
     145}
     146
     147/**
    111148 * Get a reference to block descriptor
    112149 *
  • uspace/lib/ext2/libext2_filesystem.h

    re2abab03 reef306c  
    5252#define EXT2_REV0_INODE_SIZE            128
    5353
     54#define EXT2_FEATURE_RO_SPARSE_SUPERBLOCK       1
     55#define EXT2_FEATURE_RO_LARGE_FILE                      2
     56#define EXT2_FEATURE_I_TYPE_IN_DIR                      2
     57
     58#define EXT2_SUPPORTED_INCOMPATIBLE_FEATURES EXT2_FEATURE_I_TYPE_IN_DIR
     59#define EXT2_SUPPORTED_READ_ONLY_FEATURES 0
     60
    5461extern int ext2_filesystem_init(ext2_filesystem_t *, devmap_handle_t);
    5562extern int ext2_filesystem_check_sanity(ext2_filesystem_t *);
     63extern int ext2_filesystem_check_flags(ext2_filesystem_t *, bool *);
    5664extern int ext2_filesystem_get_block_group_ref(ext2_filesystem_t *, uint32_t,
    5765    ext2_block_group_ref_t **);
  • uspace/lib/ext2/libext2_superblock.c

    re2abab03 reef306c  
    258258
    259259/**
     260 * Get compatible features flags
     261 *
     262 * @param sb pointer to superblock
     263 */
     264inline uint32_t ext2_superblock_get_features_compatible(ext2_superblock_t *sb)
     265{
     266        return uint32_t_le2host(sb->features_compatible);
     267}
     268
     269/**
     270 * Get incompatible features flags
     271 *
     272 * @param sb pointer to superblock
     273 */
     274inline uint32_t ext2_superblock_get_features_incompatible(ext2_superblock_t *sb)
     275{
     276        return uint32_t_le2host(sb->features_incompatible);
     277}
     278
     279/**
     280 * Get read-only compatible features flags
     281 *
     282 * @param sb pointer to superblock
     283 */
     284inline uint32_t ext2_superblock_get_features_read_only(ext2_superblock_t *sb)
     285{
     286        return uint32_t_le2host(sb->features_read_only);
     287}
     288
     289/**
    260290 * Compute count of block groups present in the filesystem
    261291 *
  • uspace/lib/ext2/libext2_superblock.h

    re2abab03 reef306c  
    6464        uint32_t        first_inode;
    6565        uint16_t        inode_size;
    66         uint8_t         unused5[14];
     66        uint16_t        unused5;
     67        uint32_t        features_compatible;
     68        uint32_t        features_incompatible;
     69        uint32_t        features_read_only;
    6770        uint8_t         uuid[16]; // UUID TODO: Create a library for UUIDs
    6871        uint8_t         volume_name[16];
     
    103106inline uint32_t ext2_superblock_get_block_group_count(ext2_superblock_t *);
    104107inline uint32_t ext2_superblock_get_inodes_per_group(ext2_superblock_t *);
     108inline uint32_t ext2_superblock_get_features_compatible(ext2_superblock_t *);
     109inline uint32_t ext2_superblock_get_features_incompatible(ext2_superblock_t *);
     110inline uint32_t ext2_superblock_get_features_read_only(ext2_superblock_t *);
    105111
    106112extern int ext2_superblock_read_direct(devmap_handle_t, ext2_superblock_t **);
  • uspace/srv/fs/ext2fs/ext2fs_ops.c

    re2abab03 reef306c  
    484484        ext2_filesystem_t *fs;
    485485        ext2fs_instance_t *inst;
     486        bool read_only;
    486487       
    487488        /* Accept the mount options */
     
    522523        /* Do some sanity checking */
    523524        rc = ext2_filesystem_check_sanity(fs);
     525        if (rc != EOK) {
     526                ext2_filesystem_fini(fs);
     527                free(fs);
     528                free(inst);
     529                async_answer_0(rid, rc);
     530                return;
     531        }
     532       
     533        /* Check flags */
     534        rc = ext2_filesystem_check_flags(fs, &read_only);
    524535        if (rc != EOK) {
    525536                ext2_filesystem_fini(fs);
Note: See TracChangeset for help on using the changeset viewer.