aboutsummaryrefslogtreecommitdiff
path: root/e2fsprogs/chattr.c
diff options
context:
space:
mode:
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 1d267f7a4..5a7545e09 100644
--- a/e2fsprogs/chattr.c
+++ b/e2fsprogs/chattr.c
@@ -20,12 +20,12 @@
20//kbuild:lib-$(CONFIG_CHATTR) += chattr.o e2fs_lib.o 20//kbuild:lib-$(CONFIG_CHATTR) += chattr.o e2fs_lib.o
21 21
22//usage:#define chattr_trivial_usage 22//usage:#define chattr_trivial_usage
23//usage: "[-R] [-v VERSION] [-+=AacDdijsStTu] FILE..." 23//usage: "[-R] [-v VERSION] [-p PROJID] [-+=AacDdijsStTu] FILE..."
24//usage:#define chattr_full_usage "\n\n" 24//usage:#define chattr_full_usage "\n\n"
25//usage: "Change ext2 file attributes\n" 25//usage: "Change ext2 file attributes\n"
26//usage: "\n -R Recurse" 26//usage: "\n -R Recurse"
27//TODD? "\n -p NUM Set project number"
28//usage: "\n -v NUM Set version/generation number" 27//usage: "\n -v NUM Set version/generation number"
28//usage: "\n -p NUM Set project number"
29//-V, -f accepted but ignored 29//-V, -f accepted but ignored
30//usage: "\nModifiers:" 30//usage: "\nModifiers:"
31//usage: "\n -,+,= Remove/add/set attributes" 31//usage: "\n -,+,= Remove/add/set attributes"
@@ -45,16 +45,18 @@
45#include "libbb.h" 45#include "libbb.h"
46#include "e2fs_lib.h" 46#include "e2fs_lib.h"
47 47
48#define OPT_ADD 1 48#define OPT_ADD (1 << 0)
49#define OPT_REM 2 49#define OPT_REM (1 << 1)
50#define OPT_SET 4 50#define OPT_SET (1 << 2)
51#define OPT_SET_VER 8 51#define OPT_SET_VER (1 << 3)
52#define OPT_SET_PROJ (1 << 4)
52 53
53struct globals { 54struct globals {
54 unsigned long version; 55 unsigned long version;
55 unsigned long af; 56 unsigned long af;
56 unsigned long rf; 57 unsigned long rf;
57 int flags; 58 int flags;
59 uint32_t projid;
58 smallint recursive; 60 smallint recursive;
59}; 61};
60 62
@@ -108,7 +110,13 @@ static char** decode_arg(char **argv, struct globals *gp)
108 gp->flags |= OPT_SET_VER; 110 gp->flags |= OPT_SET_VER;
109 continue; 111 continue;
110 } 112 }
111//TODO: "-p PROJECT_NUM" ? 113 if (*arg == 'p') {
114 if (!*++argv)
115 bb_show_usage();
116 gp->projid = xatou32(*argv);
117 gp->flags |= OPT_SET_PROJ;
118 continue;
119 }
112 /* not a known option, try as an attribute */ 120 /* not a known option, try as an attribute */
113 } 121 }
114 *fl |= get_flag(*arg); 122 *fl |= get_flag(*arg);
@@ -151,7 +159,11 @@ static void change_attributes(const char *name, struct globals *gp)
151 159
152 if (gp->flags & OPT_SET_VER) 160 if (gp->flags & OPT_SET_VER)
153 if (fsetversion(name, gp->version) != 0) 161 if (fsetversion(name, gp->version) != 0)
154 bb_perror_msg("setting version on %s", name); 162 bb_perror_msg("setting %s on %s", "version", name);
163
164 if (gp->flags & OPT_SET_PROJ)
165 if (fsetprojid(name, gp->projid) != 0)
166 bb_perror_msg("setting %s on %s", "project ID", name);
155 167
156 if (gp->flags & OPT_SET) { 168 if (gp->flags & OPT_SET) {
157 fsflags = gp->af; 169 fsflags = gp->af;