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) |
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 @@ #error permission bitflag value assumption(s) violated! #endif +/* Generate ls-style "mode string" like "-rwsr-xr-x" or "drwxrwxrwt" */ + #if ( S_IFSOCK!= 0140000 ) || ( S_IFLNK != 0120000 ) \ || ( S_IFREG != 0100000 ) || ( S_IFBLK != 0060000 ) \ || ( S_IFDIR != 0040000 ) || ( S_IFCHR != 0020000 ) \ || ( S_IFIFO != 0010000 ) -#warning mode type bitflag value assumption(s) violated! falling back to larger version +# warning mode type bitflag value assumption(s) violated! falling back to larger version -#if (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX) == 07777 -#undef mode_t -#define mode_t unsigned short -#endif +# if (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX) == 07777 +# undef mode_t +# define mode_t unsigned short +# endif static const mode_t mode_flags[] ALIGN4 = { S_IRUSR, S_IWUSR, S_IXUSR, S_ISUID, @@ -33,17 +35,13 @@ static const mode_t mode_flags[] ALIGN4 = { S_IROTH, S_IWOTH, S_IXOTH, S_ISVTX }; -/* The static const char arrays below are duplicated for the two cases - * because moving them ahead of the mode_flags declaration cause a text - * size increase with the gcc version I'm using. */ - /* The previous version used "0pcCd?bB-?l?s???". However, the '0', 'C', * and 'B' types don't appear to be available on linux. So I removed them. */ static const char type_chars[16] ALIGN1 = "?pc?d?b?-?l?s???"; /***************************************** 0123456789abcdef */ static const char mode_chars[7] ALIGN1 = "rwxSTst"; -char* FAST_FUNC bb_mode_string(char buf[12], mode_t mode) +char* FAST_FUNC bb_mode_string(char buf[11], mode_t mode) { char *p = buf; @@ -79,7 +77,7 @@ static const char type_chars[16] ALIGN1 = "?pc?d?b?-?l?s???"; /***************************************** 0123456789abcdef */ static const char mode_chars[7] ALIGN1 = "rwxSTst"; -char* FAST_FUNC bb_mode_string(char buf[12], mode_t mode) +char* FAST_FUNC bb_mode_string(char buf[11], mode_t mode) { char *p = buf; |