Skip to contentSkip to conversation

f2fs_io: {set, clear}flags: support immutable flag correctly

PATCH New Chao Yu via Linux-f2fs-devel 1 participant 2 messages Oct 18, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 f2fs_io: {set, clear}flags: support immutable flag correctly

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.

---
 man/f2fs_io.8           | 6 +++---
 tools/f2fs_io/f2fs_io.c | 9 ++++++---
 2 files changed, 9 insertions(+), 6 deletions(-)
man/f2fs_io.8 +3 -3
index b9c9dc8..e58244c 100644
@@ -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
tools/f2fs_io/f2fs_io.c +6 -3
index a7b593a..00bfc7a 100644
@@ -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]);
Signature · 8 lines
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#1 lore raw

PATCH 2/2 f2fs_io: {set, clear}flags: support nocow flag

This patch supports to set or clear nocow flag in f2fs_io

---
 man/f2fs_io.8           |  4 ++--
 tools/f2fs_io/f2fs_io.c | 10 ++++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)
man/f2fs_io.8 +2 -2
index e58244c..5041c1b 100644
@@ -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, nocompression, and immutable.
+compression, nocompression, immutable, and nocow.
 .TP
 \fBclearflags\fR \fI[flag] [file]\fR
 Clear the specified flag on the target file, which can be compression,
- nocompression and immutable.
+ nocompression, immutable, and nocow.
 .TP
 \fBshutdown\fR \fIshutdown filesystem\fR
 Freeze and stop all IOs for the file system mounted on
tools/f2fs_io/f2fs_io.c +8 -2
index 00bfc7a..76f8e84 100644
@@ -291,7 +291,8 @@ static void do_getflags(int argc, char **argv, const struct cmd_desc *cmd)
 "  casefold\n"							\
 "  compression\n"						\
 "  nocompression\n"						\
-"  immutable\n"
+"  immutable\n"							\
+"  nocow\n"
 
 static void do_setflags(int argc, char **argv, const struct cmd_desc *cmd)
 {
@@ -319,6 +320,8 @@ static void do_setflags(int argc, char **argv, const struct cmd_desc *cmd)
 		flag |= FS_NOCOMP_FL;
 	else if (!strcmp(argv[1], "immutable"))
 		flag |= FS_IMMUTABLE_FL;
+	else if (!strcmp(argv[1], "nocow"))
+		flag |= FS_NOCOW_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,7 +335,8 @@ static void do_setflags(int argc, char **argv, const struct cmd_desc *cmd)
 "flag can be\n"							\
 "  compression\n"						\
 "  nocompression\n"						\
-"  immutable\n"
+"  immutable\n"							\
+"  nocow\n"
 
 static void do_clearflags(int argc, char **argv, const struct cmd_desc *cmd)
 {
@@ -358,6 +362,8 @@ static void do_clearflags(int argc, char **argv, const struct cmd_desc *cmd)
 		flag &= ~FS_NOCOMP_FL;
 	else if (!strcmp(argv[1], "immutable"))
 		flag &= ~FS_IMMUTABLE_FL;
+	else if (!strcmp(argv[1], "nocow"))
+		flag &= ~FS_NOCOW_FL;
 
 	ret = ioctl(fd, F2FS_IOC_SETFLAGS, &flag);
 	printf("clear a flag on %s ret=%d, flags=%s\n", argv[2], ret, argv[1]);
Signature · 8 lines
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel