[PATCH] chattr: Fix the problem that the chattr cannot add -s attributes to the file.
ITcxk
chunhui_r at foxmail.com
Thu Oct 12 00:29:28 UTC 2023
The chattr command cannot add the -s attribute to the file normally. When you enter "chattr +s testfile",
the content of --help will be displayed directly.
The reason is that commit 83dff7f43154cd41e4d2e5831060a2d2ddc6596e ("lsattr: support more ext2 flags")
changed the enumeration variable order, resulting in an error in the offset obtained in e2fs_lib.h.
Solution 1: Change the offset
The chattr command cannot add the -s attribute to the file normally.
Fixes: 83dff7f43154cd41e4d2e5831060a2d2ddc6596e ("lsattr: support more ext2 flags")
Signed-off-by: ITcxk <chunhui_r at foxmail.com>
---
e2fsprogs/e2fs_lib.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/e2fsprogs/e2fs_lib.h b/e2fsprogs/e2fs_lib.h
index bab447a94..c6b90d389 100644
--- a/e2fsprogs/e2fs_lib.h
+++ b/e2fsprogs/e2fs_lib.h
@@ -21,11 +21,11 @@ extern const char e2attr_flags_sname[];
/* If you plan to ENABLE_COMPRESSION, see e2fs_lib.c and chattr.c - */
/* make sure that chattr doesn't accept bad options! */
#ifdef ENABLE_COMPRESSION
-#define e2attr_flags_value_chattr (&e2attr_flags_value[5])
-#define e2attr_flags_sname_chattr (&e2attr_flags_sname[5])
+#define e2attr_flags_value_chattr (&e2attr_flags_value[3])
+#define e2attr_flags_sname_chattr (&e2attr_flags_sname[3])
#else
-#define e2attr_flags_value_chattr (&e2attr_flags_value[1])
-#define e2attr_flags_sname_chattr (&e2attr_flags_sname[1])
+#define e2attr_flags_value_chattr (&e2attr_flags_value[0])
+#define e2attr_flags_sname_chattr (&e2attr_flags_sname[0])
#endif
POP_SAVED_FUNCTION_VISIBILITY
--
2.37.0 (Apple Git-136)
Solution 2: Replace the devil's numbers
The chattr command cannot add the -s attribute to the file normally.
Fixes: 83dff7f43154cd41e4d2e5831060a2d2ddc6596e ("lsattr: support more ext2 flags")
Signed-off-by: ITcxk <chunhui_r at foxmail.com>
---
e2fsprogs/e2fs_lib.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/e2fsprogs/e2fs_lib.h b/e2fsprogs/e2fs_lib.h
index bab447a94..c6b90d389 100644
--- a/e2fsprogs/e2fs_lib.h
+++ b/e2fsprogs/e2fs_lib.h
@@ -21,11 +21,11 @@ extern const char e2attr_flags_sname[];
/* If you plan to ENABLE_COMPRESSION, see e2fs_lib.c and chattr.c - */
/* make sure that chattr doesn't accept bad options! */
#ifdef ENABLE_COMPRESSION
-#define e2attr_flags_value_chattr (&e2attr_flags_value[5])
-#define e2attr_flags_sname_chattr (&e2attr_flags_sname[5])
+#define e2attr_flags_value_chattr (&EXT2_SECRM_FL)
+#define e2attr_flags_sname_chattr (&EXT2_SECRM_FL)
#else
-#define e2attr_flags_value_chattr (&e2attr_flags_value[1])
-#define e2attr_flags_sname_chattr (&e2attr_flags_sname[1])
+#define e2attr_flags_value_chattr (&EXT2_SECRM_FL)
+#define e2attr_flags_sname_chattr (&EXT2_SECRM_FL)
#endif
POP_SAVED_FUNCTION_VISIBILITY
--
2.37.0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20231012/4e4b36c9/attachment-0001.html>
More information about the busybox
mailing list