On 2024/9/6 10:06, Hongzhen Luo wrote:

On 2024/9/5 20:02, Huang Jianan wrote:
On 2024/9/5 19:37, Hongzhen Luo wrote:
The current `fsck --extract` does not support exporting the extended
attributes of files. This patch adds `--xattrs` option to dump the
extended attributes, as well as the `--no-xattrs` option to not dump
the extended attributes.

Signed-off-by: Hongzhen Luo <hongz...@linux.alibaba.com>
---
v4: Optimize the error messages and code.
v3: 
https://lore.kernel.org/all/20240903113729.3539578-1-hongz...@linux.alibaba.com/
v2: 
https://lore.kernel.org/all/20240903085643.3393012-1-hongz...@linux.alibaba.com/
v1: 
https://lore.kernel.org/all/20240903073517.3311407-1-hongz...@linux.alibaba.com/
---
   fsck/main.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++---
   1 file changed, 79 insertions(+), 4 deletions(-)

diff --git a/fsck/main.c b/fsck/main.c
index 28f1e7e..183665c 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -9,6 +9,7 @@
   #include <utime.h>
   #include <unistd.h>
   #include <sys/stat.h>
+#include <sys/xattr.h>
   #include "erofs/print.h"
   #include "erofs/compress.h"
   #include "erofs/decompress.h"
@@ -31,6 +32,7 @@ struct erofsfsck_cfg {
          bool overwrite;
          bool preserve_owner;
          bool preserve_perms;
+       bool dump_xattrs;
   };
   static struct erofsfsck_cfg fsckcfg;

@@ -48,6 +50,8 @@ static struct option long_options[] = {
          {"no-preserve-owner", no_argument, 0, 10},
          {"no-preserve-perms", no_argument, 0, 11},
          {"offset", required_argument, 0, 12},
+       {"xattrs", no_argument, 0, 13},
+       {"no-xattrs", no_argument, 0, 14},
          {0, 0, 0, 0},
   };

@@ -98,6 +102,8 @@ static void usage(int argc, char **argv)
                  " --extract[=X]          check if all files are well encoded, 
optionally\n"
                  "                        extract to X\n"
                  " --offset=#             skip # bytes at the beginning of 
IMAGE\n"
+               " --xattrs               dump extended attributes (default)\n"
+               " --no-xattrs            do not dump extended attributes\n"
How about:

" --[no-]xattrs  whether to dump extended attributes (default on)\n"

To keep the same style as the other switch options.

Thanks,
Jianan

Yes, that would be more concise. I'll send a new version soon.

Yes, that is a good idea, please help send a version
so I could merge this work.

Thanks,
Gao Xiang


Thanks,

Hongzhen

Reply via email to