aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2022-05-19 13:02:26 +0100
committerRon Yorston <rmy@pobox.com>2022-05-19 15:43:23 +0100
commit3ab7b90aba64b2341f74d1e5b85a3f8fef216258 (patch)
tree7e7ad25c6f73f2fc89562b564e1f262e20406df1
parent055902330c448a5bbd59d12231bcb0aa00e50970 (diff)
downloadbusybox-w32-3ab7b90aba64b2341f74d1e5b85a3f8fef216258.tar.gz
busybox-w32-3ab7b90aba64b2341f74d1e5b85a3f8fef216258.tar.bz2
busybox-w32-3ab7b90aba64b2341f74d1e5b85a3f8fef216258.zip
lsattr: distinguish between junctions and symlinks
Use the new st_tag member of struct stat to display whether a reparse point is a junction or a symlink.
-rw-r--r--e2fsprogs/e2fs_lib.c39
-rw-r--r--e2fsprogs/e2fs_lib.h7
-rw-r--r--e2fsprogs/lsattr.c4
3 files changed, 47 insertions, 3 deletions
diff --git a/e2fsprogs/e2fs_lib.c b/e2fsprogs/e2fs_lib.c
index e40702e78..07de5eda7 100644
--- a/e2fsprogs/e2fs_lib.c
+++ b/e2fsprogs/e2fs_lib.c
@@ -105,10 +105,18 @@ static const char e2attr_flags_lname[] ALIGN1 =
105 /* Another trailing NUL is added by compiler */; 105 /* Another trailing NUL is added by compiler */;
106#endif 106#endif
107 107
108#if !ENABLE_PLATFORM_MINGW32
108void print_e2flags_long(unsigned flags) 109void print_e2flags_long(unsigned flags)
110#else
111#define flags sb->st_attr
112void print_e2flags_long(struct stat *sb)
113#endif
109{ 114{
110 const uint32_t *fv; 115 const uint32_t *fv;
111 const char *fn; 116 const char *fn;
117#if ENABLE_PLATFORM_MINGW32
118 const char *ln;
119#endif
112 int first = 1; 120 int first = 1;
113 121
114 fv = e2attr_flags_value; 122 fv = e2attr_flags_value;
@@ -117,7 +125,22 @@ void print_e2flags_long(unsigned flags)
117 if (flags & *fv) { 125 if (flags & *fv) {
118 if (!first) 126 if (!first)
119 fputs(", ", stdout); 127 fputs(", ", stdout);
128#if ENABLE_PLATFORM_MINGW32
129 ln = fn;
130 if (*fv == FILE_ATTRIBUTE_REPARSE_POINT) {
131 switch (sb->st_tag) {
132 case IO_REPARSE_TAG_SYMLINK:
133 ln = "Symbolic_Link";
134 break;
135 case IO_REPARSE_TAG_MOUNT_POINT:
136 ln = "Junction";
137 break;
138 }
139 }
140 fputs(ln, stdout);
141#else
120 fputs(fn, stdout); 142 fputs(fn, stdout);
143#endif
121 first = 0; 144 first = 0;
122 } 145 }
123 fv++; 146 fv++;
@@ -127,7 +150,11 @@ void print_e2flags_long(unsigned flags)
127 fputs("---", stdout); 150 fputs("---", stdout);
128} 151}
129 152
153#if !ENABLE_PLATFORM_MINGW32
130void print_e2flags(unsigned flags) 154void print_e2flags(unsigned flags)
155#else
156void print_e2flags(struct stat *sb)
157#endif
131{ 158{
132 const uint32_t *fv; 159 const uint32_t *fv;
133 const char *fn; 160 const char *fn;
@@ -138,6 +165,18 @@ void print_e2flags(unsigned flags)
138 char c = '-'; 165 char c = '-';
139 if (flags & *fv) 166 if (flags & *fv)
140 c = *fn; 167 c = *fn;
168#if ENABLE_PLATFORM_MINGW32
169 if (*fv == FILE_ATTRIBUTE_REPARSE_POINT) {
170 switch (sb->st_tag) {
171 case IO_REPARSE_TAG_SYMLINK:
172 c = 'l';
173 break;
174 case IO_REPARSE_TAG_MOUNT_POINT:
175 c = 'j';
176 break;
177 }
178 }
179#endif
141 putchar(c); 180 putchar(c);
142 fv++; 181 fv++;
143 fn++; 182 fn++;
diff --git a/e2fsprogs/e2fs_lib.h b/e2fsprogs/e2fs_lib.h
index fd6948fc7..5ce206ad6 100644
--- a/e2fsprogs/e2fs_lib.h
+++ b/e2fsprogs/e2fs_lib.h
@@ -16,11 +16,16 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
16#define CHATTR_MASK (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | \ 16#define CHATTR_MASK (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | \
17 FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE | \ 17 FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE | \
18 FILE_ATTRIBUTE_TEMPORARY | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED) 18 FILE_ATTRIBUTE_TEMPORARY | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED)
19#endif 19
20/* Print file attributes on an NTFS file system */
21void print_e2flags_long(struct stat *sb);
22void print_e2flags(struct stat *sb);
23#else
20 24
21/* Print file attributes on an ext2 file system */ 25/* Print file attributes on an ext2 file system */
22void print_e2flags_long(unsigned flags); 26void print_e2flags_long(unsigned flags);
23void print_e2flags(unsigned flags); 27void print_e2flags(unsigned flags);
28#endif
24 29
25extern const uint32_t e2attr_flags_value[]; 30extern const uint32_t e2attr_flags_value[];
26extern const char e2attr_flags_sname[]; 31extern const char e2attr_flags_sname[];
diff --git a/e2fsprogs/lsattr.c b/e2fsprogs/lsattr.c
index 461ce39e6..e86807e85 100644
--- a/e2fsprogs/lsattr.c
+++ b/e2fsprogs/lsattr.c
@@ -53,8 +53,8 @@ enum {
53 53
54static void list_attributes(const char *name) 54static void list_attributes(const char *name)
55{ 55{
56 unsigned fsflags;
57#if !ENABLE_PLATFORM_MINGW32 56#if !ENABLE_PLATFORM_MINGW32
57 unsigned fsflags;
58 int fd, r; 58 int fd, r;
59 59
60 /* There is no way to run needed ioctls on a symlink. 60 /* There is no way to run needed ioctls on a symlink.
@@ -95,7 +95,7 @@ static void list_attributes(const char *name)
95 S_ISDIR(st.st_mode) || S_ISLNK(st.st_mode))) 95 S_ISDIR(st.st_mode) || S_ISLNK(st.st_mode)))
96 goto read_err; 96 goto read_err;
97 97
98 fsflags = st.st_attr; 98#define fsflags &st
99#endif 99#endif
100 100
101 if (option_mask32 & OPT_PF_LONG) { 101 if (option_mask32 & OPT_PF_LONG) {