mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2024-11-23 01:59:54 +00:00
Switch from the u_int to the uint types
commit 87d7a95e3134b668e9f1e8519a19f390509fac60 category: bugfix issue: #I6VAS0 CVE: NA Signed-off-by: DongSenhao <dongsenhao2@huawei.com> --------------------------------------- Many format strings use one of the PRI* macros. These macros are compatible with the uint types but not with the u_int types. Hence this patch that switches from the u_int to the uint types. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: dongsenhao <dongsenhao2@huawei.com>
This commit is contained in:
parent
d29305ee15
commit
a8c6a6d93f
@ -2312,7 +2312,7 @@ static void fix_checkpoint(struct f2fs_sb_info *sbi)
|
||||
block_t cp_blocks;
|
||||
u32 i;
|
||||
int ret;
|
||||
u_int32_t crc = 0;
|
||||
uint32_t crc = 0;
|
||||
|
||||
/* should call from fsck */
|
||||
ASSERT(c.func == FSCK);
|
||||
@ -2438,7 +2438,7 @@ static int check_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
|
||||
struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
|
||||
struct blk_zone blkz;
|
||||
block_t cs_block, wp_block, zone_last_vblock;
|
||||
u_int64_t cs_sector, wp_sector;
|
||||
uint64_t cs_sector, wp_sector;
|
||||
int i, ret;
|
||||
unsigned int zone_segno;
|
||||
int log_sectors_per_block = sbi->log_blocksize - SECTOR_SHIFT;
|
||||
|
44
fsck/mount.c
44
fsck/mount.c
@ -31,7 +31,7 @@
|
||||
#define ACL_OTHER (0x20)
|
||||
#endif
|
||||
|
||||
static int get_device_idx(struct f2fs_sb_info *sbi, u_int32_t segno)
|
||||
static int get_device_idx(struct f2fs_sb_info *sbi, uint32_t segno)
|
||||
{
|
||||
block_t seg_start_blkaddr;
|
||||
int i;
|
||||
@ -48,7 +48,7 @@ static int get_device_idx(struct f2fs_sb_info *sbi, u_int32_t segno)
|
||||
#ifdef HAVE_LINUX_BLKZONED_H
|
||||
|
||||
static int get_zone_idx_from_dev(struct f2fs_sb_info *sbi,
|
||||
u_int32_t segno, u_int32_t dev_idx)
|
||||
uint32_t segno, uint32_t dev_idx)
|
||||
{
|
||||
block_t seg_start_blkaddr = START_BLOCK(sbi, segno);
|
||||
|
||||
@ -365,7 +365,7 @@ void print_node_info(struct f2fs_sb_info *sbi,
|
||||
}
|
||||
}
|
||||
|
||||
static void DISP_label(u_int16_t *name)
|
||||
static void DISP_label(uint16_t *name)
|
||||
{
|
||||
char buffer[MAX_VOLUME_NAME];
|
||||
|
||||
@ -674,7 +674,7 @@ out:
|
||||
void update_superblock(struct f2fs_super_block *sb, int sb_mask)
|
||||
{
|
||||
int addr, ret;
|
||||
u_int8_t *buf;
|
||||
uint8_t *buf;
|
||||
u32 old_crc, new_crc;
|
||||
|
||||
buf = calloc(BLOCK_SZ, 1);
|
||||
@ -1498,7 +1498,7 @@ static int f2fs_late_init_nid_bitmap(struct f2fs_sb_info *sbi)
|
||||
u32 update_nat_bits_flags(struct f2fs_super_block *sb,
|
||||
struct f2fs_checkpoint *cp, u32 flags)
|
||||
{
|
||||
u_int32_t nat_bits_bytes, nat_bits_blocks;
|
||||
uint32_t nat_bits_bytes, nat_bits_blocks;
|
||||
|
||||
nat_bits_bytes = get_sb(segment_count_nat) << 5;
|
||||
nat_bits_blocks = F2FS_BYTES_TO_BLK((nat_bits_bytes << 1) + 8 +
|
||||
@ -1517,14 +1517,14 @@ void write_nat_bits(struct f2fs_sb_info *sbi,
|
||||
struct f2fs_super_block *sb, struct f2fs_checkpoint *cp, int set)
|
||||
{
|
||||
struct f2fs_nm_info *nm_i = NM_I(sbi);
|
||||
u_int32_t nat_blocks = get_sb(segment_count_nat) <<
|
||||
uint32_t nat_blocks = get_sb(segment_count_nat) <<
|
||||
(get_sb(log_blocks_per_seg) - 1);
|
||||
u_int32_t nat_bits_bytes = nat_blocks >> 3;
|
||||
u_int32_t nat_bits_blocks = F2FS_BYTES_TO_BLK((nat_bits_bytes << 1) +
|
||||
uint32_t nat_bits_bytes = nat_blocks >> 3;
|
||||
uint32_t nat_bits_blocks = F2FS_BYTES_TO_BLK((nat_bits_bytes << 1) +
|
||||
8 + F2FS_BLKSIZE - 1);
|
||||
unsigned char *nat_bits, *full_nat_bits, *empty_nat_bits;
|
||||
struct f2fs_nat_block *nat_block;
|
||||
u_int32_t i, j;
|
||||
uint32_t i, j;
|
||||
block_t blkaddr;
|
||||
int ret;
|
||||
|
||||
@ -1590,15 +1590,15 @@ static int check_nat_bits(struct f2fs_sb_info *sbi,
|
||||
struct f2fs_super_block *sb, struct f2fs_checkpoint *cp)
|
||||
{
|
||||
struct f2fs_nm_info *nm_i = NM_I(sbi);
|
||||
u_int32_t nat_blocks = get_sb(segment_count_nat) <<
|
||||
uint32_t nat_blocks = get_sb(segment_count_nat) <<
|
||||
(get_sb(log_blocks_per_seg) - 1);
|
||||
u_int32_t nat_bits_bytes = nat_blocks >> 3;
|
||||
u_int32_t nat_bits_blocks = F2FS_BYTES_TO_BLK((nat_bits_bytes << 1) +
|
||||
uint32_t nat_bits_bytes = nat_blocks >> 3;
|
||||
uint32_t nat_bits_blocks = F2FS_BYTES_TO_BLK((nat_bits_bytes << 1) +
|
||||
8 + F2FS_BLKSIZE - 1);
|
||||
unsigned char *nat_bits, *full_nat_bits, *empty_nat_bits;
|
||||
struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
|
||||
struct f2fs_journal *journal = &curseg->sum_blk->journal;
|
||||
u_int32_t i, j;
|
||||
uint32_t i, j;
|
||||
block_t blkaddr;
|
||||
int err = 0;
|
||||
|
||||
@ -1628,8 +1628,8 @@ static int check_nat_bits(struct f2fs_sb_info *sbi,
|
||||
}
|
||||
|
||||
for (i = 0; i < nat_blocks; i++) {
|
||||
u_int32_t start_nid = i * NAT_ENTRY_PER_BLOCK;
|
||||
u_int32_t valid = 0;
|
||||
uint32_t start_nid = i * NAT_ENTRY_PER_BLOCK;
|
||||
uint32_t valid = 0;
|
||||
int empty = test_bit_le(i, empty_nat_bits);
|
||||
int full = test_bit_le(i, full_nat_bits);
|
||||
|
||||
@ -2702,7 +2702,7 @@ void set_section_type(struct f2fs_sb_info *sbi, unsigned int segno, int type)
|
||||
static bool write_pointer_at_zone_start(struct f2fs_sb_info *sbi,
|
||||
unsigned int zone_segno)
|
||||
{
|
||||
u_int64_t sector;
|
||||
uint64_t sector;
|
||||
struct blk_zone blkz;
|
||||
block_t block = START_BLOCK(sbi, zone_segno);
|
||||
int log_sectors_per_block = sbi->log_blocksize - SECTOR_SHIFT;
|
||||
@ -3011,7 +3011,7 @@ void write_checkpoint(struct f2fs_sb_info *sbi)
|
||||
unsigned long long cp_blk_no;
|
||||
u32 flags = CP_UMOUNT_FLAG;
|
||||
int i, ret;
|
||||
u_int32_t crc = 0;
|
||||
uint32_t crc = 0;
|
||||
|
||||
if (is_set_ckpt_flags(cp, CP_ORPHAN_PRESENT_FLAG)) {
|
||||
orphan_blks = __start_sum_addr(sbi) - 1;
|
||||
@ -3242,7 +3242,7 @@ void build_nat_area_bitmap(struct f2fs_sb_info *sbi)
|
||||
|
||||
static int check_sector_size(struct f2fs_super_block *sb)
|
||||
{
|
||||
u_int32_t log_sectorsize, log_sectors_per_block;
|
||||
uint32_t log_sectorsize, log_sectors_per_block;
|
||||
|
||||
log_sectorsize = log_base_2(c.sector_size);
|
||||
log_sectors_per_block = log_base_2(c.sectors_per_blk);
|
||||
@ -3679,10 +3679,10 @@ void f2fs_do_umount(struct f2fs_sb_info *sbi)
|
||||
int f2fs_sparse_initialize_meta(struct f2fs_sb_info *sbi)
|
||||
{
|
||||
struct f2fs_super_block *sb = sbi->raw_super;
|
||||
u_int32_t sit_seg_count, sit_size;
|
||||
u_int32_t nat_seg_count, nat_size;
|
||||
u_int64_t sit_seg_addr, nat_seg_addr, payload_addr;
|
||||
u_int32_t seg_size = 1 << get_sb(log_blocks_per_seg);
|
||||
uint32_t sit_seg_count, sit_size;
|
||||
uint32_t nat_seg_count, nat_size;
|
||||
uint64_t sit_seg_addr, nat_seg_addr, payload_addr;
|
||||
uint32_t seg_size = 1 << get_sb(log_blocks_per_seg);
|
||||
int ret;
|
||||
|
||||
if (!c.sparse_mode)
|
||||
|
@ -11,27 +11,27 @@
|
||||
|
||||
static int get_new_sb(struct f2fs_super_block *sb)
|
||||
{
|
||||
u_int32_t zone_size_bytes;
|
||||
u_int64_t zone_align_start_offset;
|
||||
u_int32_t blocks_for_sit, blocks_for_nat, blocks_for_ssa;
|
||||
u_int32_t sit_segments, nat_segments, diff, total_meta_segments;
|
||||
u_int32_t total_valid_blks_available;
|
||||
u_int32_t sit_bitmap_size, max_sit_bitmap_size;
|
||||
u_int32_t max_nat_bitmap_size, max_nat_segments;
|
||||
u_int32_t segment_size_bytes = 1 << (get_sb(log_blocksize) +
|
||||
uint32_t zone_size_bytes;
|
||||
uint64_t zone_align_start_offset;
|
||||
uint32_t blocks_for_sit, blocks_for_nat, blocks_for_ssa;
|
||||
uint32_t sit_segments, nat_segments, diff, total_meta_segments;
|
||||
uint32_t total_valid_blks_available;
|
||||
uint32_t sit_bitmap_size, max_sit_bitmap_size;
|
||||
uint32_t max_nat_bitmap_size, max_nat_segments;
|
||||
uint32_t segment_size_bytes = 1 << (get_sb(log_blocksize) +
|
||||
get_sb(log_blocks_per_seg));
|
||||
u_int32_t blks_per_seg = 1 << get_sb(log_blocks_per_seg);
|
||||
u_int32_t segs_per_zone = get_sb(segs_per_sec) * get_sb(secs_per_zone);
|
||||
uint32_t blks_per_seg = 1 << get_sb(log_blocks_per_seg);
|
||||
uint32_t segs_per_zone = get_sb(segs_per_sec) * get_sb(secs_per_zone);
|
||||
|
||||
set_sb(block_count, c.target_sectors >>
|
||||
get_sb(log_sectors_per_block));
|
||||
|
||||
zone_size_bytes = segment_size_bytes * segs_per_zone;
|
||||
zone_align_start_offset =
|
||||
((u_int64_t) c.start_sector * DEFAULT_SECTOR_SIZE +
|
||||
((uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE +
|
||||
2 * F2FS_BLKSIZE + zone_size_bytes - 1) /
|
||||
zone_size_bytes * zone_size_bytes -
|
||||
(u_int64_t) c.start_sector * DEFAULT_SECTOR_SIZE;
|
||||
(uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE;
|
||||
|
||||
set_sb(segment_count, (c.target_sectors * c.sector_size -
|
||||
zone_align_start_offset) / segment_size_bytes /
|
||||
@ -76,7 +76,7 @@ static int get_new_sb(struct f2fs_super_block *sb)
|
||||
/* use cp_payload if free space of f2fs_checkpoint is not enough */
|
||||
if (max_sit_bitmap_size + max_nat_bitmap_size >
|
||||
MAX_BITMAP_SIZE_IN_CKPT) {
|
||||
u_int32_t diff = max_sit_bitmap_size +
|
||||
uint32_t diff = max_sit_bitmap_size +
|
||||
max_nat_bitmap_size -
|
||||
MAX_BITMAP_SIZE_IN_CKPT;
|
||||
set_sb(cp_payload, F2FS_BLK_ALIGN(diff));
|
||||
@ -457,7 +457,7 @@ static void rebuild_checkpoint(struct f2fs_sb_info *sbi,
|
||||
block_t new_cp_blks = 1 + get_newsb(cp_payload);
|
||||
block_t orphan_blks = 0;
|
||||
block_t new_cp_blk_no, old_cp_blk_no;
|
||||
u_int32_t crc = 0;
|
||||
uint32_t crc = 0;
|
||||
u32 flags;
|
||||
void *buf;
|
||||
int i, ret;
|
||||
|
@ -70,20 +70,16 @@
|
||||
|
||||
#ifdef ANDROID_WINDOWS_HOST
|
||||
#undef HAVE_LINUX_TYPES_H
|
||||
typedef uint64_t u_int64_t;
|
||||
typedef uint32_t u_int32_t;
|
||||
typedef uint16_t u_int16_t;
|
||||
typedef uint8_t u_int8_t;
|
||||
#endif
|
||||
|
||||
/* codes from kernel's f2fs.h, GPL-v2.0 */
|
||||
#define MIN_COMPRESS_LOG_SIZE 2
|
||||
#define MAX_COMPRESS_LOG_SIZE 8
|
||||
|
||||
typedef u_int64_t u64;
|
||||
typedef u_int32_t u32;
|
||||
typedef u_int16_t u16;
|
||||
typedef u_int8_t u8;
|
||||
typedef uint64_t u64;
|
||||
typedef uint32_t u32;
|
||||
typedef uint16_t u16;
|
||||
typedef uint8_t u8;
|
||||
typedef u32 block_t;
|
||||
typedef u32 nid_t;
|
||||
#ifndef bool
|
||||
@ -378,16 +374,16 @@ enum default_set {
|
||||
struct device_info {
|
||||
char *path;
|
||||
int32_t fd;
|
||||
u_int32_t sector_size;
|
||||
u_int64_t total_sectors; /* got by get_device_info */
|
||||
u_int64_t start_blkaddr;
|
||||
u_int64_t end_blkaddr;
|
||||
u_int32_t total_segments;
|
||||
uint32_t sector_size;
|
||||
uint64_t total_sectors; /* got by get_device_info */
|
||||
uint64_t start_blkaddr;
|
||||
uint64_t end_blkaddr;
|
||||
uint32_t total_segments;
|
||||
|
||||
/* to handle zone block devices */
|
||||
int zoned_model;
|
||||
u_int32_t nr_zones;
|
||||
u_int32_t nr_rnd_zones;
|
||||
uint32_t nr_zones;
|
||||
uint32_t nr_rnd_zones;
|
||||
size_t zone_blocks;
|
||||
uint64_t zone_size;
|
||||
size_t *zone_cap_blocks;
|
||||
@ -445,36 +441,36 @@ typedef struct {
|
||||
#define ALIGN_UP(addrs, size) ALIGN_DOWN(((addrs) + (size) - 1), (size))
|
||||
|
||||
struct f2fs_configuration {
|
||||
u_int32_t reserved_segments;
|
||||
u_int32_t new_reserved_segments;
|
||||
uint32_t reserved_segments;
|
||||
uint32_t new_reserved_segments;
|
||||
int sparse_mode;
|
||||
int zoned_mode;
|
||||
int zoned_model;
|
||||
size_t zone_blocks;
|
||||
double overprovision;
|
||||
double new_overprovision;
|
||||
u_int32_t cur_seg[6];
|
||||
u_int32_t segs_per_sec;
|
||||
u_int32_t secs_per_zone;
|
||||
u_int32_t segs_per_zone;
|
||||
u_int32_t start_sector;
|
||||
u_int32_t total_segments;
|
||||
u_int32_t sector_size;
|
||||
u_int64_t device_size;
|
||||
u_int64_t total_sectors;
|
||||
u_int64_t wanted_total_sectors;
|
||||
u_int64_t wanted_sector_size;
|
||||
u_int64_t target_sectors;
|
||||
u_int64_t max_size;
|
||||
u_int32_t sectors_per_blk;
|
||||
u_int32_t blks_per_seg;
|
||||
uint32_t cur_seg[6];
|
||||
uint32_t segs_per_sec;
|
||||
uint32_t secs_per_zone;
|
||||
uint32_t segs_per_zone;
|
||||
uint32_t start_sector;
|
||||
uint32_t total_segments;
|
||||
uint32_t sector_size;
|
||||
uint64_t device_size;
|
||||
uint64_t total_sectors;
|
||||
uint64_t wanted_total_sectors;
|
||||
uint64_t wanted_sector_size;
|
||||
uint64_t target_sectors;
|
||||
uint64_t max_size;
|
||||
uint32_t sectors_per_blk;
|
||||
uint32_t blks_per_seg;
|
||||
__u8 init_version[VERSION_LEN + 1];
|
||||
__u8 sb_version[VERSION_LEN + 1];
|
||||
__u8 version[VERSION_LEN + 1];
|
||||
char *vol_label;
|
||||
char *vol_uuid;
|
||||
u_int16_t s_encoding;
|
||||
u_int16_t s_encoding_flags;
|
||||
uint16_t s_encoding;
|
||||
uint16_t s_encoding_flags;
|
||||
int heap;
|
||||
int32_t kd;
|
||||
int32_t dump_fd;
|
||||
@ -513,20 +509,20 @@ struct f2fs_configuration {
|
||||
|
||||
/* mkfs parameters */
|
||||
int fake_seed;
|
||||
u_int32_t next_free_nid;
|
||||
u_int32_t quota_inum;
|
||||
u_int32_t quota_dnum;
|
||||
u_int32_t lpf_inum;
|
||||
u_int32_t lpf_dnum;
|
||||
u_int32_t lpf_ino;
|
||||
u_int32_t root_uid;
|
||||
u_int32_t root_gid;
|
||||
uint32_t next_free_nid;
|
||||
uint32_t quota_inum;
|
||||
uint32_t quota_dnum;
|
||||
uint32_t lpf_inum;
|
||||
uint32_t lpf_dnum;
|
||||
uint32_t lpf_ino;
|
||||
uint32_t root_uid;
|
||||
uint32_t root_gid;
|
||||
|
||||
/* defragmentation parameters */
|
||||
int defrag_shrink;
|
||||
u_int64_t defrag_start;
|
||||
u_int64_t defrag_len;
|
||||
u_int64_t defrag_target;
|
||||
uint64_t defrag_start;
|
||||
uint64_t defrag_len;
|
||||
uint64_t defrag_target;
|
||||
|
||||
/* sload parameters */
|
||||
char *from_dir;
|
||||
@ -543,7 +539,7 @@ struct f2fs_configuration {
|
||||
int safe_resize;
|
||||
|
||||
/* precomputed fs UUID checksum for seeding other checksums */
|
||||
u_int32_t chksum_seed;
|
||||
uint32_t chksum_seed;
|
||||
|
||||
/* cache parameters */
|
||||
dev_cache_config_t cache_config;
|
||||
@ -1319,9 +1315,9 @@ enum {
|
||||
SSR
|
||||
};
|
||||
|
||||
extern int utf8_to_utf16(u_int16_t *, const char *, size_t, size_t);
|
||||
extern int utf16_to_utf8(char *, const u_int16_t *, size_t, size_t);
|
||||
extern int log_base_2(u_int32_t);
|
||||
extern int utf8_to_utf16(uint16_t *, const char *, size_t, size_t);
|
||||
extern int utf16_to_utf8(char *, const uint16_t *, size_t, size_t);
|
||||
extern int log_base_2(uint32_t);
|
||||
extern unsigned int addrs_per_inode(struct f2fs_inode *);
|
||||
extern unsigned int addrs_per_block(struct f2fs_inode *);
|
||||
extern unsigned int f2fs_max_file_offset(struct f2fs_inode *);
|
||||
@ -1339,8 +1335,8 @@ extern int f2fs_clear_bit(unsigned int, char *);
|
||||
extern u64 find_next_bit_le(const u8 *, u64, u64);
|
||||
extern u64 find_next_zero_bit_le(const u8 *, u64, u64);
|
||||
|
||||
extern u_int32_t f2fs_cal_crc32(u_int32_t, void *, int);
|
||||
extern int f2fs_crc_valid(u_int32_t blk_crc, void *buf, int len);
|
||||
extern uint32_t f2fs_cal_crc32(uint32_t, void *, int);
|
||||
extern int f2fs_crc_valid(uint32_t blk_crc, void *buf, int len);
|
||||
|
||||
extern void f2fs_init_configuration(void);
|
||||
extern int f2fs_devs_are_umounted(void);
|
||||
@ -1497,7 +1493,7 @@ blk_zone_cond_str(struct blk_zone *blkz)
|
||||
|
||||
extern int f2fs_get_zoned_model(int);
|
||||
extern int f2fs_get_zone_blocks(int);
|
||||
extern int f2fs_report_zone(int, u_int64_t, void *);
|
||||
extern int f2fs_report_zone(int, uint64_t, void *);
|
||||
typedef int (report_zones_cb_t)(int i, void *, void *);
|
||||
extern int f2fs_report_zones(int, report_zones_cb_t *, void *);
|
||||
extern int f2fs_check_zones(int);
|
||||
@ -1514,7 +1510,7 @@ static inline double get_best_overprovision(struct f2fs_super_block *sb)
|
||||
{
|
||||
double reserved, ovp, candidate, end, diff, space;
|
||||
double max_ovp = 0, max_space = 0;
|
||||
u_int32_t usable_main_segs = f2fs_get_usable_segments(sb);
|
||||
uint32_t usable_main_segs = f2fs_get_usable_segments(sb);
|
||||
|
||||
if (get_sb(segment_count_main) < 256) {
|
||||
candidate = 10;
|
||||
@ -1541,12 +1537,12 @@ static inline double get_best_overprovision(struct f2fs_super_block *sb)
|
||||
|
||||
static inline __le64 get_cp_crc(struct f2fs_checkpoint *cp)
|
||||
{
|
||||
u_int64_t cp_ver = get_cp(checkpoint_ver);
|
||||
uint64_t cp_ver = get_cp(checkpoint_ver);
|
||||
size_t crc_offset = get_cp(checksum_offset);
|
||||
u_int32_t crc = le32_to_cpu(*(__le32 *)((unsigned char *)cp +
|
||||
uint32_t crc = le32_to_cpu(*(__le32 *)((unsigned char *)cp +
|
||||
crc_offset));
|
||||
|
||||
cp_ver |= ((u_int64_t)crc << 32);
|
||||
cp_ver |= ((uint64_t)crc << 32);
|
||||
return cpu_to_le64(cp_ver);
|
||||
}
|
||||
|
||||
@ -1693,7 +1689,7 @@ static inline int parse_feature(struct feature *table, const char *features)
|
||||
}
|
||||
|
||||
static inline int parse_root_owner(char *ids,
|
||||
u_int32_t *root_uid, u_int32_t *root_gid)
|
||||
uint32_t *root_uid, uint32_t *root_gid)
|
||||
{
|
||||
char *uid = ids;
|
||||
char *gid = NULL;
|
||||
|
@ -46,18 +46,18 @@ enum quota_type {
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct v2_disk_dqheader {
|
||||
u_int32_t dqh_magic; /* Magic number identifying file */
|
||||
u_int32_t dqh_version; /* File version */
|
||||
uint32_t dqh_magic; /* Magic number identifying file */
|
||||
uint32_t dqh_version; /* File version */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* Header with type and version specific information */
|
||||
struct v2_disk_dqinfo {
|
||||
u_int32_t dqi_bgrace; /* Time before block soft limit becomes hard limit */
|
||||
u_int32_t dqi_igrace; /* Time before inode soft limit becomes hard limit */
|
||||
u_int32_t dqi_flags; /* Flags for quotafile (DQF_*) */
|
||||
u_int32_t dqi_blocks; /* Number of blocks in file */
|
||||
u_int32_t dqi_free_blk; /* Number of first free block in the list */
|
||||
u_int32_t dqi_free_entry; /* Number of block with at least one free entry */
|
||||
uint32_t dqi_bgrace; /* Time before block soft limit becomes hard limit */
|
||||
uint32_t dqi_igrace; /* Time before inode soft limit becomes hard limit */
|
||||
uint32_t dqi_flags; /* Flags for quotafile (DQF_*) */
|
||||
uint32_t dqi_blocks; /* Number of blocks in file */
|
||||
uint32_t dqi_free_blk; /* Number of first free block in the list */
|
||||
uint32_t dqi_free_entry; /* Number of block with at least one free entry */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct v2r1_disk_dqblk {
|
||||
|
@ -106,7 +106,7 @@ static const char *utf8_to_wchar(const char *input, wchar_t *wc,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static u_int16_t *wchar_to_utf16(u_int16_t *output, wchar_t wc, size_t outsize)
|
||||
static uint16_t *wchar_to_utf16(uint16_t *output, wchar_t wc, size_t outsize)
|
||||
{
|
||||
if (wc <= 0xffff) {
|
||||
if (outsize == 0)
|
||||
@ -122,11 +122,11 @@ static u_int16_t *wchar_to_utf16(u_int16_t *output, wchar_t wc, size_t outsize)
|
||||
return output + 2;
|
||||
}
|
||||
|
||||
int utf8_to_utf16(u_int16_t *output, const char *input, size_t outsize,
|
||||
int utf8_to_utf16(uint16_t *output, const char *input, size_t outsize,
|
||||
size_t insize)
|
||||
{
|
||||
const char *inp = input;
|
||||
u_int16_t *outp = output;
|
||||
uint16_t *outp = output;
|
||||
wchar_t wc;
|
||||
|
||||
while ((size_t)(inp - input) < insize && *inp) {
|
||||
@ -145,7 +145,7 @@ int utf8_to_utf16(u_int16_t *output, const char *input, size_t outsize,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const u_int16_t *utf16_to_wchar(const u_int16_t *input, wchar_t *wc,
|
||||
static const uint16_t *utf16_to_wchar(const uint16_t *input, wchar_t *wc,
|
||||
size_t insize)
|
||||
{
|
||||
if ((le16_to_cpu(input[0]) & 0xfc00) == 0xd800) {
|
||||
@ -208,10 +208,10 @@ static char *wchar_to_utf8(char *output, wchar_t wc, size_t outsize)
|
||||
return output;
|
||||
}
|
||||
|
||||
int utf16_to_utf8(char *output, const u_int16_t *input, size_t outsize,
|
||||
int utf16_to_utf8(char *output, const uint16_t *input, size_t outsize,
|
||||
size_t insize)
|
||||
{
|
||||
const u_int16_t *inp = input;
|
||||
const uint16_t *inp = input;
|
||||
char *outp = output;
|
||||
wchar_t wc;
|
||||
|
||||
@ -231,7 +231,7 @@ int utf16_to_utf8(char *output, const u_int16_t *input, size_t outsize,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int log_base_2(u_int32_t num)
|
||||
int log_base_2(uint32_t num)
|
||||
{
|
||||
int ret = 0;
|
||||
if (num <= 0 || (num & (num - 1)) != 0)
|
||||
@ -532,7 +532,7 @@ unsigned int f2fs_max_file_offset(struct f2fs_inode *i)
|
||||
*/
|
||||
#define CRCPOLY_LE 0xedb88320
|
||||
|
||||
u_int32_t f2fs_cal_crc32(u_int32_t crc, void *buf, int len)
|
||||
uint32_t f2fs_cal_crc32(uint32_t crc, void *buf, int len)
|
||||
{
|
||||
int i;
|
||||
unsigned char *p = (unsigned char *)buf;
|
||||
@ -544,9 +544,9 @@ u_int32_t f2fs_cal_crc32(u_int32_t crc, void *buf, int len)
|
||||
return crc;
|
||||
}
|
||||
|
||||
int f2fs_crc_valid(u_int32_t blk_crc, void *buf, int len)
|
||||
int f2fs_crc_valid(uint32_t blk_crc, void *buf, int len)
|
||||
{
|
||||
u_int32_t cal_crc = 0;
|
||||
uint32_t cal_crc = 0;
|
||||
|
||||
cal_crc = f2fs_cal_crc32(F2FS_SUPER_MAGIC, buf, len);
|
||||
|
||||
@ -1212,7 +1212,7 @@ int f2fs_get_f2fs_info(void)
|
||||
c.devices[0].total_sectors = c.total_sectors;
|
||||
}
|
||||
if (c.total_sectors * c.sector_size >
|
||||
(u_int64_t)F2FS_MAX_SEGMENT * 2 * 1024 * 1024) {
|
||||
(uint64_t)F2FS_MAX_SEGMENT * 2 * 1024 * 1024) {
|
||||
MSG(0, "\tError: F2FS can support 16TB at most!!!\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ struct f2fs_configuration c;
|
||||
#include <sparse/sparse.h>
|
||||
struct sparse_file *f2fs_sparse_file;
|
||||
static char **blocks;
|
||||
u_int64_t blocks_count;
|
||||
uint64_t blocks_count;
|
||||
static char *zeroed_block;
|
||||
#endif
|
||||
|
||||
@ -663,7 +663,7 @@ int f2fs_init_sparse_file(void)
|
||||
return -1;
|
||||
|
||||
c.device_size = sparse_file_len(f2fs_sparse_file, 0, 0);
|
||||
c.device_size &= (~((u_int64_t)(F2FS_BLKSIZE - 1)));
|
||||
c.device_size &= (~((uint64_t)(F2FS_BLKSIZE - 1)));
|
||||
}
|
||||
|
||||
if (sparse_file_block_size(f2fs_sparse_file) != F2FS_BLKSIZE) {
|
||||
|
@ -204,7 +204,7 @@ int f2fs_get_zone_blocks(int i)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int f2fs_report_zone(int i, u_int64_t sector, void *blkzone)
|
||||
int f2fs_report_zone(int i, uint64_t sector, void *blkzone)
|
||||
{
|
||||
struct blk_zone *blkz = (struct blk_zone *)blkzone;
|
||||
struct blk_zone_report *rep;
|
||||
@ -239,9 +239,9 @@ int f2fs_report_zones(int j, report_zones_cb_t *report_zones_cb, void *opaque)
|
||||
struct blk_zone_report *rep;
|
||||
struct blk_zone *blkz;
|
||||
unsigned int i, n = 0;
|
||||
u_int64_t total_sectors = (dev->total_sectors * c.sector_size)
|
||||
uint64_t total_sectors = (dev->total_sectors * c.sector_size)
|
||||
>> SECTOR_SHIFT;
|
||||
u_int64_t sector = 0;
|
||||
uint64_t sector = 0;
|
||||
int ret = -1;
|
||||
|
||||
rep = malloc(F2FS_REPORT_ZONES_BUFSZ);
|
||||
@ -292,8 +292,8 @@ int f2fs_check_zones(int j)
|
||||
struct blk_zone_report *rep;
|
||||
struct blk_zone *blkz;
|
||||
unsigned int i, n = 0;
|
||||
u_int64_t total_sectors;
|
||||
u_int64_t sector;
|
||||
uint64_t total_sectors;
|
||||
uint64_t sector;
|
||||
int last_is_conv = 1;
|
||||
int ret = -1;
|
||||
|
||||
@ -445,8 +445,8 @@ int f2fs_reset_zones(int j)
|
||||
struct blk_zone_report *rep;
|
||||
struct blk_zone *blkz;
|
||||
struct blk_zone_range range;
|
||||
u_int64_t total_sectors;
|
||||
u_int64_t sector;
|
||||
uint64_t total_sectors;
|
||||
uint64_t sector;
|
||||
unsigned int i;
|
||||
int ret = -1;
|
||||
|
||||
@ -534,7 +534,7 @@ uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb)
|
||||
|
||||
#else
|
||||
|
||||
int f2fs_report_zone(int i, u_int64_t UNUSED(sector), void *UNUSED(blkzone))
|
||||
int f2fs_report_zone(int i, uint64_t UNUSED(sector), void *UNUSED(blkzone))
|
||||
{
|
||||
ERR_MSG("%d: Unsupported zoned block device\n", i);
|
||||
return -1;
|
||||
|
@ -201,18 +201,18 @@ static void verify_cur_segs(void)
|
||||
|
||||
static int f2fs_prepare_super_block(void)
|
||||
{
|
||||
u_int32_t blk_size_bytes;
|
||||
u_int32_t log_sectorsize, log_sectors_per_block;
|
||||
u_int32_t log_blocksize, log_blks_per_seg;
|
||||
u_int32_t segment_size_bytes, zone_size_bytes;
|
||||
u_int32_t sit_segments, nat_segments;
|
||||
u_int32_t blocks_for_sit, blocks_for_nat, blocks_for_ssa;
|
||||
u_int32_t total_valid_blks_available;
|
||||
u_int64_t zone_align_start_offset, diff;
|
||||
u_int64_t total_meta_zones, total_meta_segments;
|
||||
u_int32_t sit_bitmap_size, max_sit_bitmap_size;
|
||||
u_int32_t max_nat_bitmap_size, max_nat_segments;
|
||||
u_int32_t total_zones, avail_zones;
|
||||
uint32_t blk_size_bytes;
|
||||
uint32_t log_sectorsize, log_sectors_per_block;
|
||||
uint32_t log_blocksize, log_blks_per_seg;
|
||||
uint32_t segment_size_bytes, zone_size_bytes;
|
||||
uint32_t sit_segments, nat_segments;
|
||||
uint32_t blocks_for_sit, blocks_for_nat, blocks_for_ssa;
|
||||
uint32_t total_valid_blks_available;
|
||||
uint64_t zone_align_start_offset, diff;
|
||||
uint64_t total_meta_zones, total_meta_segments;
|
||||
uint32_t sit_bitmap_size, max_sit_bitmap_size;
|
||||
uint32_t max_nat_bitmap_size, max_nat_segments;
|
||||
uint32_t total_zones, avail_zones;
|
||||
enum quota_type qtype;
|
||||
int i;
|
||||
|
||||
@ -245,10 +245,10 @@ static int f2fs_prepare_super_block(void)
|
||||
set_sb(block_count, c.total_sectors >> log_sectors_per_block);
|
||||
|
||||
zone_align_start_offset =
|
||||
((u_int64_t) c.start_sector * DEFAULT_SECTOR_SIZE +
|
||||
((uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE +
|
||||
2 * F2FS_BLKSIZE + zone_size_bytes - 1) /
|
||||
zone_size_bytes * zone_size_bytes -
|
||||
(u_int64_t) c.start_sector * DEFAULT_SECTOR_SIZE;
|
||||
(uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE;
|
||||
|
||||
if (c.feature & cpu_to_le32(F2FS_FEATURE_RO))
|
||||
zone_align_start_offset = 8192;
|
||||
@ -365,7 +365,7 @@ static int f2fs_prepare_super_block(void)
|
||||
/* use cp_payload if free space of f2fs_checkpoint is not enough */
|
||||
if (max_sit_bitmap_size + max_nat_bitmap_size >
|
||||
MAX_BITMAP_SIZE_IN_CKPT) {
|
||||
u_int32_t diff = max_sit_bitmap_size +
|
||||
uint32_t diff = max_sit_bitmap_size +
|
||||
max_nat_bitmap_size -
|
||||
MAX_BITMAP_SIZE_IN_CKPT;
|
||||
set_sb(cp_payload, F2FS_BLK_ALIGN(diff));
|
||||
@ -608,15 +608,15 @@ static int f2fs_prepare_super_block(void)
|
||||
|
||||
static int f2fs_init_sit_area(void)
|
||||
{
|
||||
u_int32_t blk_size, seg_size;
|
||||
u_int32_t index = 0;
|
||||
u_int64_t sit_seg_addr = 0;
|
||||
u_int8_t *zero_buf = NULL;
|
||||
uint32_t blk_size, seg_size;
|
||||
uint32_t index = 0;
|
||||
uint64_t sit_seg_addr = 0;
|
||||
uint8_t *zero_buf = NULL;
|
||||
|
||||
blk_size = 1 << get_sb(log_blocksize);
|
||||
seg_size = (1 << get_sb(log_blocks_per_seg)) * blk_size;
|
||||
|
||||
zero_buf = calloc(sizeof(u_int8_t), seg_size);
|
||||
zero_buf = calloc(sizeof(uint8_t), seg_size);
|
||||
if(zero_buf == NULL) {
|
||||
MSG(1, "\tError: Calloc Failed for sit_zero_buf!!!\n");
|
||||
return -1;
|
||||
@ -642,15 +642,15 @@ static int f2fs_init_sit_area(void)
|
||||
|
||||
static int f2fs_init_nat_area(void)
|
||||
{
|
||||
u_int32_t blk_size, seg_size;
|
||||
u_int32_t index = 0;
|
||||
u_int64_t nat_seg_addr = 0;
|
||||
u_int8_t *nat_buf = NULL;
|
||||
uint32_t blk_size, seg_size;
|
||||
uint32_t index = 0;
|
||||
uint64_t nat_seg_addr = 0;
|
||||
uint8_t *nat_buf = NULL;
|
||||
|
||||
blk_size = 1 << get_sb(log_blocksize);
|
||||
seg_size = (1 << get_sb(log_blocks_per_seg)) * blk_size;
|
||||
|
||||
nat_buf = calloc(sizeof(u_int8_t), seg_size);
|
||||
nat_buf = calloc(sizeof(uint8_t), seg_size);
|
||||
if (nat_buf == NULL) {
|
||||
MSG(1, "\tError: Calloc Failed for nat_zero_blk!!!\n");
|
||||
return -1;
|
||||
@ -678,11 +678,11 @@ static int f2fs_write_check_point_pack(void)
|
||||
{
|
||||
struct f2fs_summary_block *sum = NULL;
|
||||
struct f2fs_journal *journal;
|
||||
u_int32_t blk_size_bytes;
|
||||
u_int32_t nat_bits_bytes, nat_bits_blocks;
|
||||
uint32_t blk_size_bytes;
|
||||
uint32_t nat_bits_bytes, nat_bits_blocks;
|
||||
unsigned char *nat_bits = NULL, *empty_nat_bits;
|
||||
u_int64_t cp_seg_blk = 0;
|
||||
u_int32_t crc = 0, flags;
|
||||
uint64_t cp_seg_blk = 0;
|
||||
uint32_t crc = 0, flags;
|
||||
unsigned int i;
|
||||
char *cp_payload = NULL;
|
||||
char *sum_compact, *sum_compact_p;
|
||||
@ -1116,7 +1116,7 @@ free_cp:
|
||||
static int f2fs_write_super_block(void)
|
||||
{
|
||||
int index;
|
||||
u_int8_t *zero_buff;
|
||||
uint8_t *zero_buff;
|
||||
|
||||
zero_buff = calloc(F2FS_BLKSIZE, 1);
|
||||
if (zero_buff == NULL) {
|
||||
@ -1143,11 +1143,11 @@ static int f2fs_write_super_block(void)
|
||||
static int f2fs_discard_obsolete_dnode(void)
|
||||
{
|
||||
struct f2fs_node *raw_node;
|
||||
u_int64_t next_blkaddr = 0, offset;
|
||||
uint64_t next_blkaddr = 0, offset;
|
||||
u64 end_blkaddr = (get_sb(segment_count_main) <<
|
||||
get_sb(log_blocks_per_seg)) + get_sb(main_blkaddr);
|
||||
u_int64_t start_inode_pos = get_sb(main_blkaddr);
|
||||
u_int64_t last_inode_pos;
|
||||
uint64_t start_inode_pos = get_sb(main_blkaddr);
|
||||
uint64_t last_inode_pos;
|
||||
|
||||
if (c.zoned_mode || c.feature & cpu_to_le32(F2FS_FEATURE_RO))
|
||||
return 0;
|
||||
@ -1198,8 +1198,8 @@ static int f2fs_discard_obsolete_dnode(void)
|
||||
static int f2fs_write_root_inode(void)
|
||||
{
|
||||
struct f2fs_node *raw_node = NULL;
|
||||
u_int64_t blk_size_bytes, data_blk_nor;
|
||||
u_int64_t main_area_node_seg_blk_offset = 0;
|
||||
uint64_t blk_size_bytes, data_blk_nor;
|
||||
uint64_t main_area_node_seg_blk_offset = 0;
|
||||
|
||||
raw_node = calloc(F2FS_BLKSIZE, 1);
|
||||
if (raw_node == NULL) {
|
||||
@ -1358,8 +1358,8 @@ static int f2fs_write_default_quota(int qtype, unsigned int blkaddr,
|
||||
static int f2fs_write_qf_inode(int qtype, int offset)
|
||||
{
|
||||
struct f2fs_node *raw_node = NULL;
|
||||
u_int64_t data_blk_nor;
|
||||
u_int64_t main_area_node_seg_blk_offset = 0;
|
||||
uint64_t data_blk_nor;
|
||||
uint64_t main_area_node_seg_blk_offset = 0;
|
||||
__le32 raw_id;
|
||||
int i;
|
||||
|
||||
@ -1421,7 +1421,7 @@ static int f2fs_write_qf_inode(int qtype, int offset)
|
||||
static int f2fs_update_nat_root(void)
|
||||
{
|
||||
struct f2fs_nat_block *nat_blk = NULL;
|
||||
u_int64_t nat_seg_blk_offset = 0;
|
||||
uint64_t nat_seg_blk_offset = 0;
|
||||
enum quota_type qtype;
|
||||
int i;
|
||||
|
||||
@ -1517,7 +1517,7 @@ static block_t f2fs_add_default_dentry_lpf(void)
|
||||
static int f2fs_write_lpf_inode(void)
|
||||
{
|
||||
struct f2fs_node *raw_node;
|
||||
u_int64_t blk_size_bytes, main_area_node_seg_blk_offset;
|
||||
uint64_t blk_size_bytes, main_area_node_seg_blk_offset;
|
||||
block_t data_blk_nor;
|
||||
int err = 0;
|
||||
|
||||
@ -1611,7 +1611,7 @@ exit:
|
||||
static int f2fs_add_default_dentry_root(void)
|
||||
{
|
||||
struct f2fs_dentry_block *dent_blk = NULL;
|
||||
u_int64_t data_blk_offset = 0;
|
||||
uint64_t data_blk_offset = 0;
|
||||
|
||||
dent_blk = calloc(F2FS_BLKSIZE, 1);
|
||||
if(dent_blk == NULL) {
|
||||
|
@ -255,7 +255,7 @@ static void f2fs_parse_options(int argc, char *argv[])
|
||||
break;
|
||||
case 'S':
|
||||
c.device_size = atoll(optarg);
|
||||
c.device_size &= (~((u_int64_t)(F2FS_BLKSIZE - 1)));
|
||||
c.device_size &= (~((uint64_t)(F2FS_BLKSIZE - 1)));
|
||||
c.sparse_mode = 1;
|
||||
break;
|
||||
case 'z':
|
||||
|
@ -52,7 +52,7 @@ static int trim_device(int i)
|
||||
unsigned long long range[2];
|
||||
struct stat *stat_buf;
|
||||
struct device_info *dev = c.devices + i;
|
||||
u_int64_t bytes = dev->total_sectors * dev->sector_size;
|
||||
uint64_t bytes = dev->total_sectors * dev->sector_size;
|
||||
int fd = dev->fd;
|
||||
|
||||
stat_buf = malloc(sizeof(struct stat));
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
extern struct f2fs_configuration c;
|
||||
|
||||
int f2fs_trim_device(int, u_int64_t);
|
||||
int f2fs_trim_device(int, uint64_t);
|
||||
int f2fs_trim_devices(void);
|
||||
int f2fs_format_device(void);
|
||||
|
@ -30,10 +30,10 @@
|
||||
# define UNUSED(x) x
|
||||
#endif
|
||||
|
||||
typedef u_int64_t u64;
|
||||
typedef u_int32_t u32;
|
||||
typedef u_int16_t u16;
|
||||
typedef u_int8_t u8;
|
||||
typedef uint64_t u64;
|
||||
typedef uint32_t u32;
|
||||
typedef uint16_t u16;
|
||||
typedef uint8_t u8;
|
||||
|
||||
#ifndef HAVE_LINUX_TYPES_H
|
||||
typedef u8 __u8;
|
||||
|
Loading…
Reference in New Issue
Block a user