Hand over immutable flag clearing functionality from setflags to
clearflags, since the flag name is immutable rather than noimmutable.

And support setting functionality in subcommand setflags.

Signed-off-by: Chao Yu <c...@kernel.org>
---
 man/f2fs_io.8           | 6 +++---
 tools/f2fs_io/f2fs_io.c | 9 ++++++---
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/man/f2fs_io.8 b/man/f2fs_io.8
index b9c9dc8..e58244c 100644
--- a/man/f2fs_io.8
+++ b/man/f2fs_io.8
@@ -16,11 +16,11 @@ Get the flags associated with the specified file.
 .TP
 \fBsetflags\fR \fI[flag] [file]\fR
 Set an f2fs file on specified file.  The flag can be casefold,
-compression, and nocompression.
+compression, nocompression, and immutable.
 .TP
 \fBclearflags\fR \fI[flag] [file]\fR
-Clear the specified flag on the target file, which can be compression
-and nocompression.
+Clear the specified flag on the target file, which can be compression,
+ nocompression and immutable.
 .TP
 \fBshutdown\fR \fIshutdown filesystem\fR
 Freeze and stop all IOs for the file system mounted on
diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index a7b593a..00bfc7a 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -291,7 +291,7 @@ static void do_getflags(int argc, char **argv, const struct 
cmd_desc *cmd)
 "  casefold\n"                                                 \
 "  compression\n"                                              \
 "  nocompression\n"                                            \
-"  noimmutable\n"
+"  immutable\n"
 
 static void do_setflags(int argc, char **argv, const struct cmd_desc *cmd)
 {
@@ -317,8 +317,8 @@ static void do_setflags(int argc, char **argv, const struct 
cmd_desc *cmd)
                flag |= FS_COMPR_FL;
        else if (!strcmp(argv[1], "nocompression"))
                flag |= FS_NOCOMP_FL;
-       else if (!strcmp(argv[1], "noimmutable"))
-               flag &= ~FS_IMMUTABLE_FL;
+       else if (!strcmp(argv[1], "immutable"))
+               flag |= FS_IMMUTABLE_FL;
 
        ret = ioctl(fd, F2FS_IOC_SETFLAGS, &flag);
        printf("set a flag on %s ret=%d, flags=%s\n", argv[2], ret, argv[1]);
@@ -332,6 +332,7 @@ static void do_setflags(int argc, char **argv, const struct 
cmd_desc *cmd)
 "flag can be\n"                                                        \
 "  compression\n"                                              \
 "  nocompression\n"                                            \
+"  immutable\n"
 
 static void do_clearflags(int argc, char **argv, const struct cmd_desc *cmd)
 {
@@ -355,6 +356,8 @@ static void do_clearflags(int argc, char **argv, const 
struct cmd_desc *cmd)
                flag &= ~FS_COMPR_FL;
        else if (!strcmp(argv[1], "nocompression"))
                flag &= ~FS_NOCOMP_FL;
+       else if (!strcmp(argv[1], "immutable"))
+               flag &= ~FS_IMMUTABLE_FL;
 
        ret = ioctl(fd, F2FS_IOC_SETFLAGS, &flag);
        printf("clear a flag on %s ret=%d, flags=%s\n", argv[2], ret, argv[1]);
-- 
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to