Changeset 5726a1a3 in mainline


Ignore:
Timestamp:
2011-10-08T12:48:12Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ee6d9dd
Parents:
36cb22f
Message:

mkmfs improvements:

  • Be more verbose.
  • num_of_set_bits() is not used, replace it with is_power_of_two()
File:
1 edited

Legend:

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

    r36cb22f r5726a1a3  
    8484
    8585static void     help_cmd_mkmfs(help_level_t level);
    86 static int      num_of_set_bits(uint32_t n);
     86static bool     is_power_of_two(uint32_t n);
    8787static int      init_superblock(struct mfs_sb_info *sb);
    8888static int      write_superblock(const struct mfs_sb_info *sbi);
     
    172172                printf(NAME ":Error! Invalid block size.\n");
    173173                exit(0);
    174         } else if (num_of_set_bits(sb.block_size) != 1) {
     174        } else if (!is_power_of_two(sb.block_size)) {
    175175                /*Block size must be a power of 2.*/
    176176                printf(NAME ":Error! Invalid block size.\n");
     
    236236
    237237        printf(NAME ": Creating Minix file system on device\n");
     238        printf(NAME ": Writing superblock\n");
    238239
    239240        /*Initialize superblock*/
     
    243244        }
    244245
     246        printf(NAME ": Initializing bitmaps\n");
     247
    245248        /*Initialize bitmaps*/
    246249        if (init_bitmaps(&sb) != EOK) {
     
    249252        }
    250253
     254        printf(NAME ": Initializing the inode table\n");
     255
    251256        /*Init inode table*/
    252257        if (init_inode_table(&sb) != EOK) {
     
    254259                return 2;
    255260        }
     261
     262        printf(NAME ": Creating the root directory inode\n");
    256263
    257264        /*Make the root inode*/
     
    720727}
    721728
    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;
     729static bool is_power_of_two(uint32_t n)
     730{
     731        if (n == 0)
     732                return false;
     733
     734        return (n & (n - 1)) == 0;
    727735}
    728736
Note: See TracChangeset for help on using the changeset viewer.