Changeset 340b5690 in mainline


Ignore:
Timestamp:
2011-03-09T20:26:46Z (14 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bb0db564
Parents:
7df022e5
Message:

Fix inode table initialization

Location:
uspace
Files:
2 edited

Legend:

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

    r7df022e5 r340b5690  
    5959#define UPPER(n, size) (((n) / (size)) + (((n) % (size)) != 0))
    6060#define NEXT_DENTRY(p, dirsize) (p += dirsize)
     61#define FIRST_ZONE(bs)          ((MFS_BOOTBLOCK_SIZE + MFS_SUPERBLOCK_SIZE) / (bs))
    6162
    6263typedef enum {
     
    317318        uint8_t *itable_buf;
    318319        int rc;
    319         long itable_pos = 2 + sb->zbmap_blocks + sb->ibmap_blocks;
     320        long itable_off;
     321
     322        itable_off = FIRST_ZONE(sb->block_size);
     323        itable_off += sb->zbmap_blocks + sb->ibmap_blocks;
     324
     325        /*Convert to 1K offset*/
     326        itable_off *= sb->block_size / MFS_MIN_BLOCKSIZE;
    320327
    321328        itable_buf = malloc(sb->block_size);
     
    326333        memset(itable_buf, 0x00, sb->block_size);
    327334
    328         const int chunks = sb->block_size / MFS_BLOCKSIZE;
    329 
    330         for (i = 0; i < sb->itable_size; ++i, itable_pos += chunks) {
    331                 rc = block_write_direct(sb->handle, itable_pos, chunks, itable_buf);
     335        for (i = 0; i < sb->itable_size * (sb->block_size / MFS_MIN_BLOCKSIZE); ++i, ++itable_off) {
     336                rc = block_write_direct(sb->handle, itable_off, 1, itable_buf);
    332337
    333338                if (rc != EOK)
     
    342347{
    343348        struct mfs_inode *ino_buf;
    344         const long itable_pos = 2 + sb->zbmap_blocks + sb->ibmap_blocks;
    345         int rc;
     349        long itable_off;
     350        int rc;
     351
     352        itable_off = FIRST_ZONE(MFS_BLOCKSIZE);
     353        itable_off += sb->zbmap_blocks + sb->ibmap_blocks;
    346354
    347355        const time_t sec = time(NULL);
     
    362370        ino_buf[MFS_ROOT_INO].i_dzone[0] = sb->first_data_zone;
    363371
    364         rc = block_write_direct(sb->handle, itable_pos, 1, ino_buf);
     372        rc = block_write_direct(sb->handle, itable_off, 1, ino_buf);
    365373
    366374        free(ino_buf);
     
    371379{
    372380        struct mfs2_inode *ino_buf;
    373         const size_t bufsize = MFS_MIN_BLOCKSIZE;
    374         const long itable_pos = 2 + sb->zbmap_blocks + sb->ibmap_blocks;
    375         int rc;
     381        long itable_off;
     382        int rc;
     383
     384        itable_off = FIRST_ZONE(sb->block_size);
     385        itable_off += sb->zbmap_blocks + sb->ibmap_blocks;
     386
     387        /*Convert to 1K block offset*/
     388        itable_off *= sb->block_size / MFS_MIN_BLOCKSIZE;
    376389
    377390        const time_t sec = time(NULL);
    378391
    379         ino_buf = (struct mfs2_inode *) malloc(bufsize);
     392        ino_buf = (struct mfs2_inode *) malloc(MFS_MIN_BLOCKSIZE);
    380393
    381394        if (!ino_buf)
    382395                return ENOMEM;
    383396
    384         memset(ino_buf, 0x00, bufsize);
     397        memset(ino_buf, 0x00, MFS_MIN_BLOCKSIZE);
    385398
    386399        ino_buf[MFS_ROOT_INO].i_mode = S_IFDIR;
     
    394407        ino_buf[MFS_ROOT_INO].i_dzone[0] = sb->first_data_zone;
    395408
    396         rc = block_write_direct(sb->handle, itable_pos * (sb->block_size / MFS_MIN_BLOCKSIZE), 1, ino_buf);
     409        rc = block_write_direct(sb->handle, itable_off, 1, ino_buf);
    397410
    398411        free(ino_buf);
     
    442455        sb->ibmap_blocks = UPPER(sb->n_inodes, sb->block_size * 8);
    443456
     457        /*Compute inode table size*/
     458        sb->itable_size = sb->n_inodes / sb->ino_per_block;
     459
    444460        /*Compute zone bitmap size in blocks*/
    445461        sb->zbmap_blocks = UPPER(sb->n_zones, sb->block_size * 8);
    446462
    447         /*Compute inode table size*/
    448         sb->itable_size = sb->n_inodes / sb->ino_per_block;
    449 
    450463        /*Compute first data zone position*/
    451         sb->first_data_zone = 2 + sb->itable_size +
     464        sb->first_data_zone = FIRST_ZONE(sb->block_size) + sb->itable_size +
    452465                                sb->zbmap_blocks + sb->ibmap_blocks;
    453466
  • uspace/lib/minix/minix.h

    r7df022e5 r340b5690  
    4848#define MFS_SUPERBLOCK          1
    4949#define MFS_SUPERBLOCK_SIZE     1024
     50#define MFS_BOOTBLOCK_SIZE      1024
    5051
    5152#define V2_NR_DIRECT_ZONES      7
Note: See TracChangeset for help on using the changeset viewer.