Changeset 5726a1a3 in mainline
- Timestamp:
- 2011-10-08T12:48:12Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ee6d9dd
- Parents:
- 36cb22f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkmfs/mkmfs.c
r36cb22f r5726a1a3 84 84 85 85 static void help_cmd_mkmfs(help_level_t level); 86 static int num_of_set_bits(uint32_t n);86 static bool is_power_of_two(uint32_t n); 87 87 static int init_superblock(struct mfs_sb_info *sb); 88 88 static int write_superblock(const struct mfs_sb_info *sbi); … … 172 172 printf(NAME ":Error! Invalid block size.\n"); 173 173 exit(0); 174 } else if ( num_of_set_bits(sb.block_size) != 1) {174 } else if (!is_power_of_two(sb.block_size)) { 175 175 /*Block size must be a power of 2.*/ 176 176 printf(NAME ":Error! Invalid block size.\n"); … … 236 236 237 237 printf(NAME ": Creating Minix file system on device\n"); 238 printf(NAME ": Writing superblock\n"); 238 239 239 240 /*Initialize superblock*/ … … 243 244 } 244 245 246 printf(NAME ": Initializing bitmaps\n"); 247 245 248 /*Initialize bitmaps*/ 246 249 if (init_bitmaps(&sb) != EOK) { … … 249 252 } 250 253 254 printf(NAME ": Initializing the inode table\n"); 255 251 256 /*Init inode table*/ 252 257 if (init_inode_table(&sb) != EOK) { … … 254 259 return 2; 255 260 } 261 262 printf(NAME ": Creating the root directory inode\n"); 256 263 257 264 /*Make the root inode*/ … … 720 727 } 721 728 722 static int num_of_set_bits(uint32_t n) 723 { 724 n = n - ((n >> 1) & 0x55555555); 725 n = (n & 0x33333333) + ((n >> 2) & 0x33333333); 726 return (((n + (n >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24; 729 static bool is_power_of_two(uint32_t n) 730 { 731 if (n == 0) 732 return false; 733 734 return (n & (n - 1)) == 0; 727 735 } 728 736
Note:
See TracChangeset
for help on using the changeset viewer.