aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-09-17 17:10:38 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-09-17 17:10:38 +0200
commit6279aec03d4677424408a515a57aa83664b81311 (patch)
treecd45810d883981cb1b7337e27a41c3430988aa30 /libbb
parent3a65435eaa845d45bbea176701726f27a88e8498 (diff)
downloadbusybox-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.c20
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
30static const mode_t mode_flags[] ALIGN4 = { 32static 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. */
42static const char type_chars[16] ALIGN1 = "?pc?d?b?-?l?s???"; 40static const char type_chars[16] ALIGN1 = "?pc?d?b?-?l?s???";
43/***************************************** 0123456789abcdef */ 41/***************************************** 0123456789abcdef */
44static const char mode_chars[7] ALIGN1 = "rwxSTst"; 42static const char mode_chars[7] ALIGN1 = "rwxSTst";
45 43
46char* FAST_FUNC bb_mode_string(char buf[12], mode_t mode) 44char* 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 */
80static const char mode_chars[7] ALIGN1 = "rwxSTst"; 78static const char mode_chars[7] ALIGN1 = "rwxSTst";
81 79
82char* FAST_FUNC bb_mode_string(char buf[12], mode_t mode) 80char* FAST_FUNC bb_mode_string(char buf[11], mode_t mode)
83{ 81{
84 char *p = buf; 82 char *p = buf;
85 83