source: mainline/uspace/app/mkminix/mkminix.c@ 245eb02d

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 245eb02d was 92dd5c8, checked in by Maurizio Lombardi <m.lombardi85@…>, 14 years ago

Read superblock and look for a corrispondent magic number, fix first data zone calculation in mkminix

  • Property mode set to 100644
File size: 16.6 KB
Line 
1/*
2 * Copyright (c) 2010 Jiri Svoboda
3 * Copyright (c) 2011 Maurizio Lombardi
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @addtogroup fs
31 * @{
32 */
33
34/**
35 * @file mkminix.c
36 * @brief Tool for creating new Minix file systems.
37 *
38 */
39
40#include <stdio.h>
41#include <stdlib.h>
42#include <libblock.h>
43#include <unistd.h>
44#include <errno.h>
45#include <sys/typefmt.h>
46#include <inttypes.h>
47#include <getopt.h>
48#include <mem.h>
49#include <str.h>
50#include <time.h>
51#include <minix.h>
52
53#define NAME "mkminix"
54
55#define FREE 0
56#define USED 1
57
58#define UPPER(n, size) (((n) / (size)) + (((n) % (size)) != 0))
59#define NEXT_DENTRY(p, dirsize) (p += dirsize)
60#define FIRST_ZONE(bs) (1 + (bs) / MFS_MIN_BLOCKSIZE)
61#define CONVERT_1K_OFF(off, bs) ((off) * ((bs) / MFS_MIN_BLOCKSIZE))
62
63typedef enum {
64 HELP_SHORT,
65 HELP_LONG
66} help_level_t;
67
68/*Generic MFS superblock*/
69struct mfs_sb_info {
70 uint64_t n_inodes;
71 uint64_t n_zones;
72 aoff64_t dev_nblocks;
73 unsigned long ibmap_blocks;
74 unsigned long zbmap_blocks;
75 unsigned long first_data_zone;
76 unsigned long itable_size;
77 int log2_zone_size;
78 int ino_per_block;
79 int dirsize;
80 uint32_t max_file_size;
81 uint16_t magic;
82 uint32_t block_size;
83 int fs_version;
84 bool longnames;
85};
86
87static void help_cmd_mkminix(help_level_t level);
88static int num_of_set_bits(uint32_t n);
89static int init_superblock(struct mfs_sb_info *sb);
90static int write_superblock(const struct mfs_sb_info *sbi);
91static int write_superblock3(const struct mfs_sb_info *sbi);
92static int init_bitmaps(const struct mfs_sb_info *sb);
93static int init_inode_table(const struct mfs_sb_info *sb);
94static int make_root_ino(const struct mfs_sb_info *sb);
95static int make_root_ino3(const struct mfs_sb_info *sb);
96static void mark_bmap(uint32_t *bmap, int idx, int v);
97static int insert_dentries(const struct mfs_sb_info *sb);
98
99static inline int write_1k_block(aoff64_t off, size_t size, const void *data);
100
101static devmap_handle_t handle;
102
103static struct option const long_options[] = {
104 { "help", no_argument, 0, 'h' },
105 { "long-names", no_argument, 0, 'l' },
106 { "block-size", required_argument, 0, 'b' },
107 { "inodes", required_argument, 0, 'i' },
108 { NULL, no_argument, 0, '1' },
109 { NULL, no_argument, 0, '2' },
110 { NULL, no_argument, 0, '3' },
111 { 0, 0, 0, 0 }
112};
113
114int main (int argc, char **argv)
115{
116 int rc, c, opt_ind;
117 char *device_name;
118 aoff64_t devblock_size;
119
120 struct mfs_sb_info sb;
121
122 /*Default is MinixFS V3*/
123 sb.magic = MFS_MAGIC_V3;
124 sb.fs_version = 3;
125
126 /*Default block size is 4Kb*/
127 sb.block_size = MFS_MAX_BLOCKSIZE;
128 sb.dirsize = MFS3_DIRSIZE;
129 sb.n_inodes = 0;
130 sb.longnames = false;
131 sb.ino_per_block = V3_INODES_PER_BLOCK(MFS_MAX_BLOCKSIZE);
132
133 if (argc == 1) {
134 help_cmd_mkminix(HELP_SHORT);
135 printf("Incorrect number of arguments, try `mkminix --help'\n");
136 exit(0);
137 }
138
139 for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
140 c = getopt_long(argc, argv, "lh123b:i:", long_options, &opt_ind);
141 switch (c) {
142 case 'h':
143 help_cmd_mkminix(HELP_LONG);
144 exit(0);
145 case '1':
146 sb.magic = MFS_MAGIC_V1;
147 sb.block_size = MFS_BLOCKSIZE;
148 sb.fs_version = 1;
149 sb.ino_per_block = V1_INODES_PER_BLOCK;
150 sb.dirsize = MFS_DIRSIZE;
151 break;
152 case '2':
153 sb.magic = MFS_MAGIC_V2;
154 sb.block_size = MFS_BLOCKSIZE;
155 sb.fs_version = 2;
156 sb.ino_per_block = V2_INODES_PER_BLOCK;
157 sb.dirsize = MFS_DIRSIZE;
158 break;
159 case '3':
160 sb.magic = MFS_MAGIC_V3;
161 sb.fs_version = 3;
162 sb.block_size = MFS_MAX_BLOCKSIZE;
163 sb.dirsize = MFS3_DIRSIZE;
164 break;
165 case 'b':
166 sb.block_size = (uint32_t) strtol(optarg, NULL, 10);
167 break;
168 case 'i':
169 sb.n_inodes = (uint64_t) strtol(optarg, NULL, 10);
170 break;
171 case 'l':
172 sb.longnames = true;
173 sb.dirsize = MFSL_DIRSIZE;
174 break;
175 }
176 }
177
178 if (sb.block_size < MFS_MIN_BLOCKSIZE ||
179 sb.block_size > MFS_MAX_BLOCKSIZE) {
180 printf(NAME ":Error! Invalid block size.\n");
181 exit(0);
182 } else if (num_of_set_bits(sb.block_size) != 1) {
183 /*Block size must be a power of 2.*/
184 printf(NAME ":Error! Invalid block size.\n");
185 exit(0);
186 } else if (sb.block_size > MFS_BLOCKSIZE &&
187 sb.fs_version != 3) {
188 printf(NAME ":Error! Block size > 1024 is supported by V3 filesystem only.\n");
189 exit(0);
190 } else if (sb.fs_version == 3 && sb.longnames) {
191 printf(NAME ":Error! Long filenames are supported by V1/V2 filesystem only.\n");
192 exit(0);
193 }
194
195 argv += optind;
196
197 device_name = argv[0];
198
199 if (!device_name) {
200 help_cmd_mkminix(HELP_LONG);
201 exit(0);
202 }
203
204 rc = devmap_device_get_handle(device_name, &handle, 0);
205 if (rc != EOK) {
206 printf(NAME ": Error resolving device `%s'.\n", device_name);
207 return 2;
208 }
209
210 rc = block_init(handle, MFS_MIN_BLOCKSIZE);
211 if (rc != EOK) {
212 printf(NAME ": Error initializing libblock.\n");
213 return 2;
214 }
215
216 rc = block_get_bsize(handle, &devblock_size);
217 if (rc != EOK) {
218 printf(NAME ": Error determining device block size.\n");
219 return 2;
220 }
221
222 rc = block_get_nblocks(handle, &sb.dev_nblocks);
223 if (rc != EOK) {
224 printf(NAME ": Warning, failed to obtain block device size.\n");
225 } else {
226 printf(NAME ": Block device has %" PRIuOFF64 " blocks.\n",
227 sb.dev_nblocks);
228 }
229
230 if (devblock_size != 512) {
231 printf(NAME ": Error. Device block size is not 512 bytes.\n");
232 return 2;
233 }
234
235 /*Minimum block size is 1 Kb*/
236 sb.dev_nblocks /= 2;
237
238 printf(NAME ": Creating Minix file system on device\n");
239
240 /*Initialize superblock*/
241 if (init_superblock(&sb) != EOK) {
242 printf(NAME ": Error. Superblock initialization failed\n");
243 return 2;
244 }
245
246 /*Initialize bitmaps*/
247 if (init_bitmaps(&sb) != EOK) {
248 printf(NAME ": Error. Bitmaps initialization failed\n");
249 return 2;
250 }
251
252 /*Init inode table*/
253 if (init_inode_table(&sb) != EOK) {
254 printf(NAME ": Error. Inode table initialization failed\n");
255 return 2;
256 }
257
258 /*Make the root inode*/
259 if (sb.fs_version == 3)
260 rc = make_root_ino3(&sb);
261 else
262 rc = make_root_ino(&sb);
263
264 if (rc != EOK) {
265 printf(NAME ": Error. Root inode initialization failed\n");
266 return 2;
267 }
268
269 /*Insert directory entries . and ..*/
270 if (insert_dentries(&sb) != EOK) {
271 printf(NAME ": Error. Root directory initialization failed\n");
272 return 2;
273 }
274
275 return 0;
276}
277
278static int insert_dentries(const struct mfs_sb_info *sb)
279{
280 void *root_block;
281 int rc;
282 const long root_dblock = CONVERT_1K_OFF(sb->first_data_zone, sb->block_size);
283
284 root_block = (void *) malloc(MFS_MIN_BLOCKSIZE);
285 memset(root_block, 0x00, MFS_MIN_BLOCKSIZE);
286
287 if (!root_block)
288 return ENOMEM;
289
290 if (sb->fs_version != 3) {
291 /*Directory entries for V1/V2 filesystem*/
292 struct mfs_dentry *dentry = root_block;
293
294 dentry->d_inum = MFS_ROOT_INO;
295 memcpy(dentry->d_name, ".\0", 2);
296
297 NEXT_DENTRY(dentry, sb->dirsize);
298
299 dentry->d_inum = MFS_ROOT_INO;
300 memcpy(dentry->d_name, "..\0", 3);
301 } else {
302 /*Directory entries for V3 filesystem*/
303 struct mfs3_dentry *dentry = root_block;
304
305 dentry->d_inum = MFS_ROOT_INO;
306 memcpy(dentry->d_name, ".\0", 2);
307
308 NEXT_DENTRY(dentry, sb->dirsize);
309
310 dentry->d_inum = MFS_ROOT_INO;
311 memcpy(dentry->d_name, "..\0", 3);
312 }
313
314 rc = write_1k_block(root_dblock, 1, root_block);
315
316 free(root_block);
317 return rc;
318}
319
320static int init_inode_table(const struct mfs_sb_info *sb)
321{
322 unsigned int i;
323 uint8_t *itable_buf;
324 int rc;
325 long itable_off;
326 unsigned long itable_size;
327
328 itable_off = sb->zbmap_blocks + sb->ibmap_blocks;
329
330 /*Convert to 1K offset*/
331 itable_off = CONVERT_1K_OFF(itable_off, sb->block_size) +
332 FIRST_ZONE(sb->block_size);
333 itable_size = CONVERT_1K_OFF(sb->itable_size, sb->block_size);
334
335 itable_buf = malloc(MFS_MIN_BLOCKSIZE);
336
337 if (!itable_buf)
338 return ENOMEM;
339
340 memset(itable_buf, 0x00, MFS_MIN_BLOCKSIZE);
341
342 for (i = 0; i < itable_size; ++i, ++itable_off) {
343 rc = write_1k_block(itable_off, 1, itable_buf);
344
345 if (rc != EOK)
346 break;
347 }
348
349 free(itable_buf);
350 return rc;
351}
352
353static int make_root_ino(const struct mfs_sb_info *sb)
354{
355 struct mfs_inode *ino_buf;
356 long itable_off;
357 int rc;
358
359 itable_off = FIRST_ZONE(MFS_BLOCKSIZE);
360 itable_off += sb->zbmap_blocks + sb->ibmap_blocks;
361
362 const time_t sec = time(NULL);
363
364 ino_buf = (struct mfs_inode *) malloc(MFS_BLOCKSIZE);
365
366 if (!ino_buf)
367 return ENOMEM;
368
369 memset(ino_buf, 0x00, MFS_BLOCKSIZE);
370
371 ino_buf[MFS_ROOT_INO].i_mode = S_IFDIR;
372 ino_buf[MFS_ROOT_INO].i_uid = 0;
373 ino_buf[MFS_ROOT_INO].i_gid = 0;
374 ino_buf[MFS_ROOT_INO].i_size = (sb->longnames ? MFSL_DIRSIZE : MFS_DIRSIZE) * 2;
375 ino_buf[MFS_ROOT_INO].i_mtime = sec;
376 ino_buf[MFS_ROOT_INO].i_nlinks = 2;
377 ino_buf[MFS_ROOT_INO].i_dzone[0] = sb->first_data_zone;
378
379 rc = write_1k_block(itable_off, 1, ino_buf);
380
381 free(ino_buf);
382 return rc;
383}
384
385static int make_root_ino3(const struct mfs_sb_info *sb)
386{
387 struct mfs2_inode *ino_buf;
388 long itable_off;
389 int rc;
390
391 /*Compute offset of the first inode table block*/
392 itable_off = sb->zbmap_blocks + sb->ibmap_blocks;
393
394 /*Convert to 1K block offset*/
395 itable_off = CONVERT_1K_OFF(itable_off, sb->block_size) +
396 FIRST_ZONE(sb->block_size);
397
398 const time_t sec = time(NULL);
399
400 ino_buf = (struct mfs2_inode *) malloc(MFS_MIN_BLOCKSIZE);
401
402 if (!ino_buf)
403 return ENOMEM;
404
405 memset(ino_buf, 0x00, MFS_MIN_BLOCKSIZE);
406
407 ino_buf[MFS_ROOT_INO].i_mode = S_IFDIR;
408 ino_buf[MFS_ROOT_INO].i_uid = 0;
409 ino_buf[MFS_ROOT_INO].i_gid = 0;
410 ino_buf[MFS_ROOT_INO].i_size = MFS3_DIRSIZE * 2;
411 ino_buf[MFS_ROOT_INO].i_mtime = sec;
412 ino_buf[MFS_ROOT_INO].i_atime = sec;
413 ino_buf[MFS_ROOT_INO].i_ctime = sec;
414 ino_buf[MFS_ROOT_INO].i_nlinks = 2;
415 ino_buf[MFS_ROOT_INO].i_dzone[0] = sb->first_data_zone;
416
417 rc = write_1k_block(itable_off, 1, ino_buf);
418
419 free(ino_buf);
420 return rc;
421}
422
423static int init_superblock(struct mfs_sb_info *sb)
424{
425 aoff64_t inodes;
426 int rc;
427
428 if (sb->longnames)
429 sb->magic = sb->fs_version == 1 ? MFS_MAGIC_V1L : MFS_MAGIC_V2L;
430
431 /*Compute the number of zones on disk*/
432
433 if (sb->fs_version == 1) {
434 /*Valid only for MFS V1*/
435 sb->n_zones = sb->dev_nblocks > UINT16_MAX ?
436 UINT16_MAX : sb->dev_nblocks;
437 } else {
438 /*Valid for MFS V2/V3*/
439 sb->n_zones = sb->dev_nblocks > UINT32_MAX ?
440 UINT32_MAX : sb->dev_nblocks;
441
442 if (sb->fs_version == 3) {
443 sb->ino_per_block = V3_INODES_PER_BLOCK(sb->block_size);
444 sb->n_zones /= (sb->block_size / MFS_MIN_BLOCKSIZE);
445 }
446 }
447
448 /*Round up the number of inodes to fill block size*/
449 if (sb->n_inodes == 0)
450 inodes = sb->dev_nblocks / 3;
451 else
452 inodes = sb->n_inodes;
453
454 if (inodes % sb->ino_per_block)
455 inodes = ((inodes / sb->ino_per_block) + 1) * sb->ino_per_block;
456
457 if (sb->fs_version < 3)
458 sb->n_inodes = inodes > UINT16_MAX ? UINT16_MAX : inodes;
459 else
460 sb->n_inodes = inodes > UINT32_MAX ? UINT32_MAX : inodes;
461
462 /*Compute inode bitmap size in blocks*/
463 sb->ibmap_blocks = UPPER(sb->n_inodes, sb->block_size * 8);
464
465 /*Compute inode table size*/
466 sb->itable_size = sb->n_inodes / sb->ino_per_block;
467
468 /*Compute zone bitmap size in blocks*/
469 sb->zbmap_blocks = UPPER(sb->n_zones, sb->block_size * 8);
470
471 /*Compute first data zone position*/
472 sb->first_data_zone = 2 + sb->itable_size +
473 sb->zbmap_blocks + sb->ibmap_blocks;
474
475 /*Set log2 of zone to block ratio to zero*/
476 sb->log2_zone_size = 0;
477
478 /*Check for errors*/
479 if (sb->first_data_zone >= sb->n_zones) {
480 printf(NAME ": Error! Insufficient disk space");
481 return ENOMEM;
482 }
483
484 /*Superblock is now ready to be written on disk*/
485 printf(NAME ": %d inodes\n", (uint32_t) sb->n_inodes);
486 printf(NAME ": %d zones\n", (uint32_t) sb->n_zones);
487 printf(NAME ": inode table blocks = %ld\n", sb->itable_size);
488 printf(NAME ": inode bitmap blocks = %ld\n", sb->ibmap_blocks);
489 printf(NAME ": zone bitmap blocks = %ld\n", sb->zbmap_blocks);
490 printf(NAME ": first data zone = %d\n", (uint32_t) sb->first_data_zone);
491 printf(NAME ": long fnames = %s\n", sb->longnames ? "Yes" : "No");
492
493 if (sb->fs_version == 3)
494 rc = write_superblock3(sb);
495 else
496 rc = write_superblock(sb);
497
498 return rc;
499}
500
501static int write_superblock(const struct mfs_sb_info *sbi)
502{
503 struct mfs_superblock *sb;
504 int rc;
505
506 sb = (struct mfs_superblock *) malloc(MFS_SUPERBLOCK_SIZE);;
507
508 if (!sb)
509 return ENOMEM;
510
511 sb->s_ninodes = (uint16_t) sbi->n_inodes;
512 sb->s_nzones = (uint16_t) sbi->n_zones;
513 sb->s_nzones2 = (uint32_t) sbi->n_zones;
514 sb->s_ibmap_blocks = (uint16_t) sbi->ibmap_blocks;
515 sb->s_zbmap_blocks = (uint16_t) sbi->zbmap_blocks;
516 sb->s_first_data_zone = (uint16_t) sbi->first_data_zone;
517 sb->s_log2_zone_size = sbi->log2_zone_size;
518 sb->s_max_file_size = UINT32_MAX;
519 sb->s_magic = sbi->magic;
520 sb->s_state = MFS_VALID_FS;
521
522 rc = write_1k_block(MFS_SUPERBLOCK, 1, sb);
523 free(sb);
524
525 return rc;
526}
527
528static int write_superblock3(const struct mfs_sb_info *sbi)
529{
530 struct mfs3_superblock *sb;
531 int rc;
532
533 sb = (struct mfs3_superblock *) malloc(MFS_SUPERBLOCK_SIZE);
534
535 if (!sb)
536 return ENOMEM;
537
538 sb->s_ninodes = (uint32_t) sbi->n_inodes;
539 sb->s_nzones = (uint32_t) sbi->n_zones;
540 sb->s_ibmap_blocks = (uint16_t) sbi->ibmap_blocks;
541 sb->s_zbmap_blocks = (uint16_t) sbi->zbmap_blocks;
542 sb->s_first_data_zone = (uint16_t) sbi->first_data_zone;
543 sb->s_log2_zone_size = sbi->log2_zone_size;
544 sb->s_max_file_size = UINT32_MAX;
545 sb->s_magic = sbi->magic;
546 sb->s_block_size = sbi->block_size;
547 sb->s_disk_version = 3;
548
549 rc = write_1k_block(MFS_SUPERBLOCK, 1, sb);
550 free(sb);
551
552 return rc;
553}
554
555static int init_bitmaps(const struct mfs_sb_info *sb)
556{
557 uint32_t *ibmap_buf, *zbmap_buf;
558 uint8_t *ibmap_buf8, *zbmap_buf8;
559 unsigned int ibmap_nblocks = sb->ibmap_blocks;
560 unsigned int zbmap_nblocks = sb->zbmap_blocks;
561 unsigned int i;
562 int rc;
563
564 ibmap_buf = (uint32_t *) malloc(ibmap_nblocks * sb->block_size);
565 zbmap_buf = (uint32_t *) malloc(zbmap_nblocks * sb->block_size);
566
567 if (!ibmap_buf || !zbmap_buf)
568 return ENOMEM;
569
570 memset(ibmap_buf, 0xFF, ibmap_nblocks * sb->block_size);
571 memset(zbmap_buf, 0xFF, zbmap_nblocks * sb->block_size);
572
573 for (i = 2; i < sb->n_inodes; ++i)
574 mark_bmap(ibmap_buf, i, FREE);
575
576 for (i = sb->first_data_zone + 1; i < sb->n_zones; ++i)
577 mark_bmap(zbmap_buf, i, FREE);
578
579 /*Convert to 1K block offsets*/
580 ibmap_nblocks = CONVERT_1K_OFF(ibmap_nblocks, sb->block_size);
581 zbmap_nblocks = CONVERT_1K_OFF(zbmap_nblocks, sb->block_size);
582
583 ibmap_buf8 = (uint8_t *) ibmap_buf;
584 zbmap_buf8 = (uint8_t *) zbmap_buf;
585
586 int start_block = FIRST_ZONE(sb->block_size);
587
588 for (i = 0; i < ibmap_nblocks; ++i) {
589 if ((rc = write_1k_block(start_block + i,
590 1, (ibmap_buf8 + i * MFS_BLOCKSIZE))) != EOK)
591 return rc;
592 }
593
594 start_block = FIRST_ZONE(sb->block_size) + ibmap_nblocks;
595
596 for (i = 0; i < zbmap_nblocks; ++i) {
597 if ((rc = write_1k_block(start_block + i,
598 1, (zbmap_buf8 + i * MFS_BLOCKSIZE))) != EOK)
599 return rc;
600 }
601
602 free(ibmap_buf);
603 free(zbmap_buf);
604
605 return rc;
606}
607
608static void mark_bmap(uint32_t *bmap, int idx, int v)
609{
610 if (v == FREE)
611 bmap[idx / 32] &= ~(1 << (idx % 32));
612 else
613 bmap[idx / 32] |= 1 << (idx % 32);
614}
615
616static inline int write_1k_block(aoff64_t off, size_t size, const void *data)
617{
618 return block_write_direct(handle, off * 2, size * 2, data);
619}
620
621static void help_cmd_mkminix(help_level_t level)
622{
623 if (level == HELP_SHORT) {
624 printf(NAME": tool to create new Minix file systems\n");
625 } else {
626 printf("Usage: [options] device\n"
627 "-1 Make a Minix version 1 filesystem\n"
628 "-2 Make a Minix version 2 filesystem\n"
629 "-3 Make a Minix version 3 filesystem\n"
630 "-b ## Specify the block size in bytes (V3 only),\n"
631 " valid block size values are 1024, 2048 and 4096 bytes per block\n"
632 "-i ## Specify the number of inodes for the filesystem\n"
633 "-l Use 30-char long filenames (V1/V2 only)\n");
634 }
635}
636
637static int num_of_set_bits(uint32_t n)
638{
639 n = n - ((n >> 1) & 0x55555555);
640 n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
641 return (((n + (n >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
642}
643
644
645/**
646 * @}
647 */
Note: See TracBrowser for help on using the repository browser.