* removed unused includes.
* removed unused parameters.
* Fixed a bunch of warnings around:
int i;
if (i < some_uint) ...
and
u32 x;
...
if (x < 0) return error;
* Protect BLKDISCARD usage if it is not available.
Change-Id: Iede035b1beb2df01c961589a69aff47a5258ecd2
Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
#include "fsck.h"
char *tree_mark;
-int tree_mark_size = 256;
+uint32_t tree_mark_size = 256;
static int add_into_hard_link_list(struct f2fs_sb_info *sbi, u32 nid, u32 link_cnt)
{
case TYPE_INDIRECT_NODE:
ret = fsck_chk_idnode_blk(sbi,
inode,
- nid,
ftype,
node_blk,
blk_cnt);
case TYPE_DOUBLE_INDIRECT_NODE:
ret = fsck_chk_didnode_blk(sbi,
inode,
- nid,
ftype,
node_blk,
blk_cnt);
enum NODE_TYPE ntype;
u32 i_links = le32_to_cpu(node_blk->i.i_links);
u64 i_blocks = le64_to_cpu(node_blk->i.i_blocks);
- int idx = 0;
+ unsigned int idx = 0;
int ret = 0;
ASSERT(node_blk->footer.nid == node_blk->footer.ino);
if (le32_to_cpu(node_blk->i.i_addr[idx]) != 0) {
*blk_cnt = *blk_cnt + 1;
ret = fsck_chk_data_blk(sbi,
- &node_blk->i,
le32_to_cpu(node_blk->i.i_addr[idx]),
&child_cnt,
&child_files,
continue;
*blk_cnt = *blk_cnt + 1;
fsck_chk_data_blk(sbi,
- inode,
le32_to_cpu(node_blk->dn.addr[idx]),
&child_cnt,
&child_files,
int fsck_chk_idnode_blk(struct f2fs_sb_info *sbi,
struct f2fs_inode *inode,
- u32 nid,
enum FILE_TYPE ftype,
struct f2fs_node *node_blk,
u32 *blk_cnt)
int fsck_chk_didnode_blk(struct f2fs_sb_info *sbi,
struct f2fs_inode *inode,
- u32 nid,
enum FILE_TYPE ftype,
struct f2fs_node *node_blk,
u32 *blk_cnt)
int last_de = 0;
int next_idx = 0;
int name_len;
- int i;
+ unsigned int i;
int bit_offset;
if (config.dbg_lv != -1)
}
int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi,
- struct f2fs_inode *inode,
u32 blk_addr,
u32 *child_cnt,
u32 *child_files,
}
int fsck_chk_data_blk(struct f2fs_sb_info *sbi,
- struct f2fs_inode *inode,
u32 blk_addr,
u32 *child_cnt,
u32 *child_files,
if (ftype == F2FS_FT_DIR) {
fsck_chk_dentry_blk(sbi,
- inode,
blk_addr,
child_cnt,
child_files,
int fsck_verify(struct f2fs_sb_info *sbi)
{
- int i = 0;
+ unsigned int i = 0;
int ret = 0;
u32 nr_unref_nid = 0;
struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
extern int fsck_chk_idnode_blk(struct f2fs_sb_info *sbi,
struct f2fs_inode *inode,
- u32 nid,
enum FILE_TYPE ftype,
struct f2fs_node *node_blk,
u32 *blk_cnt);
extern int fsck_chk_didnode_blk(struct f2fs_sb_info *sbi,
struct f2fs_inode *inode,
- u32 nid,
enum FILE_TYPE ftype,
struct f2fs_node *node_blk,
u32 *blk_cnt);
extern int fsck_chk_data_blk(struct f2fs_sb_info *sbi,
- struct f2fs_inode *inode,
u32 blk_addr,
u32 *child_cnt,
u32 *child_files,
u8 ver);
extern int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi,
- struct f2fs_inode *inode,
u32 blk_addr,
u32 *child_cnt,
u32 *child_files,
int end_sit;
int start_ssa;
int end_ssa;
- u32 blk_addr;
+ int32_t blk_addr;
};
extern void sit_dump(struct f2fs_sb_info *sbi, int start_sit, int end_sit);
#include <libgen.h>
struct f2fs_fsck gfsck = {
- .sbi.fsck = &gfsck,
+ .sbi = { .fsck = &gfsck, },
};
void fsck_usage()
void print_inode_info(struct f2fs_inode *inode)
{
- int i = 0;
+ unsigned int i = 0;
int namelen = le32_to_cpu(inode->i_namelen);
DISP_u32(inode, i_mode);
return 0;
}
-void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified)
+void reset_curseg(struct f2fs_sb_info *sbi, int type)
{
struct curseg_info *curseg = CURSEG_I(sbi, type);
segno = le32_to_cpu(ckpt->cur_data_segno[i]);
blk_off = le16_to_cpu(ckpt->cur_data_blkoff[i]);
curseg->next_segno = segno;
- reset_curseg(sbi, i, 0);
+ reset_curseg(sbi, i);
curseg->alloc_type = ckpt->alloc_type[i];
curseg->next_blkoff = blk_off;
struct f2fs_summary *sum_entry;
void *page;
block_t addr;
- int i;
+ unsigned int i;
page = malloc(PAGE_SIZE);
if (!page)
if (IS_NODESEG(type)) {
if (is_set_ckpt_flags(ckpt, CP_UMOUNT_FLAG)) {
struct f2fs_summary *sum_entry = &sum_blk->entries[0];
- int i;
+ unsigned int i;
for (i = 0; i < sbi->blocks_per_seg; i++, sum_entry++) {
/* do not change original value */
#if 0
curseg = CURSEG_I(sbi, type);
memcpy(curseg->sum_blk, sum_blk, PAGE_CACHE_SIZE);
curseg->next_segno = segno;
- reset_curseg(sbi, type, 0);
+ reset_curseg(sbi, type);
curseg->alloc_type = ckpt->alloc_type[type];
curseg->next_blkoff = blk_off;
free(sum_blk);
}
void check_block_count(struct f2fs_sb_info *sbi,
- int segno, struct f2fs_sit_entry *raw_sit)
+ unsigned int segno, struct f2fs_sit_entry *raw_sit)
{
struct f2fs_sm_info *sm_info = SM_I(sbi);
unsigned int end_segno = sm_info->segment_count - 1;
int valid_blocks = 0;
- int i;
+ unsigned int i;
/* check segment usage */
ASSERT(GET_SIT_VBLOCKS(raw_sit) <= sbi->blocks_per_seg);
{
struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
struct f2fs_sm_info *sm_i = SM_I(sbi);
- int segno = 0, j = 0;
+ unsigned int segno = 0;
+ int j = 0;
char *ptr = NULL;
u32 sum_vblocks = 0;
pgoff_t block_off;
pgoff_t block_addr;
int seg_off;
- int ret, i;
+ int ret;
+ unsigned int i;
nat_block = (struct f2fs_nat_block *)calloc(BLOCK_SZ, 1);
struct sit_info *sit_i = SIT_I(sbi);
struct f2fs_sm_info *sm_i = SM_I(sbi);
struct f2fs_nm_info *nm_i = NM_I(sbi);
- int i;
+ unsigned int i;
/* free nm_info */
free(nm_i->nat_bitmap);
#include <inttypes.h>
#include <linux/types.h>
#include <sys/types.h>
-#include <endian.h>
-#include <byteswap.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#define POISON_POINTER_DELTA 0
-#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
-#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
+#define LIST_POISON1 ((void *) (0x00100100 + POISON_POINTER_DELTA))
+#define LIST_POISON2 ((void *) (0x00200200 + POISON_POINTER_DELTA))
+#if !defined(offsetof)
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
#include <sys/mount.h>
#include <sys/ioctl.h>
#include <linux/hdreg.h>
-#include <linux/fs.h>
#include <f2fs_fs.h>
int f2fs_get_device_info(struct f2fs_configuration *c)
{
int32_t fd = 0;
- int32_t sector_size;
+ uint32_t sector_size;
struct stat stat_buf;
struct hd_geometry geom;
#include <sys/mount.h>
#include <sys/ioctl.h>
#include <linux/hdreg.h>
-#include <linux/fs.h>
#include <f2fs_fs.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <time.h>
-#include <linux/fs.h>
#include <uuid/uuid.h>
#include "f2fs_fs.h"
log_blks_per_seg = log_base_2(config.blks_per_seg);
super_block.log_sectorsize = cpu_to_le32(log_sectorsize);
-
- if (log_sectorsize < 0) {
- MSG(1, "\tError: Failed to get the sector size: %u!\n",
- config.sector_size);
- return -1;
- }
-
super_block.log_sectors_per_block = cpu_to_le32(log_sectors_per_block);
- if (log_sectors_per_block < 0) {
- MSG(1, "\tError: Failed to get sectors per block: %u!\n",
- config.sectors_per_blk);
- return -1;
- }
-
super_block.log_blocksize = cpu_to_le32(log_blocksize);
super_block.log_blocks_per_seg = cpu_to_le32(log_blks_per_seg);
- if (log_blks_per_seg < 0) {
- MSG(1, "\tError: Failed to get block per segment: %u!\n",
- config.blks_per_seg);
- return -1;
- }
-
super_block.segs_per_sec = cpu_to_le32(config.segs_per_sec);
super_block.secs_per_zone = cpu_to_le32(config.secs_per_zone);
blk_size_bytes = 1 << log_blocksize;
#include <sys/stat.h>
#include <sys/mount.h>
#include <time.h>
-#include <linux/fs.h>
+//#include <linux/fs.h>
#include <uuid/uuid.h>
#include "f2fs_fs.h"
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
-#include <linux/fs.h>
#include "f2fs_fs.h"
return -1;
}
+#if defined(BLKDISCARD)
MSG(0, "Info: Discarding device\n");
if (S_ISREG(stat_buf.st_mode))
return 0;
MSG(0, "Info: This device doesn't support TRIM\n");
} else
return -1;
+#endif
return 0;
}
#include <libgen.h>
#include <linux/hdreg.h>
#include <linux/types.h>
-#include <linux/fs.h>
+// #include <linux/fs.h>
struct file_ext {
__u32 f_pos;