diff options
Diffstat (limited to 'e2fsprogs/e2fs_lib.c')
| -rw-r--r-- | e2fsprogs/e2fs_lib.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/e2fsprogs/e2fs_lib.c b/e2fsprogs/e2fs_lib.c index 9b68d8901..4a4db1a13 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 | /* Print file attributes on an ext2 file system */ | 12 | /* Print file attributes on an ext2 file system */ |
| 12 | const uint32_t e2attr_flags_value[] ALIGN4 = { | 13 | const uint32_t e2attr_flags_value[] ALIGN4 = { |
| 13 | #ifdef ENABLE_COMPRESSION | 14 | #ifdef ENABLE_COMPRESSION |
| @@ -70,11 +71,52 @@ static const char e2attr_flags_lname[] ALIGN1 = | |||
| 70 | "Project_Hierarchy" "\0" | 71 | "Project_Hierarchy" "\0" |
| 71 | "Verity" "\0" | 72 | "Verity" "\0" |
| 72 | /* Another trailing NUL is added by compiler */; | 73 | /* Another trailing NUL is added by compiler */; |
| 74 | #else /* ENABLE_PLATFORM_MINGW32 */ | ||
| 75 | /* Print file attributes on a Windows file system */ | ||
| 76 | const uint32_t e2attr_flags_value[] = { | ||
| 77 | FILE_ATTRIBUTE_REPARSE_POINT, | ||
| 78 | FILE_ATTRIBUTE_OFFLINE, | ||
| 79 | FILE_ATTRIBUTE_ENCRYPTED, | ||
| 80 | FILE_ATTRIBUTE_COMPRESSED, | ||
| 81 | FILE_ATTRIBUTE_SPARSE_FILE, | ||
| 82 | FILE_ATTRIBUTE_READONLY, | ||
| 83 | FILE_ATTRIBUTE_HIDDEN, | ||
| 84 | FILE_ATTRIBUTE_SYSTEM, | ||
| 85 | FILE_ATTRIBUTE_ARCHIVE, | ||
| 86 | FILE_ATTRIBUTE_TEMPORARY, | ||
| 87 | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, | ||
| 88 | }; | ||
| 89 | |||
| 90 | const char e2attr_flags_sname[] ALIGN1 = | ||
| 91 | "RoecSrhsatn"; | ||
| 92 | |||
| 93 | static const char e2attr_flags_lname[] ALIGN1 = | ||
| 94 | "Reparse_Point" "\0" | ||
| 95 | "Offline" "\0" | ||
| 96 | "Encrypted" "\0" | ||
| 97 | "Compressed" "\0" | ||
| 98 | "Sparse" "\0" | ||
| 99 | "Read_Only" "\0" | ||
| 100 | "Hidden" "\0" | ||
| 101 | "System" "\0" | ||
| 102 | "Archive" "\0" | ||
| 103 | "Temporary" "\0" | ||
| 104 | "Not_Indexed" "\0" | ||
| 105 | /* Another trailing NUL is added by compiler */; | ||
| 106 | #endif | ||
| 73 | 107 | ||
| 108 | #if !ENABLE_PLATFORM_MINGW32 | ||
| 74 | void print_e2flags_long(unsigned flags) | 109 | void print_e2flags_long(unsigned flags) |
| 110 | #else | ||
| 111 | #define flags sb->st_attr | ||
| 112 | void print_e2flags_long(struct stat *sb) | ||
| 113 | #endif | ||
| 75 | { | 114 | { |
| 76 | const uint32_t *fv; | 115 | const uint32_t *fv; |
| 77 | const char *fn; | 116 | const char *fn; |
| 117 | #if ENABLE_PLATFORM_MINGW32 | ||
| 118 | const char *ln; | ||
| 119 | #endif | ||
| 78 | int first = 1; | 120 | int first = 1; |
| 79 | 121 | ||
| 80 | fv = e2attr_flags_value; | 122 | fv = e2attr_flags_value; |
| @@ -83,7 +125,25 @@ void print_e2flags_long(unsigned flags) | |||
| 83 | if (flags & *fv) { | 125 | if (flags & *fv) { |
| 84 | if (!first) | 126 | if (!first) |
| 85 | 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 | case IO_REPARSE_TAG_APPEXECLINK: | ||
| 139 | ln = "App_Exec_Link"; | ||
| 140 | break; | ||
| 141 | } | ||
| 142 | } | ||
| 143 | fputs(ln, stdout); | ||
| 144 | #else | ||
| 86 | fputs(fn, stdout); | 145 | fputs(fn, stdout); |
| 146 | #endif | ||
| 87 | first = 0; | 147 | first = 0; |
| 88 | } | 148 | } |
| 89 | fv++; | 149 | fv++; |
| @@ -93,7 +153,11 @@ void print_e2flags_long(unsigned flags) | |||
| 93 | fputs("---", stdout); | 153 | fputs("---", stdout); |
| 94 | } | 154 | } |
| 95 | 155 | ||
| 156 | #if !ENABLE_PLATFORM_MINGW32 | ||
| 96 | void print_e2flags(unsigned flags) | 157 | void print_e2flags(unsigned flags) |
| 158 | #else | ||
| 159 | void print_e2flags(struct stat *sb) | ||
| 160 | #endif | ||
| 97 | { | 161 | { |
| 98 | const uint32_t *fv; | 162 | const uint32_t *fv; |
| 99 | const char *fn; | 163 | const char *fn; |
| @@ -104,6 +168,21 @@ void print_e2flags(unsigned flags) | |||
| 104 | char c = '-'; | 168 | char c = '-'; |
| 105 | if (flags & *fv) | 169 | if (flags & *fv) |
| 106 | c = *fn; | 170 | c = *fn; |
| 171 | #if ENABLE_PLATFORM_MINGW32 | ||
| 172 | if (*fv == FILE_ATTRIBUTE_REPARSE_POINT) { | ||
| 173 | switch (sb->st_tag) { | ||
| 174 | case IO_REPARSE_TAG_SYMLINK: | ||
| 175 | c = 'l'; | ||
| 176 | break; | ||
| 177 | case IO_REPARSE_TAG_MOUNT_POINT: | ||
| 178 | c = 'j'; | ||
| 179 | break; | ||
| 180 | case IO_REPARSE_TAG_APPEXECLINK: | ||
| 181 | c = 'A'; | ||
| 182 | break; | ||
| 183 | } | ||
| 184 | } | ||
| 185 | #endif | ||
| 107 | putchar(c); | 186 | putchar(c); |
| 108 | fv++; | 187 | fv++; |
| 109 | fn++; | 188 | fn++; |
