summaryrefslogtreecommitdiff
path: root/e2fsprogs/chattr.c
diff options
context:
space:
mode:
authorDenys Vlasenko2021-06-20 10:57:24 +0200
committerDenys Vlasenko2021-06-20 11:02:49 +0200
commit526b8347906a18d756386092fafa0b42ba0b4563 (patch)
treeaafe396ff964a194f183bead405b5f1045f67a61 /e2fsprogs/chattr.c
parent9c291f2cc0e0e76869c315b5c7e7883827b5ae95 (diff)
downloadbusybox-526b8347906a18d756386092fafa0b42ba0b4563.zip
busybox-526b8347906a18d756386092fafa0b42ba0b4563.tar.gz
lsattr,chattr: support -p
function old new delta fgetsetprojid - 107 +107 list_attributes 169 222 +53 change_attributes 277 326 +49 chattr_main 272 307 +35 close_silently - 22 +22 .rodata 103378 103393 +15 packed_usage 33658 33666 +8 fgetsetversion 88 74 -14 fgetsetflags 162 148 -14 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 5/2 up/down: 289/-28) Total: 261 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'e2fsprogs/chattr.c')
-rw-r--r--e2fsprogs/chattr.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/e2fsprogs/chattr.c b/e2fsprogs/chattr.c
index 1d267f7..5a7545e 100644
--- a/e2fsprogs/chattr.c
+++ b/e2fsprogs/chattr.c
@@ -20,12 +20,12 @@
//kbuild:lib-$(CONFIG_CHATTR) += chattr.o e2fs_lib.o
//usage:#define chattr_trivial_usage
-//usage: "[-R] [-v VERSION] [-+=AacDdijsStTu] FILE..."
+//usage: "[-R] [-v VERSION] [-p PROJID] [-+=AacDdijsStTu] FILE..."
//usage:#define chattr_full_usage "\n\n"
//usage: "Change ext2 file attributes\n"
//usage: "\n -R Recurse"
-//TODD? "\n -p NUM Set project number"
//usage: "\n -v NUM Set version/generation number"
+//usage: "\n -p NUM Set project number"
//-V, -f accepted but ignored
//usage: "\nModifiers:"
//usage: "\n -,+,= Remove/add/set attributes"
@@ -45,16 +45,18 @@
#include "libbb.h"
#include "e2fs_lib.h"
-#define OPT_ADD 1
-#define OPT_REM 2
-#define OPT_SET 4
-#define OPT_SET_VER 8
+#define OPT_ADD (1 << 0)
+#define OPT_REM (1 << 1)
+#define OPT_SET (1 << 2)
+#define OPT_SET_VER (1 << 3)
+#define OPT_SET_PROJ (1 << 4)
struct globals {
unsigned long version;
unsigned long af;
unsigned long rf;
int flags;
+ uint32_t projid;
smallint recursive;
};
@@ -108,7 +110,13 @@ static char** decode_arg(char **argv, struct globals *gp)
gp->flags |= OPT_SET_VER;
continue;
}
-//TODO: "-p PROJECT_NUM" ?
+ if (*arg == 'p') {
+ if (!*++argv)
+ bb_show_usage();
+ gp->projid = xatou32(*argv);
+ gp->flags |= OPT_SET_PROJ;
+ continue;
+ }
/* not a known option, try as an attribute */
}
*fl |= get_flag(*arg);
@@ -151,7 +159,11 @@ static void change_attributes(const char *name, struct globals *gp)
if (gp->flags & OPT_SET_VER)
if (fsetversion(name, gp->version) != 0)
- bb_perror_msg("setting version on %s", name);
+ bb_perror_msg("setting %s on %s", "version", name);
+
+ if (gp->flags & OPT_SET_PROJ)
+ if (fsetprojid(name, gp->projid) != 0)
+ bb_perror_msg("setting %s on %s", "project ID", name);
if (gp->flags & OPT_SET) {
fsflags = gp->af;