diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-09-17 17:10:38 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-09-17 17:10:38 +0200 |
commit | 6279aec03d4677424408a515a57aa83664b81311 (patch) | |
tree | cd45810d883981cb1b7337e27a41c3430988aa30 /libbb | |
parent | 3a65435eaa845d45bbea176701726f27a88e8498 (diff) | |
download | busybox-w32-6279aec03d4677424408a515a57aa83664b81311.tar.gz busybox-w32-6279aec03d4677424408a515a57aa83664b81311.tar.bz2 busybox-w32-6279aec03d4677424408a515a57aa83664b81311.zip |
libbb: clarify what bb_mode_string() generates
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/mode_string.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/libbb/mode_string.c b/libbb/mode_string.c index 8c12b4684..52abe66f7 100644 --- a/libbb/mode_string.c +++ b/libbb/mode_string.c | |||
@@ -16,16 +16,18 @@ | |||
16 | #error permission bitflag value assumption(s) violated! | 16 | #error permission bitflag value assumption(s) violated! |
17 | #endif | 17 | #endif |
18 | 18 | ||
19 | /* Generate ls-style "mode string" like "-rwsr-xr-x" or "drwxrwxrwt" */ | ||
20 | |||
19 | #if ( S_IFSOCK!= 0140000 ) || ( S_IFLNK != 0120000 ) \ | 21 | #if ( S_IFSOCK!= 0140000 ) || ( S_IFLNK != 0120000 ) \ |
20 | || ( S_IFREG != 0100000 ) || ( S_IFBLK != 0060000 ) \ | 22 | || ( S_IFREG != 0100000 ) || ( S_IFBLK != 0060000 ) \ |
21 | || ( S_IFDIR != 0040000 ) || ( S_IFCHR != 0020000 ) \ | 23 | || ( S_IFDIR != 0040000 ) || ( S_IFCHR != 0020000 ) \ |
22 | || ( S_IFIFO != 0010000 ) | 24 | || ( S_IFIFO != 0010000 ) |
23 | #warning mode type bitflag value assumption(s) violated! falling back to larger version | 25 | # warning mode type bitflag value assumption(s) violated! falling back to larger version |
24 | 26 | ||
25 | #if (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX) == 07777 | 27 | # if (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX) == 07777 |
26 | #undef mode_t | 28 | # undef mode_t |
27 | #define mode_t unsigned short | 29 | # define mode_t unsigned short |
28 | #endif | 30 | # endif |
29 | 31 | ||
30 | static const mode_t mode_flags[] ALIGN4 = { | 32 | static const mode_t mode_flags[] ALIGN4 = { |
31 | S_IRUSR, S_IWUSR, S_IXUSR, S_ISUID, | 33 | S_IRUSR, S_IWUSR, S_IXUSR, S_ISUID, |
@@ -33,17 +35,13 @@ static const mode_t mode_flags[] ALIGN4 = { | |||
33 | S_IROTH, S_IWOTH, S_IXOTH, S_ISVTX | 35 | S_IROTH, S_IWOTH, S_IXOTH, S_ISVTX |
34 | }; | 36 | }; |
35 | 37 | ||
36 | /* The static const char arrays below are duplicated for the two cases | ||
37 | * because moving them ahead of the mode_flags declaration cause a text | ||
38 | * size increase with the gcc version I'm using. */ | ||
39 | |||
40 | /* The previous version used "0pcCd?bB-?l?s???". However, the '0', 'C', | 38 | /* The previous version used "0pcCd?bB-?l?s???". However, the '0', 'C', |
41 | * and 'B' types don't appear to be available on linux. So I removed them. */ | 39 | * and 'B' types don't appear to be available on linux. So I removed them. */ |
42 | static const char type_chars[16] ALIGN1 = "?pc?d?b?-?l?s???"; | 40 | static const char type_chars[16] ALIGN1 = "?pc?d?b?-?l?s???"; |
43 | /***************************************** 0123456789abcdef */ | 41 | /***************************************** 0123456789abcdef */ |
44 | static const char mode_chars[7] ALIGN1 = "rwxSTst"; | 42 | static const char mode_chars[7] ALIGN1 = "rwxSTst"; |
45 | 43 | ||
46 | char* FAST_FUNC bb_mode_string(char buf[12], mode_t mode) | 44 | char* FAST_FUNC bb_mode_string(char buf[11], mode_t mode) |
47 | { | 45 | { |
48 | char *p = buf; | 46 | char *p = buf; |
49 | 47 | ||
@@ -79,7 +77,7 @@ static const char type_chars[16] ALIGN1 = "?pc?d?b?-?l?s???"; | |||
79 | /***************************************** 0123456789abcdef */ | 77 | /***************************************** 0123456789abcdef */ |
80 | static const char mode_chars[7] ALIGN1 = "rwxSTst"; | 78 | static const char mode_chars[7] ALIGN1 = "rwxSTst"; |
81 | 79 | ||
82 | char* FAST_FUNC bb_mode_string(char buf[12], mode_t mode) | 80 | char* FAST_FUNC bb_mode_string(char buf[11], mode_t mode) |
83 | { | 81 | { |
84 | char *p = buf; | 82 | char *p = buf; |
85 | 83 | ||