On 2017/10/31 15:51, Chao Yu wrote:
On 2017/10/31 9:38, Sheng Yong wrote:
This patch introduces dump_xattr to create xattrs for dumped files.

Signed-off-by: Sheng Yong <shengyo...@huawei.com>
---
  fsck/dump.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
  1 file changed, 60 insertions(+), 3 deletions(-)

diff --git a/fsck/dump.c b/fsck/dump.c
index 90fd073..01889fd 100644
--- a/fsck/dump.c
+++ b/fsck/dump.c
@@ -11,6 +11,9 @@
  #include <inttypes.h>
#include "fsck.h"
+#include "xattr.h"
+#include <attr/xattr.h>
+#include <linux/xattr.h>
  #include <locale.h>
#define BUF_SZ 80
@@ -310,15 +313,67 @@ static void dump_node_blk(struct f2fs_sb_info *sbi, int 
ntype,
        free(node_blk);
  }
[...]
+               DBG(1, "fd %d xattr_name %s\n", c.dump_fd, xattr_name);
+               ret = fsetxattr(c.dump_fd, xattr_name, value,
+                               le16_to_cpu(ent->e_value_size), XATTR_CREATE);
+               if (ret)

if (ret == -EEXIST)
        fsetxattr(,,,,XATTR_REPLACE)?
Hmm, there should be no 2 xattrs with the same name in one fileļ¼Œ right? :)

thanks,
Sheng

Thanks,

+                       MSG(0, "XATTR index 0x%x set xattr failed error %d\n",
+                           ent->e_name_index, errno);
+
+               free(name);
+       }
+
+       free(xattr);
+}
+
  static void dump_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
                                        struct f2fs_node *node_blk)
  {
        u32 i = 0;
        u64 ofs = 0;
- /* TODO: need to dump xattr */
-
-       if((node_blk->i.i_inline & F2FS_INLINE_DATA)){
+       if((node_blk->i.i_inline & F2FS_INLINE_DATA)) {
                DBG(3, "ino[0x%x] has inline data!\n", nid);
                /* recover from inline data */
                dev_write_dump(((unsigned char *)node_blk) + INLINE_DATA_OFFSET,
@@ -345,6 +400,8 @@ static void dump_inode_blk(struct f2fs_sb_info *sbi, u32 
nid,
                else
                        ASSERT(0);
        }
+
+       dump_xattr(sbi, node_blk);
  }
static void dump_file(struct f2fs_sb_info *sbi, struct node_info *ni,



.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to