Changeset 410a065 in mainline
- Timestamp:
- 2011-03-08T16:46:58Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8e41994
- Parents:
- 59e670e
- Location:
- uspace
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkminix/mkminix.c
r59e670e r410a065 72 72 unsigned long zbmap_blocks; 73 73 unsigned long first_data_zone; 74 unsigned long itable_size; 74 75 int log2_zone_size; 75 76 int ino_per_block; … … 87 88 static void write_superblock3(struct mfs_sb_info *sbi); 88 89 static void init_bitmaps(struct mfs_sb_info *sb); 90 static void init_inode_table(struct mfs_sb_info *sb); 91 static void make_root_ino(struct mfs_sb_info *sb); 92 static void make_root_ino3(struct mfs_sb_info *sb); 89 93 static void mark_bmap(uint32_t *bmap, int idx, int v); 90 94 … … 225 229 init_bitmaps(&sb); 226 230 231 /*Init inode table*/ 232 init_inode_table(&sb); 233 227 234 return 0; 235 } 236 237 static void init_inode_table(struct mfs_sb_info *sb) 238 { 239 unsigned int i; 240 uint8_t *itable_buf; 241 long itable_pos = 2 + sb->zbmap_blocks + sb->ibmap_blocks; 242 243 itable_buf = malloc(sb->block_size); 244 memset(itable_buf, 0x00, sb->block_size); 245 246 const int chunks = sb->block_size / MFS_BLOCKSIZE; 247 248 for (i = 0; i < sb->itable_size; ++i, ++itable_pos) 249 block_write_direct(sb->handle, itable_pos, chunks, itable_buf); 250 251 free(itable_buf); 252 253 /*Make the root inode*/ 254 if (sb->fs_version != 3) 255 make_root_ino(sb); 256 else 257 make_root_ino3(sb); 258 } 259 260 static void make_root_ino(struct mfs_sb_info *sb) 261 { 262 struct mfs_inode *ino_buf; 263 const size_t bufsize = MFS_BLOCKSIZE; 264 const long itable_pos = 2 + sb->zbmap_blocks + sb->ibmap_blocks; 265 266 ino_buf = (struct mfs_inode *) malloc(bufsize); 267 memset(ino_buf, 0x00, bufsize); 268 269 ino_buf[MFS_ROOT_INO].i_mode = S_IFDIR; 270 ino_buf[MFS_ROOT_INO].i_uid = 0; 271 ino_buf[MFS_ROOT_INO].i_gid = 0; 272 ino_buf[MFS_ROOT_INO].i_size = (sb->longnames ? MFSL_DIRSIZE : MFS_DIRSIZE) * 2; 273 ino_buf[MFS_ROOT_INO].i_mtime = 0; 274 ino_buf[MFS_ROOT_INO].i_nlinks = 2; 275 ino_buf[MFS_ROOT_INO].i_dzone[0] = sb->first_data_zone; 276 277 block_write_direct(sb->handle, itable_pos, 1, ino_buf); 278 279 free(ino_buf); 280 } 281 282 static void make_root_ino3(struct mfs_sb_info *sb) 283 { 284 struct mfs2_inode *ino_buf; 285 const size_t bufsize = MFS_MIN_BLOCKSIZE; 286 const long itable_pos = 2 + sb->zbmap_blocks + sb->ibmap_blocks; 287 288 ino_buf = (struct mfs2_inode *) malloc(bufsize); 289 memset(ino_buf, 0x00, bufsize); 290 291 ino_buf[MFS_ROOT_INO].i_mode = S_IFDIR; 292 ino_buf[MFS_ROOT_INO].i_uid = 0; 293 ino_buf[MFS_ROOT_INO].i_gid = 0; 294 ino_buf[MFS_ROOT_INO].i_size = MFS3_DIRSIZE * 2; 295 ino_buf[MFS_ROOT_INO].i_mtime = 0; 296 ino_buf[MFS_ROOT_INO].i_atime = 0; 297 ino_buf[MFS_ROOT_INO].i_ctime = 0; 298 ino_buf[MFS_ROOT_INO].i_nlinks = 2; 299 ino_buf[MFS_ROOT_INO].i_dzone[0] = sb->first_data_zone; 300 301 block_write_direct(sb->handle, itable_pos * (sb->block_size / MFS_MIN_BLOCKSIZE), 1, ino_buf); 302 303 free(ino_buf); 228 304 } 229 305 … … 271 347 272 348 /*Compute inode table size*/ 273 unsigned long ninodes_blocks= sb->n_inodes / sb->ino_per_block;349 sb->itable_size = sb->n_inodes / sb->ino_per_block; 274 350 275 351 /*Compute first data zone position*/ 276 sb->first_data_zone = 2 + ninodes_blocks+352 sb->first_data_zone = 2 + sb->itable_size + 277 353 sb->zbmap_blocks + sb->ibmap_blocks; 278 354 … … 283 359 printf(NAME ": %d inodes\n", (uint32_t) sb->n_inodes); 284 360 printf(NAME ": %d zones\n", (uint32_t) sb->n_zones); 285 printf(NAME ": inode table blocks = %ld\n", ninodes_blocks); 361 printf(NAME ": inode table blocks = %ld\n", sb->itable_size); 362 printf(NAME ": inode bitmap blocks = %ld\n", sb->ibmap_blocks); 363 printf(NAME ": zone bitmap blocks = %ld\n", sb->zbmap_blocks); 286 364 printf(NAME ": first data zone = %d\n", (uint32_t) sb->first_data_zone); 287 365 printf(NAME ": long fnames = %s\n", sb->longnames ? "Yes" : "No"); … … 320 398 { 321 399 struct mfs3_superblock *sb; 322 uint8_t *superblock_buf; 323 324 superblock_buf = malloc(1024); 325 326 sb = (struct mfs3_superblock *) superblock_buf; 400 401 sb = (struct mfs3_superblock *) malloc(MFS_SUPERBLOCK_SIZE); 327 402 328 403 sb->s_ninodes = (uint32_t) sbi->n_inodes; … … 338 413 339 414 block_write_direct(sbi->handle, MFS_SUPERBLOCK, 1, sb); 340 free(s uperblock_buf);415 free(sb); 341 416 } 342 417 -
uspace/lib/minix/minix.h
r59e670e r410a065 37 37 38 38 #define MFS_BLOCKSIZE 1024 39 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 40 #define S_IFDIR 0040000 41 #define S_IFMT 00170000 39 42 40 43 /*The following block sizes are valid only on V3 filesystem*/ … … 55 58 #define V2_INODES_PER_BLOCK (MFS_BLOCKSIZE / sizeof(struct mfs2_inode)) 56 59 #define V3_INODES_PER_BLOCK(bs) ((bs) / sizeof(struct mfs2_inode)) 60 61 #define MFS_DIRSIZE 16 62 #define MFSL_DIRSIZE 32 63 #define MFS3_DIRSIZE 64 57 64 58 65 #define MFS_MAX_NAME_LEN 14
Note:
See TracChangeset
for help on using the changeset viewer.