Changeset eee8007 in mainline


Ignore:
Timestamp:
2011-03-05T09:49:33Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
55c51c28
Parents:
1ffbbc1
Message:

Add support to long filenames, improve mkminix

Location:
uspace
Files:
1 added
4 edited

Legend:

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

    r1ffbbc1 reee8007  
    5959} help_level_t;
    6060
    61 static void help_cmd_mkminix(help_level_t level);
    62 static int num_of_set_bits(uint32_t n);
     61static void     help_cmd_mkminix(help_level_t level);
     62static int      num_of_set_bits(uint32_t n);
     63static void     prepare_superblock(struct mfs_superblock *sb);
     64static void     prepare_superblock_v3(struct mfs3_superblock *sb);
    6365
    6466static struct option const long_options[] = {
    6567        { "help", no_argument, 0, 'h' },
     68        { "long-names", no_argument, 0, 'l' },
    6669        { "blocks", required_argument, 0, 'b' },
    6770        { "inodes", required_argument, 0, 'i' },
     
    7275};
    7376
     77typedef struct mfs_params {
     78        mfs_version_t fs_version;
     79        uint32_t block_size;
     80        size_t devblock_size;
     81        unsigned long n_inodes;
     82        aoff64_t dev_nblocks;
     83        bool fs_longnames;
     84} mfs_params_t;
     85
    7486int main (int argc, char **argv)
    7587{
     
    7789        char *device_name;
    7890        devmap_handle_t handle;
    79         aoff64_t dev_nblocks;
    80 
    81         /*Default is MinixFS version 3*/
    82         mfs_version_t fs_version = MFS_VERSION_V3;
    83 
    84         /*Default block size is 4096 bytes*/
    85         uint32_t block_size = MFS_MAX_BLOCK_SIZE;
    86         size_t devblock_size;
    87         unsigned long n_inodes = 0;
     91       
     92        struct mfs_superblock *sp;
     93        struct mfs3_superblock *sp3;
     94
     95        mfs_params_t opt;
     96
     97        /*Default is MinixFS V3*/
     98        opt.fs_version = MFS_VERSION_V3;
     99
     100        /*Default block size is 4Kb*/
     101        opt.block_size = 4096;
     102        opt.n_inodes = 0;
     103        opt.fs_longnames = false;
    88104
    89105        if (argc == 1) {
     
    94110
    95111        for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
    96                 c = getopt_long(argc, argv, "h123b:i:", long_options, &opt_ind);
     112                c = getopt_long(argc, argv, "eh123b:i:", long_options, &opt_ind);
    97113                switch (c) {
    98114                case 'h':
     
    100116                        exit(0);
    101117                case '1':
    102                         fs_version = MFS_VERSION_V1;
    103                         block_size = MFS_MIN_BLOCK_SIZE;
     118                        opt.fs_version = MFS_VERSION_V1;
     119                        opt.block_size = MFS_MIN_BLOCK_SIZE;
    104120                        break;
    105121                case '2':
    106                         fs_version = MFS_VERSION_V2;
    107                         block_size = MFS_MIN_BLOCK_SIZE;
     122                        opt.fs_version = MFS_VERSION_V2;
     123                        opt.block_size = MFS_MIN_BLOCK_SIZE;
    108124                        break;
    109125                case '3':
    110                         fs_version = MFS_VERSION_V3;
     126                        opt.fs_version = MFS_VERSION_V3;
    111127                        break;
    112128                case 'b':
    113                         block_size = (uint32_t) strtol(optarg, NULL, 10);
     129                        opt.block_size = (uint32_t) strtol(optarg, NULL, 10);
    114130                        break;
    115131                case 'i':
    116                         n_inodes = (unsigned long) strtol(optarg, NULL, 10);
     132                        opt.n_inodes = (unsigned long) strtol(optarg, NULL, 10);
     133                        break;
     134                case 'l':
     135                        opt.fs_longnames = true;
    117136                        break;
    118137                }
    119138        }
    120139
    121         if (block_size < MFS_MIN_BLOCK_SIZE || block_size > MFS_MAX_BLOCK_SIZE) {
     140        if (opt.block_size < MFS_MIN_BLOCK_SIZE ||
     141                                opt.block_size > MFS_MAX_BLOCK_SIZE) {
    122142                printf(NAME ":Error! Invalid block size.\n");
    123143                exit(0);
    124         } else if (num_of_set_bits(block_size) != 1) {
     144        } else if (num_of_set_bits(opt.block_size) != 1) {
    125145                /*Block size must be a power of 2.*/
    126146                printf(NAME ":Error! Invalid block size.\n");
    127147                exit(0);
    128         } else if (block_size > MFS_MIN_BLOCK_SIZE &&
    129                         fs_version != MFS_VERSION_V3) {
    130                 printf(NAME ":Error! Block size > 1024 is supported from V3 filesystem only.\n");
     148        } else if (opt.block_size > MFS_MIN_BLOCK_SIZE &&
     149                        opt.fs_version != MFS_VERSION_V3) {
     150                printf(NAME ":Error! Block size > 1024 is supported by V3 filesystem only.\n");
     151                exit(0);
     152        } else if (opt.fs_version == MFS_VERSION_V3 && opt.fs_longnames) {
     153                printf(NAME ":Error! Long filenames are supported by V1/V2 filesystem only.\n");
    131154                exit(0);
    132155        }
     
    153176        }
    154177
    155         rc = block_get_bsize(handle, &devblock_size);
     178        rc = block_get_bsize(handle, &opt.devblock_size);
    156179        if (rc != EOK) {
    157180                printf(NAME ": Error determining device block size.\n");
     
    159182        }
    160183
    161         rc = block_get_nblocks(handle, &dev_nblocks);
     184        rc = block_get_nblocks(handle, &opt.dev_nblocks);
    162185        if (rc != EOK) {
    163186                printf(NAME ": Warning, failed to obtain block device size.\n");
    164187        } else {
    165188                printf(NAME ": Block device has %" PRIuOFF64 " blocks.\n",
    166                     dev_nblocks);
    167         }
    168 
    169         if (devblock_size != 512) {
     189                    opt.dev_nblocks);
     190        }
     191
     192        if (opt.devblock_size != 512) {
    170193                printf(NAME ": Error. Device block size is not 512 bytes.\n");
    171194                return 2;
     
    176199        /*Prepare superblock*/
    177200
     201        if (opt.fs_version == MFS_VERSION_V3) {
     202                prepare_superblock_v3(sp3);
     203        } else {
     204                prepare_superblock(sp);
     205        }
     206
    178207        return 0;
     208}
     209
     210static void prepare_superblock(struct mfs_superblock *sp)
     211{
     212}
     213
     214static void prepare_superblock_v3(struct mfs3_superblock *sp)
     215{
    179216}
    180217
     
    190227                "-b ##      Specify the block size in bytes (V3 only),\n"
    191228                "           valid block size values are 1024, 2048 and 4096 bytes per block\n"
    192                 "-i ##      Specify the number of inodes for the filesystem\n");
     229                "-i ##      Specify the number of inodes for the filesystem\n"
     230                "-l         Use 30-char long filenames (V1/V2 only)");
    193231        }
    194232}
  • uspace/srv/fs/minixfs/mfs_const.h

    r1ffbbc1 reee8007  
    5353#define V1_MAX_NAME_LEN         14
    5454#define V2_MAX_NAME_LEN         14
     55#define V2E_MAX_NAME_LEN        30
    5556#define V3_MAX_NAME_LEN         60
    5657
  • uspace/srv/fs/minixfs/mfs_dentry.h

    r1ffbbc1 reee8007  
    3737
    3838#define mfs_v2_dentry   mfs_v1_dentry
     39#define mfs_v1l_dentry  mfs_v2l_dentry
    3940
    4041/*MinixFS V1 directory entry on-disk structure*/
     
    4243        uint16_t d_inum;
    4344        char d_name[V1_MAX_NAME_LEN];
     45} __attribute__ ((packed));
     46
     47/*MinixFS V2 with 30-char filenames (Linux variant)*/
     48struct mfs_v2l_dentry {
     49        uint16_t d_inum;
     50        char d_name[V2E_MAX_NAME_LEN];
    4451} __attribute__ ((packed));
    4552
  • uspace/srv/fs/minixfs/mfs_super.h

    r1ffbbc1 reee8007  
    3939#define MFS_MAGIC_V1R           0x7F13
    4040
     41#define MFS_MAGIC_V1L           0x138F
     42#define MFS_MAGIC_V1LR          0x8F13
     43
    4144#define MFS_MAGIC_V2            0x2468
    4245#define MFS_MAGIC_V2R           0x6824
     46
     47#define MFS_MAGIC_V2L           0x2478
     48#define MFS_MAGIC_V2LR          0x7824
    4349
    4450#define MFS_MAGIC_V3            0x4D5A
     
    104110typedef enum {
    105111        MFS_VERSION_V1 = 1,
     112        MFS_VERSION_V1L,
    106113        MFS_VERSION_V2,
     114        MFS_VERSION_V2L,
    107115        MFS_VERSION_V3
    108116} mfs_version_t;
Note: See TracChangeset for help on using the changeset viewer.