fprintf(f,"\n");
}
-static int int_log10(unsigned long long arg)
-{
- int l = 0;
-
- arg = arg / 10;
- while (arg) {
- l++;
- arg = arg / 10;
- }
- return l;
-}
-
#define DUMP_LEAF_EXTENTS 0x01
#define DUMP_NODE_EXTENTS 0x02
#define DUMP_EXTENT_TABLE 0x04
return;
}
- logical_width = int_log10((EXT2_I_SIZE(&inode)+current_fs->blocksize-1)/
+ logical_width = ext2fs_log10((EXT2_I_SIZE(&inode)+current_fs->blocksize-1)/
current_fs->blocksize) + 1;
if (logical_width < 5)
logical_width = 5;
- physical_width = int_log10(ext2fs_blocks_count(current_fs->super)) + 1;
+ physical_width = ext2fs_log10(ext2fs_blocks_count(current_fs->super)) + 1;
if (physical_width < 5)
physical_width = 5;
struct dir_list *dir_list, *dir_last;
};
-static int int_log10(unsigned long long arg)
-{
- int l = 0;
-
- arg = arg / 10;
- while (arg) {
- l++;
- arg = arg / 10;
- }
- return l;
-}
-
static void print_header(struct filefrag_struct *fs)
{
if (fs->options & VERBOSE_OPT) {
errcode_t retval;
int blocksize = current_fs->blocksize;
- fs->logical_width = int_log10((EXT2_I_SIZE(inode) + blocksize - 1) /
- blocksize) + 1;
+ fs->logical_width = ext2fs_log10((EXT2_I_SIZE(inode) + blocksize - 1) /
+ blocksize) + 1;
if (fs->logical_width < 7)
fs->logical_width = 7;
fs->ext = 0;
return;
fs.f = open_pager();
- fs.physical_width = int_log10(ext2fs_blocks_count(current_fs->super));
+ fs.physical_width = ext2fs_log10(ext2fs_blocks_count(current_fs->super));
fs.physical_width++;
if (fs.physical_width < 8)
fs.physical_width = 8;
return (struct ext2_dx_root_info *)de;
}
+_INLINE_ int ext2fs_log2(unsigned long long arg)
+{
+ int l = 0;
+
+ arg >>= 1;
+ while (arg) {
+ l++;
+ arg >>= 1;
+ }
+ return l;
+}
+
+_INLINE_ int ext2fs_log10(unsigned long long arg)
+{
+ int l = 0;
+
+ arg /= 10;
+ while (arg) {
+ l++;
+ arg /= 10;
+ }
+ return l;
+}
+
/*
* This is an efficient, overflow safe way of calculating ceil((1.0 * a) / b)
*/
return 0;
}
-static int ul_log2(unsigned long arg)
-{
- int l = 0;
-
- arg >>= 1;
- while (arg) {
- l++;
- arg >>= 1;
- }
- return l;
-}
-
size_t ext2fs_max_extent_depth(ext2_extent_handle_t handle)
{
size_t iblock_sz = sizeof(((struct ext2_inode *)NULL)->i_block);
if (last_blocksize && last_blocksize == handle->fs->blocksize)
return last_result;
- last_result = 1 + ((ul_log2(EXT_MAX_EXTENT_LBLK) - ul_log2(iblock_extents)) /
- ul_log2(extents_per_block));
+ last_result = 1 + ((ext2fs_log2(EXT_MAX_EXTENT_LBLK) -
+ ext2fs_log2(iblock_extents)) /
+ ext2fs_log2(extents_per_block));
last_blocksize = handle->fs->blocksize;
return last_result;
}
#endif
}
-static int ul_log2(unsigned long arg)
-{
- int l = 0;
-
- arg >>= 1;
- while (arg) {
- l++;
- arg >>= 1;
- }
- return l;
-}
-
static void init_chunk_info(ext2_filsys fs, struct chunk_info *info)
{
int i;
- info->blocksize_bits = ul_log2((unsigned long)fs->blocksize);
+ info->blocksize_bits = ext2fs_log2(fs->blocksize);
if (info->chunkbytes) {
- info->chunkbits = ul_log2(info->chunkbytes);
+ info->chunkbits = ext2fs_log2(info->chunkbytes);
info->blks_in_chunk = info->chunkbytes >> info->blocksize_bits;
} else {
- info->chunkbits = ul_log2(DEFAULT_CHUNKSIZE);
+ info->chunkbits = ext2fs_log2(DEFAULT_CHUNKSIZE);
info->blks_in_chunk = DEFAULT_CHUNKSIZE >> info->blocksize_bits;
}
{
unsigned long idx;
- idx = ul_log2(chunk_size) + 1;
+ idx = ext2fs_log2(chunk_size) + 1;
if (idx >= MAX_HIST)
idx = MAX_HIST-1;
info->histogram.fc_chunks[idx]++;
#define EXT4_IOC_SET_ENCRYPTION_POLICY _IOR('f', 19, struct ext4_encryption_policy)
#define EXT4_IOC_GET_ENCRYPTION_POLICY _IOW('f', 21, struct ext4_encryption_policy)
-static int int_log2(int arg)
-{
- int l = 0;
-
- arg >>= 1;
- while (arg) {
- l++;
- arg >>= 1;
- }
- return l;
-}
-
static void validate_paths(int argc, char *argv[], int path_start_index)
{
int x;
EXT4_ENCRYPTION_MODE_AES_256_XTS;
policy.filenames_encryption_mode =
EXT4_ENCRYPTION_MODE_AES_256_CTS;
- policy.flags = int_log2(pad >> 2);
+ policy.flags = ext2fs_log2(pad >> 2);
memcpy(policy.master_key_descriptor, salt->key_desc,
EXT4_KEY_DESCRIPTOR_SIZE);
rc = ioctl(fd, EXT4_IOC_SET_ENCRYPTION_POLICY, &policy);
#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
#define EXT3_IOC_GETFLAGS _IOR('f', 1, long)
-static int ulong_log2(unsigned long arg)
-{
- int l = 0;
-
- arg >>= 1;
- while (arg) {
- l++;
- arg >>= 1;
- }
- return l;
-}
-
-static int ulong_log10(unsigned long long arg)
-{
- int l = 0;
-
- arg = arg / 10;
- while (arg) {
- l++;
- arg = arg / 10;
- }
- return l;
-}
-
static unsigned int div_ceil(unsigned int a, unsigned int b)
{
if (!a)
}
last_device = st.st_dev;
- width = ulong_log10(fsinfo.f_blocks);
+ width = ext2fs_log10(fsinfo.f_blocks);
if (width > physical_width)
physical_width = width;
numblocks = (st.st_size + blksize - 1) / blksize;
if (blocksize != 0)
- blk_shift = ulong_log2(blocksize);
+ blk_shift = ext2fs_log2(blocksize);
else
- blk_shift = ulong_log2(blksize);
+ blk_shift = ext2fs_log2(blksize);
if (use_extent_cache)
width = 10;
else
- width = ulong_log10(numblocks);
+ width = ext2fs_log10(numblocks);
if (width > logical_width)
logical_width = width;
if (verbose) {
fn_prefix = get_string_from_profile(fs_types, "hugefiles_name",
"hugefile");
idx_digits = get_int_from_profile(fs_types, "hugefiles_digits", 5);
- d = int_log10(num_files) + 1;
+ d = ext2fs_log10(num_files) + 1;
if (idx_digits > d)
d = idx_digits;
dsize = strlen(fn_prefix) + d + 16;
exit(1);
}
-static int int_log2(unsigned long long arg)
-{
- int l = 0;
-
- arg >>= 1;
- while (arg) {
- l++;
- arg >>= 1;
- }
- return l;
-}
-
-int int_log10(unsigned long long arg)
-{
- int l;
-
- for (l=0; arg ; l++)
- arg = arg / 10;
- return l;
-}
-
/*
* Helper function for read_bb_file and test_disk
*/
printf(", ");
else
is_first_backup = 0;
- need = int_log10(group_block) + 2;
+ need = ext2fs_log10(group_block) + 2;
if (need > col_left) {
printf("\n\t");
col_left = 72;
blocksize);
if (blocksize > 0)
fs_param.s_log_block_size =
- int_log2(blocksize >>
+ ext2fs_log2(blocksize >>
EXT2_MIN_BLOCK_LOG_SIZE);
break;
case 'c': /* Check for bad blocks */
blocksize = jfs->blocksize;
printf(_("Using journal device's blocksize: %d\n"), blocksize);
fs_param.s_log_block_size =
- int_log2(blocksize >> EXT2_MIN_BLOCK_LOG_SIZE);
+ ext2fs_log2(blocksize >> EXT2_MIN_BLOCK_LOG_SIZE);
ext2fs_close_free(&jfs);
}
}
fs_param.s_log_block_size =
- int_log2(blocksize >> EXT2_MIN_BLOCK_LOG_SIZE);
+ ext2fs_log2(blocksize >> EXT2_MIN_BLOCK_LOG_SIZE);
/*
* We now need to do a sanity check of fs_blocks_count for
"cluster_size",
blocksize*16);
fs_param.s_log_cluster_size =
- int_log2(cluster_size >> EXT2_MIN_CLUSTER_LOG_SIZE);
+ ext2fs_log2(cluster_size >> EXT2_MIN_CLUSTER_LOG_SIZE);
if (fs_param.s_log_cluster_size &&
fs_param.s_log_cluster_size < fs_param.s_log_block_size) {
com_err(program_name, 0, "%s",
"flex_bg size may not be specified"));
exit(1);
}
- fs_param.s_log_groups_per_flex = int_log2(flex_bg_size);
+ fs_param.s_log_groups_per_flex = ext2fs_log2(flex_bg_size);
}
if (inode_size && fs_param.s_rev_level >= EXT2_DYNAMIC_REV) {
const char *def_val);
extern int get_int_from_profile(char **types, const char *opt, int def_val);
extern int get_bool_from_profile(char **types, const char *opt, int def_val);
-extern int int_log10(unsigned long long arg);
/* mk_hugefiles.c */
extern errcode_t mk_hugefiles(ext2_filsys fs, const char *device_name);