Changeset e03a733 in mainline


Ignore:
Timestamp:
2011-03-06T22:30:26Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e2267e82
Parents:
ae1ae27
Message:

initialize V3 superblock and write it to disk

Location:
uspace
Files:
2 edited

Legend:

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

    rae1ae27 re03a733  
    215215                }
    216216                setup_superblock_v3(sb3, &opt);
     217                block_write_direct(handle, MFS_SUPERBLOCK, 1, sb3);
    217218                setup_bitmaps(handle, sb3->s_ninodes,
    218                                 sb3->s_total_zones, sb3->s_block_size);
     219                                sb3->s_nzones, sb3->s_block_size);
    219220        } else {
    220221                sb = (struct mfs_superblock *) malloc(sizeof(struct mfs_superblock));
     
    244245        } else {
    245246                fs_version = 2;
    246                 ino_per_block = V1_INODES_PER_BLOCK;
     247                ino_per_block = V2_INODES_PER_BLOCK;
    247248                if (opt->fs_longnames)
    248249                        opt->fs_magic = MFS_MAGIC_V2L;
     
    250251
    251252        sb->s_magic = opt->fs_magic;
     253
     254        /*Compute the number of zones on disk*/
    252255
    253256        /*Valid only for MFS V1*/
     
    259262                        UINT32_MAX : opt->dev_nblocks;
    260263
     264        /*Round up the number of inodes to fill block size*/
    261265        if (opt->n_inodes == 0)
    262266                tmp = opt->dev_nblocks / 3;             
     
    264268                tmp = opt->n_inodes;
    265269
    266         /*Round up the number of inodes to fill block size*/
    267270        if (tmp % ino_per_block)
    268271                tmp = ((tmp / ino_per_block) + 1) * ino_per_block;
     
    278281                sb->s_zbmap_blocks = UPPER(sb->s_nzones2, MFS_BLOCKSIZE * 8);
    279282
     283        /*Compute inode table size*/
     284        unsigned long ninodes_blocks = sb->s_ninodes / ino_per_block;
     285
    280286        /*Compute first data zone position*/
    281         unsigned long ninodes_blocks = sb->s_ninodes / (fs_version == 1 ?
    282                                                         V1_INODES_PER_BLOCK :
    283                                                         V2_INODES_PER_BLOCK);
    284287        sb->s_first_data_zone = 2 + ninodes_blocks +
    285288                                sb->s_zbmap_blocks + sb->s_ibmap_blocks;
     
    293296        printf(NAME ": inode table blocks = %ld\n", ninodes_blocks);
    294297        printf(NAME ": first data zone = %d\n", sb->s_first_data_zone);
     298        printf(NAME ": long fnames = %s\n", opt->fs_longnames ? "Yes" : "No");
    295299}
    296300
    297301static void setup_superblock_v3(struct mfs3_superblock *sb, mfs_params_t *opt)
    298302{
     303        int ino_per_block;
     304        int bs;
     305        aoff64_t tmp;
     306
     307        sb->s_magic = opt->fs_magic;
     308        bs = opt->block_size;
     309
     310        if (opt->n_inodes == 0)
     311                tmp = opt->dev_nblocks / 3;             
     312        else
     313                tmp = opt->n_inodes;
     314
     315        /*Compute the number of zones on disk*/
     316        sb->s_nzones = opt->dev_nblocks > UINT32_MAX ?
     317                        UINT32_MAX : opt->dev_nblocks;
     318        sb->s_nzones /= (bs / MFS_MIN_BLOCKSIZE);
     319
     320        /*Round up the number of inodes to fill block size*/
     321        ino_per_block = V3_INODES_PER_BLOCK(bs);
     322        if (tmp % ino_per_block)
     323                tmp = ((tmp / ino_per_block) + 1) * ino_per_block;
     324        sb->s_ninodes = tmp > UINT32_MAX ? UINT32_MAX : tmp;
     325
     326        /*Compute inode bitmap size in blocks*/
     327        sb->s_ibmap_blocks = UPPER(sb->s_ninodes, bs * 8);
     328
     329        /*Compute zone bitmap size in blocks*/
     330        sb->s_zbmap_blocks = UPPER(sb->s_nzones, bs * 8);
     331
     332        /*Compute inode table size*/
     333        unsigned long ninodes_blocks = sb->s_ninodes / ino_per_block;
     334
     335        /*Compute first data zone position*/
     336        sb->s_first_data_zone = 2 + ninodes_blocks +
     337                                sb->s_zbmap_blocks + sb->s_ibmap_blocks;
     338
     339        /*Set log2 of zone to block ratio to zero*/
     340        sb->s_log2_zone_size = 0;
     341        sb->s_disk_version = 3;
     342        sb->s_block_size = bs;
     343
     344        /*Superblock is now ready to be written on disk*/
     345        printf(NAME ": %d inodes\n", sb->s_ninodes);
     346        printf(NAME ": %d zones\n", sb->s_nzones);
     347        printf(NAME ": block size = %d\n", sb->s_block_size);
     348        printf(NAME ": inode table blocks = %ld\n", ninodes_blocks);
     349        printf(NAME ": first data zone = %d\n", sb->s_first_data_zone);
    299350}
    300351
  • uspace/lib/minix/minix.h

    rae1ae27 re03a733  
    119119        int32_t         s_max_file_size;
    120120        /*Total number of zones on the device*/
    121         uint32_t        s_total_zones;
     121        uint32_t        s_nzones;
    122122        /*
    123123         *Magic number used to recognize MinixFS
Note: See TracChangeset for help on using the changeset viewer.