diff options
author | Ron Yorston <rmy@pobox.com> | 2020-07-09 08:58:10 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2020-07-09 09:07:55 +0100 |
commit | 0e3456e0c4a8623fe2d8bc28c51f16c8274b8098 (patch) | |
tree | e8fc4feb3f700a1101c082d8f815d426d515ce95 | |
parent | 86eb680bbfd096ab1a2664e36f80f4bea55e18cf (diff) | |
download | busybox-w32-0e3456e0c4a8623fe2d8bc28c51f16c8274b8098.tar.gz busybox-w32-0e3456e0c4a8623fe2d8bc28c51f16c8274b8098.tar.bz2 busybox-w32-0e3456e0c4a8623fe2d8bc28c51f16c8274b8098.zip |
chattr, lsattr: enable in the default configuration
The chattr and lsattr utilities allow file attributes to be changed
and displayed. Modify them to support Windows file attributes using
the same names as Cygwin.
Only allow a limited subset of attributes to be changed: just most of
those supported by SetFileAttributes(). Since it isn't possible to set
all attributes the '=' operator isn't allowed.
-rw-r--r-- | configs/mingw32_defconfig | 6 | ||||
-rw-r--r-- | configs/mingw64_defconfig | 6 | ||||
-rw-r--r-- | e2fsprogs/chattr.c | 46 | ||||
-rw-r--r-- | e2fsprogs/e2fs_lib.c | 67 | ||||
-rw-r--r-- | e2fsprogs/e2fs_lib.h | 5 | ||||
-rw-r--r-- | e2fsprogs/lsattr.c | 15 |
6 files changed, 138 insertions, 7 deletions
diff --git a/configs/mingw32_defconfig b/configs/mingw32_defconfig index b3dfc0033..379d8265b 100644 --- a/configs/mingw32_defconfig +++ b/configs/mingw32_defconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Busybox version: 1.32.0.git | 3 | # Busybox version: 1.32.0.git |
4 | # Sun Jun 14 09:30:06 2020 | 4 | # Thu Jul 9 08:46:09 2020 |
5 | # | 5 | # |
6 | CONFIG_HAVE_DOT_CONFIG=y | 6 | CONFIG_HAVE_DOT_CONFIG=y |
7 | # CONFIG_PLATFORM_POSIX is not set | 7 | # CONFIG_PLATFORM_POSIX is not set |
@@ -562,9 +562,9 @@ CONFIG_SUW32=y | |||
562 | # | 562 | # |
563 | # Linux Ext2 FS Progs | 563 | # Linux Ext2 FS Progs |
564 | # | 564 | # |
565 | # CONFIG_CHATTR is not set | 565 | CONFIG_CHATTR=y |
566 | # CONFIG_FSCK is not set | 566 | # CONFIG_FSCK is not set |
567 | # CONFIG_LSATTR is not set | 567 | CONFIG_LSATTR=y |
568 | # CONFIG_TUNE2FS is not set | 568 | # CONFIG_TUNE2FS is not set |
569 | 569 | ||
570 | # | 570 | # |
diff --git a/configs/mingw64_defconfig b/configs/mingw64_defconfig index 2410d476d..25ed022e4 100644 --- a/configs/mingw64_defconfig +++ b/configs/mingw64_defconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Busybox version: 1.32.0.git | 3 | # Busybox version: 1.32.0.git |
4 | # Sun Jun 14 09:30:06 2020 | 4 | # Thu Jul 9 08:46:09 2020 |
5 | # | 5 | # |
6 | CONFIG_HAVE_DOT_CONFIG=y | 6 | CONFIG_HAVE_DOT_CONFIG=y |
7 | # CONFIG_PLATFORM_POSIX is not set | 7 | # CONFIG_PLATFORM_POSIX is not set |
@@ -562,9 +562,9 @@ CONFIG_SUW32=y | |||
562 | # | 562 | # |
563 | # Linux Ext2 FS Progs | 563 | # Linux Ext2 FS Progs |
564 | # | 564 | # |
565 | # CONFIG_CHATTR is not set | 565 | CONFIG_CHATTR=y |
566 | # CONFIG_FSCK is not set | 566 | # CONFIG_FSCK is not set |
567 | # CONFIG_LSATTR is not set | 567 | CONFIG_LSATTR=y |
568 | # CONFIG_TUNE2FS is not set | 568 | # CONFIG_TUNE2FS is not set |
569 | 569 | ||
570 | # | 570 | # |
diff --git a/e2fsprogs/chattr.c b/e2fsprogs/chattr.c index c37469021..e1a798727 100644 --- a/e2fsprogs/chattr.c +++ b/e2fsprogs/chattr.c | |||
@@ -20,13 +20,26 @@ | |||
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: IF_NOT_PLATFORM_MINGW32( | ||
23 | //usage: "[-R] [-v VERSION] [-+=AacDdijsStTu] FILE..." | 24 | //usage: "[-R] [-v VERSION] [-+=AacDdijsStTu] FILE..." |
25 | //usage: ) | ||
26 | //usage: IF_PLATFORM_MINGW32( | ||
27 | //usage: "[-R] [-+rhsatn] FILE..." | ||
28 | //usage: ) | ||
24 | //usage:#define chattr_full_usage "\n\n" | 29 | //usage:#define chattr_full_usage "\n\n" |
30 | //usage: IF_NOT_PLATFORM_MINGW32( | ||
25 | //usage: "Change ext2 file attributes\n" | 31 | //usage: "Change ext2 file attributes\n" |
32 | //usage: ) | ||
33 | //usage: IF_PLATFORM_MINGW32( | ||
34 | //usage: "Change file attributes\n" | ||
35 | //usage: ) | ||
26 | //usage: "\n -R Recurse" | 36 | //usage: "\n -R Recurse" |
37 | //usage: IF_NOT_PLATFORM_MINGW32( | ||
27 | //usage: "\n -v VER Set version/generation number" | 38 | //usage: "\n -v VER Set version/generation number" |
39 | //usage: ) | ||
28 | //-V, -f accepted but ignored | 40 | //-V, -f accepted but ignored |
29 | //usage: "\nModifiers:" | 41 | //usage: "\nModifiers:" |
42 | //usage: IF_NOT_PLATFORM_MINGW32( | ||
30 | //usage: "\n -,+,= Remove/add/set attributes" | 43 | //usage: "\n -,+,= Remove/add/set attributes" |
31 | //usage: "\nAttributes:" | 44 | //usage: "\nAttributes:" |
32 | //usage: "\n A Don't track atime" | 45 | //usage: "\n A Don't track atime" |
@@ -40,6 +53,17 @@ | |||
40 | //usage: "\n S Write synchronously" | 53 | //usage: "\n S Write synchronously" |
41 | //usage: "\n t Disable tail-merging of partial blocks with other files" | 54 | //usage: "\n t Disable tail-merging of partial blocks with other files" |
42 | //usage: "\n u Allow file to be undeleted" | 55 | //usage: "\n u Allow file to be undeleted" |
56 | //usage: ) | ||
57 | //usage: IF_PLATFORM_MINGW32( | ||
58 | //usage: "\n -,+ Remove/add attributes" | ||
59 | //usage: "\nAttributes:" | ||
60 | //usage: "\n r Read only" | ||
61 | //usage: "\n h Hidden" | ||
62 | //usage: "\n s System" | ||
63 | //usage: "\n a Archive" | ||
64 | //usage: "\n t Temporary" | ||
65 | //usage: "\n n Not indexed" | ||
66 | //usage: ) | ||
43 | 67 | ||
44 | #include "libbb.h" | 68 | #include "libbb.h" |
45 | #include "e2fs_lib.h" | 69 | #include "e2fs_lib.h" |
@@ -50,7 +74,9 @@ | |||
50 | #define OPT_SET_VER 8 | 74 | #define OPT_SET_VER 8 |
51 | 75 | ||
52 | struct globals { | 76 | struct globals { |
77 | #if !ENABLE_PLATFORM_MINGW32 | ||
53 | unsigned long version; | 78 | unsigned long version; |
79 | #endif | ||
54 | unsigned long af; | 80 | unsigned long af; |
55 | unsigned long rf; | 81 | unsigned long rf; |
56 | int flags; | 82 | int flags; |
@@ -75,11 +101,17 @@ static char** decode_arg(char **argv, struct globals *gp) | |||
75 | if (opt == '-') { | 101 | if (opt == '-') { |
76 | gp->flags |= OPT_REM; | 102 | gp->flags |= OPT_REM; |
77 | fl = &gp->rf; | 103 | fl = &gp->rf; |
104 | #if ENABLE_PLATFORM_MINGW32 | ||
105 | } else { /* if (opt == '+') */ | ||
106 | gp->flags |= OPT_ADD; | ||
107 | } | ||
108 | #else | ||
78 | } else if (opt == '+') { | 109 | } else if (opt == '+') { |
79 | gp->flags |= OPT_ADD; | 110 | gp->flags |= OPT_ADD; |
80 | } else { /* if (opt == '=') */ | 111 | } else { /* if (opt == '=') */ |
81 | gp->flags |= OPT_SET; | 112 | gp->flags |= OPT_SET; |
82 | } | 113 | } |
114 | #endif | ||
83 | 115 | ||
84 | while (*++arg) { | 116 | while (*++arg) { |
85 | if (opt == '-') { | 117 | if (opt == '-') { |
@@ -92,6 +124,7 @@ static char** decode_arg(char **argv, struct globals *gp) | |||
92 | gp->recursive = 1; | 124 | gp->recursive = 1; |
93 | continue; | 125 | continue; |
94 | } | 126 | } |
127 | #if !ENABLE_PLATFORM_MINGW32 | ||
95 | if (*arg == 'V') { | 128 | if (*arg == 'V') { |
96 | /*"verbose and print program version" (nop for now) */; | 129 | /*"verbose and print program version" (nop for now) */; |
97 | continue; | 130 | continue; |
@@ -108,6 +141,7 @@ static char** decode_arg(char **argv, struct globals *gp) | |||
108 | continue; | 141 | continue; |
109 | } | 142 | } |
110 | //TODO: "-p PROJECT_NUM" ? | 143 | //TODO: "-p PROJECT_NUM" ? |
144 | #endif | ||
111 | /* not a known option, try as an attribute */ | 145 | /* not a known option, try as an attribute */ |
112 | } | 146 | } |
113 | *fl |= get_flag(*arg); | 147 | *fl |= get_flag(*arg); |
@@ -148,9 +182,11 @@ static void change_attributes(const char *name, struct globals *gp) | |||
148 | if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode) && !S_ISDIR(st.st_mode)) | 182 | if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode) && !S_ISDIR(st.st_mode)) |
149 | return; | 183 | return; |
150 | 184 | ||
185 | #if !ENABLE_PLATFORM_MINGW32 | ||
151 | if (gp->flags & OPT_SET_VER) | 186 | if (gp->flags & OPT_SET_VER) |
152 | if (fsetversion(name, gp->version) != 0) | 187 | if (fsetversion(name, gp->version) != 0) |
153 | bb_perror_msg("setting version on %s", name); | 188 | bb_perror_msg("setting version on %s", name); |
189 | #endif | ||
154 | 190 | ||
155 | if (gp->flags & OPT_SET) { | 191 | if (gp->flags & OPT_SET) { |
156 | fsflags = gp->af; | 192 | fsflags = gp->af; |
@@ -163,9 +199,11 @@ static void change_attributes(const char *name, struct globals *gp) | |||
163 | fsflags &= ~gp->rf; | 199 | fsflags &= ~gp->rf; |
164 | /*if (gp->flags & OPT_ADD) - not needed, af is zero otherwise */ | 200 | /*if (gp->flags & OPT_ADD) - not needed, af is zero otherwise */ |
165 | fsflags |= gp->af; | 201 | fsflags |= gp->af; |
202 | #if !ENABLE_PLATFORM_MINGW32 | ||
166 | // What is this? And why it's not done for SET case? | 203 | // What is this? And why it's not done for SET case? |
167 | if (!S_ISDIR(st.st_mode)) | 204 | if (!S_ISDIR(st.st_mode)) |
168 | fsflags &= ~EXT2_DIRSYNC_FL; | 205 | fsflags &= ~EXT2_DIRSYNC_FL; |
206 | #endif | ||
169 | } | 207 | } |
170 | if (fsetflags(name, fsflags) != 0) | 208 | if (fsetflags(name, fsflags) != 0) |
171 | bb_perror_msg("setting flags on %s", name); | 209 | bb_perror_msg("setting flags on %s", name); |
@@ -187,7 +225,11 @@ int chattr_main(int argc UNUSED_PARAM, char **argv) | |||
187 | char *arg = *++argv; | 225 | char *arg = *++argv; |
188 | if (!arg) | 226 | if (!arg) |
189 | bb_show_usage(); | 227 | bb_show_usage(); |
228 | #if ENABLE_PLATFORM_MINGW32 | ||
229 | if (arg[0] != '-' && arg[0] != '+') | ||
230 | #else | ||
190 | if (arg[0] != '-' && arg[0] != '+' && arg[0] != '=') | 231 | if (arg[0] != '-' && arg[0] != '+' && arg[0] != '=') |
232 | #endif | ||
191 | break; | 233 | break; |
192 | 234 | ||
193 | argv = decode_arg(argv, &g); | 235 | argv = decode_arg(argv, &g); |
@@ -200,7 +242,11 @@ int chattr_main(int argc UNUSED_PARAM, char **argv) | |||
200 | if (g.rf & g.af) | 242 | if (g.rf & g.af) |
201 | bb_simple_error_msg_and_die("can't set and unset a flag"); | 243 | bb_simple_error_msg_and_die("can't set and unset a flag"); |
202 | if (!g.flags) | 244 | if (!g.flags) |
245 | #if ENABLE_PLATFORM_MINGW32 | ||
246 | bb_simple_error_msg_and_die("must use - or +"); | ||
247 | #else | ||
203 | bb_simple_error_msg_and_die("must use '-v', =, - or +"); | 248 | bb_simple_error_msg_and_die("must use '-v', =, - or +"); |
249 | #endif | ||
204 | 250 | ||
205 | /* now run chattr on all the files passed to us */ | 251 | /* now run chattr on all the files passed to us */ |
206 | do change_attributes(*argv, &g); while (*++argv); | 252 | do change_attributes(*argv, &g); while (*++argv); |
diff --git a/e2fsprogs/e2fs_lib.c b/e2fsprogs/e2fs_lib.c index 6ce655be3..3b776bc97 100644 --- a/e2fsprogs/e2fs_lib.c +++ b/e2fsprogs/e2fs_lib.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include "libbb.h" | 8 | #include "libbb.h" |
9 | #include "e2fs_lib.h" | 9 | #include "e2fs_lib.h" |
10 | 10 | ||
11 | #if !ENABLE_PLATFORM_MINGW32 | ||
11 | #define HAVE_EXT2_IOCTLS 1 | 12 | #define HAVE_EXT2_IOCTLS 1 |
12 | 13 | ||
13 | #if INT_MAX == LONG_MAX | 14 | #if INT_MAX == LONG_MAX |
@@ -24,6 +25,7 @@ static void close_silently(int fd) | |||
24 | close(fd); | 25 | close(fd); |
25 | errno = e; | 26 | errno = e; |
26 | } | 27 | } |
28 | #endif | ||
27 | 29 | ||
28 | 30 | ||
29 | /* Iterate a function on each entry of a directory */ | 31 | /* Iterate a function on each entry of a directory */ |
@@ -46,6 +48,7 @@ int iterate_on_dir(const char *dir_name, | |||
46 | } | 48 | } |
47 | 49 | ||
48 | 50 | ||
51 | #if !ENABLE_PLATFORM_MINGW32 | ||
49 | /* Get/set a file version on an ext2 file system */ | 52 | /* Get/set a file version on an ext2 file system */ |
50 | int fgetsetversion(const char *name, unsigned long *get_version, unsigned long set_version) | 53 | int fgetsetversion(const char *name, unsigned long *get_version, unsigned long set_version) |
51 | { | 54 | { |
@@ -81,7 +84,6 @@ int fgetsetversion(const char *name, unsigned long *get_version, unsigned long s | |||
81 | #endif /* ! HAVE_EXT2_IOCTLS */ | 84 | #endif /* ! HAVE_EXT2_IOCTLS */ |
82 | } | 85 | } |
83 | 86 | ||
84 | |||
85 | /* Get/set a file flags on an ext2 file system */ | 87 | /* Get/set a file flags on an ext2 file system */ |
86 | int fgetsetflags(const char *name, unsigned long *get_flags, unsigned long set_flags) | 88 | int fgetsetflags(const char *name, unsigned long *get_flags, unsigned long set_flags) |
87 | { | 89 | { |
@@ -124,8 +126,38 @@ int fgetsetflags(const char *name, unsigned long *get_flags, unsigned long set_f | |||
124 | errno = EOPNOTSUPP; | 126 | errno = EOPNOTSUPP; |
125 | return -1; | 127 | return -1; |
126 | } | 128 | } |
129 | #else /* ENABLE_PLATFORM_MINGW32 */ | ||
130 | /* Only certain attributes can be set using SetFileAttributes() */ | ||
131 | #define CHATTR_MASK (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | \ | ||
132 | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE | \ | ||
133 | FILE_ATTRIBUTE_TEMPORARY | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED | \ | ||
134 | FILE_ATTRIBUTE_OFFLINE) | ||
127 | 135 | ||
136 | /* Get/set file attributes on a Windows file system */ | ||
137 | int fgetsetflags(const char *name, unsigned long *get_flags, unsigned long set_flags) | ||
138 | { | ||
139 | struct stat buf; | ||
140 | |||
141 | if (stat(name, &buf) == 0 /* stat is ok */ | ||
142 | && !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode) | ||
143 | ) { | ||
144 | errno = EOPNOTSUPP; | ||
145 | return -1; | ||
146 | } | ||
128 | 147 | ||
148 | if (get_flags) { | ||
149 | *get_flags = (unsigned long)buf.st_attr; | ||
150 | } | ||
151 | else if (!SetFileAttributes(name, set_flags & CHATTR_MASK)) { | ||
152 | errno = err_win_to_posix(); | ||
153 | return -1; | ||
154 | } | ||
155 | return 0; | ||
156 | } | ||
157 | #endif | ||
158 | |||
159 | |||
160 | #if !ENABLE_PLATFORM_MINGW32 | ||
129 | /* Print file attributes on an ext2 file system */ | 161 | /* Print file attributes on an ext2 file system */ |
130 | const uint32_t e2attr_flags_value[] = { | 162 | const uint32_t e2attr_flags_value[] = { |
131 | #ifdef ENABLE_COMPRESSION | 163 | #ifdef ENABLE_COMPRESSION |
@@ -177,6 +209,39 @@ static const char e2attr_flags_lname[] ALIGN1 = | |||
177 | "No_Tailmerging" "\0" | 209 | "No_Tailmerging" "\0" |
178 | "Top_of_Directory_Hierarchies" "\0" | 210 | "Top_of_Directory_Hierarchies" "\0" |
179 | /* Another trailing NUL is added by compiler */; | 211 | /* Another trailing NUL is added by compiler */; |
212 | #else /* ENABLE_PLATFORM_MINGW32 */ | ||
213 | /* Print file attributes on a Windows file system */ | ||
214 | const uint32_t e2attr_flags_value[] = { | ||
215 | FILE_ATTRIBUTE_REPARSE_POINT, | ||
216 | FILE_ATTRIBUTE_OFFLINE, | ||
217 | FILE_ATTRIBUTE_ENCRYPTED, | ||
218 | FILE_ATTRIBUTE_COMPRESSED, | ||
219 | FILE_ATTRIBUTE_SPARSE_FILE, | ||
220 | FILE_ATTRIBUTE_READONLY, | ||
221 | FILE_ATTRIBUTE_HIDDEN, | ||
222 | FILE_ATTRIBUTE_SYSTEM, | ||
223 | FILE_ATTRIBUTE_ARCHIVE, | ||
224 | FILE_ATTRIBUTE_TEMPORARY, | ||
225 | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, | ||
226 | }; | ||
227 | |||
228 | const char e2attr_flags_sname[] ALIGN1 = | ||
229 | "roecSrhsatn"; | ||
230 | |||
231 | static const char e2attr_flags_lname[] ALIGN1 = | ||
232 | "Reparse" "\0" | ||
233 | "Offline" "\0" | ||
234 | "Encrypted" "\0" | ||
235 | "Compressed" "\0" | ||
236 | "Sparse" "\0" | ||
237 | "Readonly" "\0" | ||
238 | "Hidden" "\0" | ||
239 | "System" "\0" | ||
240 | "Archive" "\0" | ||
241 | "Temporary" "\0" | ||
242 | "Notindexed" "\0" | ||
243 | /* Another trailing NUL is added by compiler */; | ||
244 | #endif | ||
180 | 245 | ||
181 | void print_e2flags(FILE *f, unsigned long flags, unsigned options) | 246 | void print_e2flags(FILE *f, unsigned long flags, unsigned options) |
182 | { | 247 | { |
diff --git a/e2fsprogs/e2fs_lib.h b/e2fsprogs/e2fs_lib.h index ae28c353b..4a4d4cc27 100644 --- a/e2fsprogs/e2fs_lib.h +++ b/e2fsprogs/e2fs_lib.h | |||
@@ -36,6 +36,7 @@ extern const char e2attr_flags_sname[]; | |||
36 | 36 | ||
37 | /* If you plan to ENABLE_COMPRESSION, see e2fs_lib.c and chattr.c - */ | 37 | /* If you plan to ENABLE_COMPRESSION, see e2fs_lib.c and chattr.c - */ |
38 | /* make sure that chattr doesn't accept bad options! */ | 38 | /* make sure that chattr doesn't accept bad options! */ |
39 | #if !ENABLE_PLATFORM_MINGW32 | ||
39 | #ifdef ENABLE_COMPRESSION | 40 | #ifdef ENABLE_COMPRESSION |
40 | #define e2attr_flags_value_chattr (&e2attr_flags_value[5]) | 41 | #define e2attr_flags_value_chattr (&e2attr_flags_value[5]) |
41 | #define e2attr_flags_sname_chattr (&e2attr_flags_sname[5]) | 42 | #define e2attr_flags_sname_chattr (&e2attr_flags_sname[5]) |
@@ -43,5 +44,9 @@ extern const char e2attr_flags_sname[]; | |||
43 | #define e2attr_flags_value_chattr (&e2attr_flags_value[1]) | 44 | #define e2attr_flags_value_chattr (&e2attr_flags_value[1]) |
44 | #define e2attr_flags_sname_chattr (&e2attr_flags_sname[1]) | 45 | #define e2attr_flags_sname_chattr (&e2attr_flags_sname[1]) |
45 | #endif | 46 | #endif |
47 | #else | ||
48 | #define e2attr_flags_value_chattr (&e2attr_flags_value[5]) | ||
49 | #define e2attr_flags_sname_chattr (&e2attr_flags_sname[5]) | ||
50 | #endif | ||
46 | 51 | ||
47 | POP_SAVED_FUNCTION_VISIBILITY | 52 | POP_SAVED_FUNCTION_VISIBILITY |
diff --git a/e2fsprogs/lsattr.c b/e2fsprogs/lsattr.c index be1488b79..b36dd47a5 100644 --- a/e2fsprogs/lsattr.c +++ b/e2fsprogs/lsattr.c | |||
@@ -22,14 +22,21 @@ | |||
22 | //kbuild:lib-$(CONFIG_LSATTR) += lsattr.o e2fs_lib.o | 22 | //kbuild:lib-$(CONFIG_LSATTR) += lsattr.o e2fs_lib.o |
23 | 23 | ||
24 | //usage:#define lsattr_trivial_usage | 24 | //usage:#define lsattr_trivial_usage |
25 | //usage: IF_NOT_PLATFORM_MINGW32( | ||
25 | //usage: "[-Radlv] [FILE]..." | 26 | //usage: "[-Radlv] [FILE]..." |
27 | //usage: ) | ||
28 | //usage: IF_PLATFORM_MINGW32( | ||
29 | //usage: "[-Radl] [FILE]..." | ||
30 | //usage: ) | ||
26 | //usage:#define lsattr_full_usage "\n\n" | 31 | //usage:#define lsattr_full_usage "\n\n" |
27 | //usage: "List ext2 file attributes\n" | 32 | //usage: "List ext2 file attributes\n" |
28 | //usage: "\n -R Recurse" | 33 | //usage: "\n -R Recurse" |
29 | //usage: "\n -a Don't hide entries starting with ." | 34 | //usage: "\n -a Don't hide entries starting with ." |
30 | //usage: "\n -d List directory entries instead of contents" | 35 | //usage: "\n -d List directory entries instead of contents" |
31 | //usage: "\n -l List long flag names" | 36 | //usage: "\n -l List long flag names" |
37 | //usage: IF_NOT_PLATFORM_MINGW32( | ||
32 | //usage: "\n -v List version/generation number" | 38 | //usage: "\n -v List version/generation number" |
39 | //usage: ) | ||
33 | 40 | ||
34 | #include "libbb.h" | 41 | #include "libbb.h" |
35 | #include "e2fs_lib.h" | 42 | #include "e2fs_lib.h" |
@@ -45,16 +52,20 @@ enum { | |||
45 | static void list_attributes(const char *name) | 52 | static void list_attributes(const char *name) |
46 | { | 53 | { |
47 | unsigned long fsflags; | 54 | unsigned long fsflags; |
55 | #if !ENABLE_PLATFORM_MINGW32 | ||
48 | unsigned long generation; | 56 | unsigned long generation; |
57 | #endif | ||
49 | 58 | ||
50 | if (fgetflags(name, &fsflags) != 0) | 59 | if (fgetflags(name, &fsflags) != 0) |
51 | goto read_err; | 60 | goto read_err; |
52 | 61 | ||
62 | #if !ENABLE_PLATFORM_MINGW32 | ||
53 | if (option_mask32 & OPT_GENERATION) { | 63 | if (option_mask32 & OPT_GENERATION) { |
54 | if (fgetversion(name, &generation) != 0) | 64 | if (fgetversion(name, &generation) != 0) |
55 | goto read_err; | 65 | goto read_err; |
56 | printf("%5lu ", generation); | 66 | printf("%5lu ", generation); |
57 | } | 67 | } |
68 | #endif | ||
58 | 69 | ||
59 | if (option_mask32 & OPT_PF_LONG) { | 70 | if (option_mask32 & OPT_PF_LONG) { |
60 | printf("%-28s ", name); | 71 | printf("%-28s ", name); |
@@ -112,7 +123,11 @@ static void lsattr_args(const char *name) | |||
112 | int lsattr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 123 | int lsattr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
113 | int lsattr_main(int argc UNUSED_PARAM, char **argv) | 124 | int lsattr_main(int argc UNUSED_PARAM, char **argv) |
114 | { | 125 | { |
126 | #if ENABLE_PLATFORM_MINGW32 | ||
127 | getopt32(argv, "Radl"); | ||
128 | #else | ||
115 | getopt32(argv, "Radlv"); | 129 | getopt32(argv, "Radlv"); |
130 | #endif | ||
116 | argv += optind; | 131 | argv += optind; |
117 | 132 | ||
118 | if (!*argv) | 133 | if (!*argv) |