Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 2175178 in mainline


Ignore:
Timestamp:
2018-10-03T08:34:52Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
b209135
Parents:
174156fd
git-author:
Jiri Svoboda <jiri@…> (2018-10-02 21:31:25)
git-committer:
Jiri Svoboda <jiri@…> (2018-10-03 08:34:52)
Message:

Allow creating ext2 dynamic revision. Allow choosing ext filesystem version by mkext4 argument. Fix support for filesystems without filetype feature.

Location:
uspace
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/mkext4/mkext4.c

    r174156fd r2175178  
    4545
    4646static void syntax_print(void);
     47static errno_t ext4_version_parse(const char *, ext4_cfg_ver_t *);
    4748
    4849int main(int argc, char **argv)
     
    5152        char *dev_path;
    5253        service_id_t service_id;
     54        ext4_cfg_ver_t ver;
    5355        char *endptr;
    5456        aoff64_t nblocks;
    5557        char *label;
     58
     59        ver = ext4_def_fs_version;
    5660
    5761        if (argc < 2) {
     
    7680                        nblocks = strtol(*argv, &endptr, 10);
    7781                        if (*endptr != '\0') {
     82                                printf(NAME ": Error, invalid argument.\n");
     83                                syntax_print();
     84                                return 1;
     85                        }
     86
     87                        --argc;
     88                        ++argv;
     89                }
     90
     91                if (str_cmp(*argv, "--type") == 0) {
     92                        --argc;
     93                        ++argv;
     94                        if (*argv == NULL) {
     95                                printf(NAME ": Error, argument missing.\n");
     96                                syntax_print();
     97                                return 1;
     98                        }
     99
     100                        rc = ext4_version_parse(*argv, &ver);
     101                        if (rc != EOK) {
    78102                                printf(NAME ": Error, invalid argument.\n");
    79103                                syntax_print();
     
    125149        (void) nblocks;
    126150
    127         rc = ext4_filesystem_create(service_id);
     151        rc = ext4_filesystem_create(ver, service_id);
    128152        if (rc != EOK) {
    129153                printf(NAME ": Error initializing file system.\n");
     
    141165        printf("options:\n"
    142166            "\t--size <sectors> Filesystem size, overrides device size\n"
    143             "\t--label <label>  Volume label\n");
     167            "\t--label <label>  Volume label\n"
     168            "\t--type <fstype>  Filesystem type (ext2, ext2old)\n");
     169}
     170
     171static errno_t ext4_version_parse(const char *str, ext4_cfg_ver_t *ver)
     172{
     173        if (str_cmp(str, "ext2old") == 0) {
     174                *ver = extver_ext2_old;
     175                return EOK;
     176        }
     177
     178        if (str_cmp(str, "ext2") == 0) {
     179                *ver = extver_ext2;
     180                return EOK;
     181        }
     182
     183        return EINVAL;
    144184}
    145185
  • uspace/lib/ext4/include/ext4/filesystem.h

    r174156fd r2175178  
    3737
    3838#include <block.h>
     39#include "ext4/cfg.h"
    3940#include "ext4/fstypes.h"
    4041#include "ext4/types.h"
    4142
    4243extern errno_t ext4_filesystem_probe(service_id_t);
    43 extern errno_t ext4_filesystem_create(service_id_t);
     44extern errno_t ext4_filesystem_create(ext4_cfg_ver_t, service_id_t);
    4445extern errno_t ext4_filesystem_open(ext4_instance_t *, service_id_t,
    4546    enum cache_mode, aoff64_t *, ext4_filesystem_t **);
  • uspace/lib/ext4/include/ext4/superblock.h

    r174156fd r2175178  
    3939#include <stdint.h>
    4040#include <uuid.h>
     41#include "ext4/cfg.h"
    4142#include "ext4/types.h"
    4243
     
    164165extern uint32_t ext4_superblock_get_inodes_in_group(ext4_superblock_t *,
    165166    uint32_t);
    166 extern errno_t ext4_superblock_create(size_t, uint64_t, ext4_superblock_t **);
     167extern errno_t ext4_superblock_create(size_t, uint64_t, ext4_cfg_ver_t,
     168    ext4_superblock_t **);
    167169extern uint32_t ext4_superblock_get_group_backup_blocks(ext4_superblock_t *,
    168170    uint32_t);
  • uspace/lib/ext4/src/directory.c

    r174156fd r2175178  
    369369
    370370        /* Set type of entry */
    371         if (ext4_inode_is_type(sb, child->inode, EXT4_INODE_MODE_DIRECTORY))
     371        if (!ext4_superblock_has_feature_incompatible(sb, EXT4_FEATURE_INCOMPAT_FILETYPE))
     372                ext4_directory_entry_ll_set_inode_type(sb, entry,
     373                    EXT4_DIRECTORY_FILETYPE_UNKNOWN);
     374        else if (ext4_inode_is_type(sb, child->inode, EXT4_INODE_MODE_DIRECTORY))
    372375                ext4_directory_entry_ll_set_inode_type(sb, entry,
    373376                    EXT4_DIRECTORY_FILETYPE_DIR);
  • uspace/lib/ext4/src/filesystem.c

    r174156fd r2175178  
    4848#include "ext4/bitmap.h"
    4949#include "ext4/block_group.h"
     50#include "ext4/cfg.h"
    5051#include "ext4/directory.h"
    5152#include "ext4/extent.h"
     
    248249/** Create new filesystem.
    249250 *
     251 * @param ver Filesystem version
    250252 * @param service_id Block device where to create new filesystem
    251253 */
    252 errno_t ext4_filesystem_create(service_id_t service_id)
     254errno_t ext4_filesystem_create(ext4_cfg_ver_t ver, service_id_t service_id)
    253255{
    254256        errno_t rc;
     
    280282
    281283        /* Create superblock */
    282         rc = ext4_superblock_create(dev_bsize, dev_nblocks, &superblock);
     284        rc = ext4_superblock_create(dev_bsize, dev_nblocks, ver, &superblock);
    283285        if (rc != EOK)
    284286                goto err;
  • uspace/lib/ext4/src/superblock.c

    r174156fd r2175178  
    4545#include <stdlib.h>
    4646#include <time.h>
     47#include "ext4/cfg.h"
    4748#include "ext4/superblock.h"
    4849
     
    14541455 * @param dev_bsize Device block size
    14551456 * @param dev_bcnt Device number of blocks
     1457 * @param ver Filesystem version
    14561458 * @param rsb Place to store pointer to newly allocated superblock
    14571459 * @return EOK on success or error code
    14581460 */
    14591461errno_t ext4_superblock_create(size_t dev_bsize, uint64_t dev_bcnt,
    1460     ext4_superblock_t **rsb)
     1462    ext4_cfg_ver_t ver, ext4_superblock_t **rsb)
    14611463{
    14621464        ext4_superblock_t *sb;
     
    15571559        ext4_superblock_set_check_interval(sb, 0);
    15581560        ext4_superblock_set_creator_os(sb, EXT4_SUPERBLOCK_OS_LINUX);
    1559         ext4_superblock_set_rev_level(sb, EXT4_GOOD_OLD_REV);
     1561        if (ver >= extver_ext2)
     1562                ext4_superblock_set_rev_level(sb, EXT4_DYNAMIC_REV);
     1563        else
     1564                ext4_superblock_set_rev_level(sb, EXT4_GOOD_OLD_REV);
    15601565        ext4_superblock_set_def_resuid(sb, 0);
    15611566        ext4_superblock_set_def_resgid(sb, 0);
     1567
     1568        if (ver >= extver_ext2) {
     1569                /* Dynamic rev */
     1570                ext4_superblock_set_first_inode(sb, EXT4_REV0_FIRST_INO);
     1571                ext4_superblock_set_inode_size(sb, EXT4_REV0_INODE_SIZE);
     1572                ext4_superblock_set_block_group_index(sb, 0); // XXX
     1573                ext4_superblock_set_features_compatible(sb, 0);
     1574                ext4_superblock_set_features_incompatible(sb, 0);
     1575                ext4_superblock_set_features_read_only(sb, 0);
     1576
     1577                ext4_superblock_set_uuid(sb, &uuid);
     1578                /* 16-byte Latin-1 string padded with null characters */
     1579                ext4_superblock_set_volume_name(sb, "HelenOS-Ext4\0\0\0\0");
     1580                /* 64-byte Latin-1 string padded with null characters */
     1581                ext4_superblock_set_last_mounted(sb,
     1582                    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
     1583                    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
     1584                sb->algorithm_usage_bitmap = 0;
     1585        }
    15621586#if 0
    1563         /* Dynamic rev */
    1564         ext4_superblock_set_first_inode(sb, EXT4_REV0_FIRST_INO);
    1565         ext4_superblock_set_inode_size(sb, EXT4_REV0_INODE_SIZE);
    1566         ext4_superblock_set_block_group_index(sb, 0); // XXX
    1567         ext4_superblock_set_features_compatible(sb, 0);
    1568         ext4_superblock_set_features_incompatible(sb, 0);
    1569         ext4_superblock_set_features_read_only(sb, 0);
    1570 
    1571         ext4_superblock_set_uuid(sb, &uuid);
    1572         /* 16-byte Latin-1 string padded with null characters */
    1573         ext4_superblock_set_volume_name(sb, "HelenOS-Ext4\0\0\0\0");
    1574         /* 64-byte Latin-1 string padded with null characters */
    1575         ext4_superblock_set_last_mounted(sb,
    1576             "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
    1577             "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
    1578         sb->algorithm_usage_bitmap = 0;
    1579 
    15801587        /* Journalling */
    15811588        ext4_superblock_set_desc_size(sb, EXT4_MAX_BLOCK_GROUP_DESCRIPTOR_SIZE);
Note: See TracChangeset for help on using the changeset viewer.