source: mainline/uspace/app/mkminix/mkminix.c@ ccbc5b56

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

Fix directory entries initialization, mkminix is now ready to be used.

  • Property mode set to 100644
File size: 16.5 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) ((MFS_BOOTBLOCK_SIZE + MFS_SUPERBLOCK_SIZE) / (bs))
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) + 2;
332 itable_size = CONVERT_1K_OFF(sb->itable_size, sb->block_size);
333
334 itable_buf = malloc(MFS_MIN_BLOCKSIZE);
335
336 if (!itable_buf)
337 return ENOMEM;
338
339 memset(itable_buf, 0x00, MFS_MIN_BLOCKSIZE);
340
341 for (i = 0; i < itable_size; ++i, ++itable_off) {
342 rc = write_1k_block(itable_off, 1, itable_buf);
343
344 if (rc != EOK)
345 break;
346 }
347
348 free(itable_buf);
349 return rc;
350}
351
352static int make_root_ino(const struct mfs_sb_info *sb)
353{
354 struct mfs_inode *ino_buf;
355 long itable_off;
356 int rc;
357
358 itable_off = FIRST_ZONE(MFS_BLOCKSIZE);
359 itable_off += sb->zbmap_blocks + sb->ibmap_blocks;
360
361 const time_t sec = time(NULL);
362
363 ino_buf = (struct mfs_inode *) malloc(MFS_BLOCKSIZE);
364
365 if (!ino_buf)
366 return ENOMEM;
367
368 memset(ino_buf, 0x00, MFS_BLOCKSIZE);
369
370 ino_buf[MFS_ROOT_INO].i_mode = S_IFDIR;
371 ino_buf[MFS_ROOT_INO].i_uid = 0;
372 ino_buf[MFS_ROOT_INO].i_gid = 0;
373 ino_buf[MFS_ROOT_INO].i_size = (sb->longnames ? MFSL_DIRSIZE : MFS_DIRSIZE) * 2;
374 ino_buf[MFS_ROOT_INO].i_mtime = sec;
375 ino_buf[MFS_ROOT_INO].i_nlinks = 2;
376 ino_buf[MFS_ROOT_INO].i_dzone[0] = sb->first_data_zone;
377
378 rc = write_1k_block(itable_off, 1, ino_buf);
379
380 free(ino_buf);
381 return rc;
382}
383
384static int make_root_ino3(const struct mfs_sb_info *sb)
385{
386 struct mfs2_inode *ino_buf;
387 long itable_off;
388 int rc;
389
390 /*Compute offset of the first inode table block*/
391 itable_off = sb->zbmap_blocks + sb->ibmap_blocks;
392
393 /*Convert to 1K block offset*/
394 itable_off = CONVERT_1K_OFF(itable_off, sb->block_size) + 2;
395
396 const time_t sec = time(NULL);
397
398 ino_buf = (struct mfs2_inode *) malloc(MFS_MIN_BLOCKSIZE);
399
400 if (!ino_buf)
401 return ENOMEM;
402
403 memset(ino_buf, 0x00, MFS_MIN_BLOCKSIZE);
404
405 ino_buf[MFS_ROOT_INO].i_mode = S_IFDIR;
406 ino_buf[MFS_ROOT_INO].i_uid = 0;
407 ino_buf[MFS_ROOT_INO].i_gid = 0;
408 ino_buf[MFS_ROOT_INO].i_size = MFS3_DIRSIZE * 2;
409 ino_buf[MFS_ROOT_INO].i_mtime = sec;
410 ino_buf[MFS_ROOT_INO].i_atime = sec;
411 ino_buf[MFS_ROOT_INO].i_ctime = sec;
412 ino_buf[MFS_ROOT_INO].i_nlinks = 2;
413 ino_buf[MFS_ROOT_INO].i_dzone[0] = sb->first_data_zone;
414
415 rc = write_1k_block(itable_off, 1, ino_buf);
416
417 free(ino_buf);
418 return rc;
419}
420
421static int init_superblock(struct mfs_sb_info *sb)
422{
423 aoff64_t inodes;
424 int rc;
425
426 if (sb->longnames)
427 sb->magic = sb->fs_version == 1 ? MFS_MAGIC_V1L : MFS_MAGIC_V2L;
428
429 /*Compute the number of zones on disk*/
430
431 if (sb->fs_version == 1) {
432 /*Valid only for MFS V1*/
433 sb->n_zones = sb->dev_nblocks > UINT16_MAX ?
434 UINT16_MAX : sb->dev_nblocks;
435 } else {
436 /*Valid for MFS V2/V3*/
437 sb->n_zones = sb->dev_nblocks > UINT32_MAX ?
438 UINT32_MAX : sb->dev_nblocks;
439
440 if (sb->fs_version == 3) {
441 sb->ino_per_block = V3_INODES_PER_BLOCK(sb->block_size);
442 sb->n_zones /= (sb->block_size / MFS_MIN_BLOCKSIZE);
443 }
444 }
445
446 /*Round up the number of inodes to fill block size*/
447 if (sb->n_inodes == 0)
448 inodes = sb->dev_nblocks / 3;
449 else
450 inodes = sb->n_inodes;
451
452 if (inodes % sb->ino_per_block)
453 inodes = ((inodes / sb->ino_per_block) + 1) * sb->ino_per_block;
454
455 if (sb->fs_version < 3)
456 sb->n_inodes = inodes > UINT16_MAX ? UINT16_MAX : inodes;
457 else
458 sb->n_inodes = inodes > UINT32_MAX ? UINT32_MAX : inodes;
459
460 /*Compute inode bitmap size in blocks*/
461 sb->ibmap_blocks = UPPER(sb->n_inodes, sb->block_size * 8);
462
463 /*Compute inode table size*/
464 sb->itable_size = sb->n_inodes / sb->ino_per_block;
465
466 /*Compute zone bitmap size in blocks*/
467 sb->zbmap_blocks = UPPER(sb->n_zones, sb->block_size * 8);
468
469 /*Compute first data zone position*/
470 sb->first_data_zone = FIRST_ZONE(sb->block_size) + sb->itable_size +
471 sb->zbmap_blocks + sb->ibmap_blocks;
472
473 /*Set log2 of zone to block ratio to zero*/
474 sb->log2_zone_size = 0;
475
476 /*Check for errors*/
477 if (sb->first_data_zone >= sb->n_zones) {
478 printf(NAME ": Error! Insufficient disk space");
479 return ENOMEM;
480 }
481
482 /*Superblock is now ready to be written on disk*/
483 printf(NAME ": %d inodes\n", (uint32_t) sb->n_inodes);
484 printf(NAME ": %d zones\n", (uint32_t) sb->n_zones);
485 printf(NAME ": inode table blocks = %ld\n", sb->itable_size);
486 printf(NAME ": inode bitmap blocks = %ld\n", sb->ibmap_blocks);
487 printf(NAME ": zone bitmap blocks = %ld\n", sb->zbmap_blocks);
488 printf(NAME ": first data zone = %d\n", (uint32_t) sb->first_data_zone);
489 printf(NAME ": long fnames = %s\n", sb->longnames ? "Yes" : "No");
490
491 if (sb->fs_version == 3)
492 rc = write_superblock3(sb);
493 else
494 rc = write_superblock(sb);
495
496 return rc;
497}
498
499static int write_superblock(const struct mfs_sb_info *sbi)
500{
501 struct mfs_superblock *sb;
502 int rc;
503
504 sb = (struct mfs_superblock *) malloc(MFS_SUPERBLOCK_SIZE);;
505
506 if (!sb)
507 return ENOMEM;
508
509 sb->s_ninodes = (uint16_t) sbi->n_inodes;
510 sb->s_nzones = (uint16_t) sbi->n_zones;
511 sb->s_nzones2 = (uint32_t) sbi->n_zones;
512 sb->s_ibmap_blocks = (uint16_t) sbi->ibmap_blocks;
513 sb->s_zbmap_blocks = (uint16_t) sbi->zbmap_blocks;
514 sb->s_first_data_zone = (uint16_t) sbi->first_data_zone;
515 sb->s_log2_zone_size = sbi->log2_zone_size;
516 sb->s_max_file_size = UINT32_MAX;
517 sb->s_magic = sbi->magic;
518 sb->s_state = MFS_VALID_FS;
519
520 rc = write_1k_block(MFS_SUPERBLOCK, 1, sb);
521 free(sb);
522
523 return rc;
524}
525
526static int write_superblock3(const struct mfs_sb_info *sbi)
527{
528 struct mfs3_superblock *sb;
529 int rc;
530
531 sb = (struct mfs3_superblock *) malloc(MFS_SUPERBLOCK_SIZE);
532
533 if (!sb)
534 return ENOMEM;
535
536 sb->s_ninodes = (uint32_t) sbi->n_inodes;
537 sb->s_nzones = (uint32_t) sbi->n_zones;
538 sb->s_ibmap_blocks = (uint16_t) sbi->ibmap_blocks;
539 sb->s_zbmap_blocks = (uint16_t) sbi->zbmap_blocks;
540 sb->s_first_data_zone = (uint16_t) sbi->first_data_zone;
541 sb->s_log2_zone_size = sbi->log2_zone_size;
542 sb->s_max_file_size = UINT32_MAX;
543 sb->s_magic = sbi->magic;
544 sb->s_block_size = sbi->block_size;
545 sb->s_disk_version = 3;
546
547 rc = write_1k_block(MFS_SUPERBLOCK, 1, sb);
548 free(sb);
549
550 return rc;
551}
552
553static int init_bitmaps(const struct mfs_sb_info *sb)
554{
555 uint32_t *ibmap_buf, *zbmap_buf;
556 uint8_t *ibmap_buf8, *zbmap_buf8;
557 unsigned int ibmap_nblocks = sb->ibmap_blocks;
558 unsigned int zbmap_nblocks = sb->zbmap_blocks;
559 unsigned int i;
560 int rc;
561
562 ibmap_buf = (uint32_t *) malloc(ibmap_nblocks * sb->block_size);
563 zbmap_buf = (uint32_t *) malloc(zbmap_nblocks * sb->block_size);
564
565 if (!ibmap_buf || !zbmap_buf)
566 return ENOMEM;
567
568 memset(ibmap_buf, 0xFF, ibmap_nblocks * sb->block_size);
569 memset(zbmap_buf, 0xFF, zbmap_nblocks * sb->block_size);
570
571 for (i = 2; i < sb->n_inodes; ++i)
572 mark_bmap(ibmap_buf, i, FREE);
573
574 for (i = sb->first_data_zone + 1; i < sb->n_zones; ++i)
575 mark_bmap(zbmap_buf, i, FREE);
576
577 /*Convert to 1K block offsets*/
578 ibmap_nblocks = CONVERT_1K_OFF(ibmap_nblocks, sb->block_size);
579 zbmap_nblocks = CONVERT_1K_OFF(zbmap_nblocks, sb->block_size);
580
581 ibmap_buf8 = (uint8_t *) ibmap_buf;
582 zbmap_buf8 = (uint8_t *) zbmap_buf;
583
584 int start_block = 2;
585
586 for (i = 0; i < ibmap_nblocks; ++i) {
587 if ((rc = write_1k_block(start_block + i,
588 1, (ibmap_buf8 + i * MFS_BLOCKSIZE))) != EOK)
589 return rc;
590 }
591
592 start_block = 2 + ibmap_nblocks;
593
594 for (i = 0; i < zbmap_nblocks; ++i) {
595 if ((rc = write_1k_block(start_block + i,
596 1, (zbmap_buf8 + i * MFS_BLOCKSIZE))) != EOK)
597 return rc;
598 }
599
600 free(ibmap_buf);
601 free(zbmap_buf);
602
603 return rc;
604}
605
606static void mark_bmap(uint32_t *bmap, int idx, int v)
607{
608 if (v == FREE)
609 bmap[idx / 32] &= ~(1 << (idx % 32));
610 else
611 bmap[idx / 32] |= 1 << (idx % 32);
612}
613
614static inline int write_1k_block(aoff64_t off, size_t size, const void *data)
615{
616 return block_write_direct(handle, off * 2, size * 2, data);
617}
618
619static void help_cmd_mkminix(help_level_t level)
620{
621 if (level == HELP_SHORT) {
622 printf(NAME": tool to create new Minix file systems\n");
623 } else {
624 printf("Usage: [options] device\n"
625 "-1 Make a Minix version 1 filesystem\n"
626 "-2 Make a Minix version 2 filesystem\n"
627 "-3 Make a Minix version 3 filesystem\n"
628 "-b ## Specify the block size in bytes (V3 only),\n"
629 " valid block size values are 1024, 2048 and 4096 bytes per block\n"
630 "-i ## Specify the number of inodes for the filesystem\n"
631 "-l Use 30-char long filenames (V1/V2 only)\n");
632 }
633}
634
635static int num_of_set_bits(uint32_t n)
636{
637 n = n - ((n >> 1) & 0x55555555);
638 n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
639 return (((n + (n >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
640}
641
642
643/**
644 * @}
645 */
Note: See TracBrowser for help on using the repository browser.