Changeset fd282ad in mainline


Ignore:
Timestamp:
2011-03-08T18:10:20Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c64506b
Parents:
3c616f6
Message:

Insert directory entries . and .. in root dir

File:
1 edited

Legend:

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

    r3c616f6 rfd282ad  
    4848#include <getopt.h>
    4949#include <mem.h>
     50#include <str.h>
    5051#include <minix.h>
    5152
     
    5657
    5758#define UPPER(n, size) (((n) / (size)) + (((n) % (size)) != 0))
     59#define NEXT_DENTRY(p, dirsize) (p += dirsize)
    5860
    5961typedef enum {
     
    7577        int log2_zone_size;
    7678        int ino_per_block;
     79        int dirsize;
    7780        uint32_t max_file_size;
    7881        uint16_t magic;
     
    9295static void     make_root_ino3(struct mfs_sb_info *sb);
    9396static void     mark_bmap(uint32_t *bmap, int idx, int v);
     97static void     insert_dentries(struct mfs_sb_info *sb);
    9498
    9599static struct option const long_options[] = {
     
    137141                        sb.fs_version = 1;
    138142                        sb.ino_per_block = V1_INODES_PER_BLOCK;
     143                        sb.dirsize = MFS_DIRSIZE;
    139144                        break;
    140145                case '2':
     
    143148                        sb.fs_version = 2;
    144149                        sb.ino_per_block = V2_INODES_PER_BLOCK;
     150                        sb.dirsize = MFS_DIRSIZE;
    145151                        break;
    146152                case '3':
     
    148154                        sb.fs_version = 3;
    149155                        sb.block_size = MFS_MAX_BLOCKSIZE;
     156                        sb.dirsize = MFS3_DIRSIZE;
    150157                        break;
    151158                case 'b':
     
    157164                case 'l':
    158165                        sb.longnames = true;
     166                        sb.dirsize = MFSL_DIRSIZE;
    159167                        break;
    160168                }
     
    232240        init_inode_table(&sb);
    233241
     242        /*Insert directory entries . and ..*/
     243        insert_dentries(&sb);
     244
    234245        return 0;
     246}
     247
     248static void insert_dentries(struct mfs_sb_info *sb)
     249{
     250        void *root_block;
     251        const long root_dblock = sb->first_data_zone * (sb->block_size / MFS_MIN_BLOCKSIZE);
     252
     253        root_block = (void *) malloc(MFS_MIN_BLOCKSIZE);
     254       
     255        if (sb->fs_version != 3) {
     256                /*Directories entry for V1/V2 filesystem*/
     257                struct mfs_dentry *dentry = root_block;
     258
     259                dentry->d_inum = MFS_ROOT_INO;
     260                str_cpy(dentry->d_name, 1, ".");
     261
     262                NEXT_DENTRY(dentry, sb->dirsize);
     263
     264                dentry->d_inum = MFS_ROOT_INO;
     265                str_cpy(dentry->d_name, 2, "..");
     266        } else {
     267                /*Directories entry for V1/V2 filesystem*/
     268                struct mfs3_dentry *dentry = root_block;
     269
     270                dentry->d_inum = MFS_ROOT_INO;
     271                str_cpy(dentry->d_name, 1, ".");
     272
     273                NEXT_DENTRY(dentry, sb->dirsize);
     274
     275                dentry->d_inum = MFS_ROOT_INO;
     276                str_cpy(dentry->d_name, 2, "..");
     277        }
     278
     279        block_write_direct(sb->handle, root_dblock, 1, root_block);
     280
     281        free(root_block);
    235282}
    236283
Note: See TracChangeset for help on using the changeset viewer.