diff options
Diffstat (limited to 'e2fsprogs/lsattr.c')
-rw-r--r-- | e2fsprogs/lsattr.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/e2fsprogs/lsattr.c b/e2fsprogs/lsattr.c index f678f72fb..427552f7a 100644 --- a/e2fsprogs/lsattr.c +++ b/e2fsprogs/lsattr.c | |||
@@ -21,16 +21,45 @@ | |||
21 | //kbuild:lib-$(CONFIG_LSATTR) += lsattr.o e2fs_lib.o | 21 | //kbuild:lib-$(CONFIG_LSATTR) += lsattr.o e2fs_lib.o |
22 | 22 | ||
23 | //usage:#define lsattr_trivial_usage | 23 | //usage:#define lsattr_trivial_usage |
24 | //usage: IF_NOT_PLATFORM_MINGW32( | ||
24 | //usage: "[-Radlpv] [FILE]..." | 25 | //usage: "[-Radlpv] [FILE]..." |
26 | //usage: ) | ||
27 | //usage: IF_PLATFORM_MINGW32( | ||
28 | //usage: "[-Radl] [FILE]..." | ||
29 | //usage: ) | ||
25 | //usage:#define lsattr_full_usage "\n\n" | 30 | //usage:#define lsattr_full_usage "\n\n" |
31 | //usage: IF_NOT_PLATFORM_MINGW32( | ||
26 | //usage: "List ext2 file attributes\n" | 32 | //usage: "List ext2 file attributes\n" |
33 | //usage: ) | ||
34 | //usage: IF_PLATFORM_MINGW32( | ||
35 | //usage: "List file attributes\n" | ||
36 | //usage: ) | ||
27 | //usage: "\n -R Recurse" | 37 | //usage: "\n -R Recurse" |
28 | //usage: "\n -a Include names starting with ." | 38 | //usage: "\n -a Include names starting with ." |
29 | //usage: "\n -d List directory names, not contents" | 39 | //usage: "\n -d List directory names, not contents" |
30 | // -a,-d text should match ls --help | 40 | // -a,-d text should match ls --help |
31 | //usage: "\n -l List long flag names" | 41 | //usage: "\n -l List long flag names" |
42 | //usage: IF_NOT_PLATFORM_MINGW32( | ||
32 | //usage: "\n -p List project ID" | 43 | //usage: "\n -p List project ID" |
33 | //usage: "\n -v List version/generation number" | 44 | //usage: "\n -v List version/generation number" |
45 | //usage: ) | ||
46 | //usage: IF_PLATFORM_MINGW32( | ||
47 | //usage: "\n\nAttributes:\n" | ||
48 | //usage: "\n j Junction" | ||
49 | //usage: "\n l Symbolic link" | ||
50 | //usage: "\n A App exec link" | ||
51 | //usage: "\n R Reparse point" | ||
52 | //usage: "\n o Offline" | ||
53 | //usage: "\n e Encrypted" | ||
54 | //usage: "\n c Compressed" | ||
55 | //usage: "\n S Sparse" | ||
56 | //usage: "\n r Read only" | ||
57 | //usage: "\n h Hidden" | ||
58 | //usage: "\n s System" | ||
59 | //usage: "\n a Archive" | ||
60 | //usage: "\n t Temporary" | ||
61 | //usage: "\n n Not indexed" | ||
62 | //usage: ) | ||
34 | 63 | ||
35 | #include "libbb.h" | 64 | #include "libbb.h" |
36 | #include "e2fs_lib.h" | 65 | #include "e2fs_lib.h" |
@@ -46,6 +75,7 @@ enum { | |||
46 | 75 | ||
47 | static void list_attributes(const char *name) | 76 | static void list_attributes(const char *name) |
48 | { | 77 | { |
78 | #if !ENABLE_PLATFORM_MINGW32 | ||
49 | unsigned fsflags; | 79 | unsigned fsflags; |
50 | int fd, r; | 80 | int fd, r; |
51 | 81 | ||
@@ -80,6 +110,15 @@ static void list_attributes(const char *name) | |||
80 | goto read_err; | 110 | goto read_err; |
81 | 111 | ||
82 | close(fd); | 112 | close(fd); |
113 | #else /* ENABLE_PLATFORM_MINGW32 */ | ||
114 | struct stat st; | ||
115 | |||
116 | if (lstat(name, &st) == 0 && !(S_ISREG(st.st_mode) || | ||
117 | S_ISDIR(st.st_mode) || S_ISLNK(st.st_mode))) | ||
118 | goto read_err; | ||
119 | |||
120 | #define fsflags &st | ||
121 | #endif | ||
83 | 122 | ||
84 | if (option_mask32 & OPT_PF_LONG) { | 123 | if (option_mask32 & OPT_PF_LONG) { |
85 | printf("%-28s ", name); | 124 | printf("%-28s ", name); |
@@ -93,7 +132,9 @@ static void list_attributes(const char *name) | |||
93 | return; | 132 | return; |
94 | read_err: | 133 | read_err: |
95 | bb_perror_msg("reading %s", name); | 134 | bb_perror_msg("reading %s", name); |
135 | #if !ENABLE_PLATFORM_MINGW32 | ||
96 | close(fd); | 136 | close(fd); |
137 | #endif | ||
97 | } | 138 | } |
98 | 139 | ||
99 | static int FAST_FUNC lsattr_dir_proc(const char *dir_name, | 140 | static int FAST_FUNC lsattr_dir_proc(const char *dir_name, |
@@ -142,7 +183,11 @@ static void lsattr_args(const char *name) | |||
142 | int lsattr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 183 | int lsattr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
143 | int lsattr_main(int argc UNUSED_PARAM, char **argv) | 184 | int lsattr_main(int argc UNUSED_PARAM, char **argv) |
144 | { | 185 | { |
186 | #if ENABLE_PLATFORM_MINGW32 | ||
187 | getopt32(argv, "Radl"); | ||
188 | #else | ||
145 | getopt32(argv, "Radlvp"); | 189 | getopt32(argv, "Radlvp"); |
190 | #endif | ||
146 | argv += optind; | 191 | argv += optind; |
147 | 192 | ||
148 | if (!*argv) | 193 | if (!*argv) |