aboutsummaryrefslogtreecommitdiff
path: root/fsck/f2fs.h
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2015-12-09 16:18:44 -0800
committerJaegeuk Kim <jaegeuk@kernel.org>2016-04-18 21:11:26 -0400
commit603f8f9d3628e8b81fea301e5f543a9f0b0d902d (patch)
tree903a3a88d22de833be6c852559f74712f079df7d /fsck/f2fs.h
parentd3be08825e9f5ebe8e9bf9da9a9b77cefd9b525d (diff)
downloadf2fs-tools-603f8f9d3628e8b81fea301e5f543a9f0b0d902d.tar.gz
sload.f2fs: support loading files into partition directly
This patch implements loading files into the existing partition. For example, # sload.f2fs -f ./ /dev/sdb1 Then, all the directories and files will be loaded into /dev/sdb1. By default, newly files should have inline_data and inline_xattr, if possible. Signed-off-by: Hou Pengyang <houpengyang@huawei.com> Signed-off-by: Liu Shuoran <liushuoran@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fsck/f2fs.h')
-rw-r--r--fsck/f2fs.h77
1 files changed, 76 insertions, 1 deletions
diff --git a/fsck/f2fs.h b/fsck/f2fs.h
index 4b3c666..39ff161 100644
--- a/fsck/f2fs.h
+++ b/fsck/f2fs.h
@@ -60,6 +60,7 @@ struct f2fs_nm_info {
char *nat_bitmap;
int bitmap_size;
+ char *nid_bitmap;
};
struct seg_entry {
@@ -124,6 +125,44 @@ struct f2fs_sm_info {
unsigned int ovp_segments;
};
+struct f2fs_dentry_ptr {
+ struct inode *inode;
+ u8 *bitmap;
+ struct f2fs_dir_entry *dentry;
+ __u8 (*filename)[F2FS_SLOT_LEN];
+ int max;
+};
+
+struct dentry {
+ char *path;
+ char *full_path;
+ const u8 *name;
+ int len;
+ char *link;
+ unsigned long size;
+ u8 file_type;
+ u16 mode;
+ u16 uid;
+ u16 gid;
+ u32 *inode;
+ u32 mtime;
+ char *secon;
+ uint64_t capabilities;
+ nid_t ino;
+ nid_t pino;
+};
+
+/* different from dnode_of_data in kernel */
+struct dnode_of_data {
+ struct f2fs_node *inode_blk; /* inode page */
+ struct f2fs_node *node_blk; /* cached direct node page */
+ nid_t nid;
+ unsigned int ofs_in_node;
+ block_t data_blkaddr;
+ block_t node_blkaddr;
+ int idirty, ndirty;
+};
+
struct f2fs_sb_info {
struct f2fs_fsck *fsck;
@@ -160,6 +199,7 @@ struct f2fs_sb_info {
u32 s_next_generation; /* for NFS support */
unsigned int cur_victim_sec; /* current victim section num */
+ u32 free_segments;
};
static inline struct f2fs_super_block *F2FS_RAW_SUPER(struct f2fs_sb_info *sbi)
@@ -313,7 +353,6 @@ static inline block_t sum_blk_addr(struct f2fs_sb_info *sbi, int base, int type)
- (base + 1) + type;
}
-
#define nats_in_cursum(jnl) (le16_to_cpu(jnl->n_nats))
#define sits_in_cursum(jnl) (le16_to_cpu(jnl->n_sits))
@@ -397,6 +436,42 @@ static inline void node_info_from_raw_nat(struct node_info *ni,
ni->version = raw_nat->version;
}
+static inline void set_summary(struct f2fs_summary *sum, nid_t nid,
+ unsigned int ofs_in_node, unsigned char version)
+{
+ sum->nid = cpu_to_le32(nid);
+ sum->ofs_in_node = cpu_to_le16(ofs_in_node);
+ sum->version = version;
+}
+
+#define S_SHIFT 12
+static unsigned char f2fs_type_by_mode[S_IFMT >> S_SHIFT] = {
+ [S_IFREG >> S_SHIFT] = F2FS_FT_REG_FILE,
+ [S_IFDIR >> S_SHIFT] = F2FS_FT_DIR,
+ [S_IFCHR >> S_SHIFT] = F2FS_FT_CHRDEV,
+ [S_IFBLK >> S_SHIFT] = F2FS_FT_BLKDEV,
+ [S_IFIFO >> S_SHIFT] = F2FS_FT_FIFO,
+ [S_IFSOCK >> S_SHIFT] = F2FS_FT_SOCK,
+ [S_IFLNK >> S_SHIFT] = F2FS_FT_SYMLINK,
+};
+
+static inline void set_de_type(struct f2fs_dir_entry *de, umode_t mode)
+{
+ de->file_type = f2fs_type_by_mode[(mode & S_IFMT) >> S_SHIFT];
+}
+
+static inline void *inline_xattr_addr(struct f2fs_inode *inode)
+{
+ return (void *)&(inode->i_addr[DEF_ADDRS_PER_INODE_INLINE_XATTR]);
+}
+
+static inline int inline_xattr_size(struct f2fs_inode *inode)
+{
+ if (inode->i_inline & F2FS_INLINE_XATTR)
+ return F2FS_INLINE_XATTR_ADDRS << 2;
+ return 0;
+}
+
extern int lookup_nat_in_journal(struct f2fs_sb_info *sbi, u32 nid, struct f2fs_nat_entry *ne);
#define IS_SUM_NODE_SEG(footer) (footer.entry_type == SUM_TYPE_NODE)
#define IS_SUM_DATA_SEG(footer) (footer.entry_type == SUM_TYPE_DATA)