libbb: clarify what bb_mode_string() generates
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
		@@ -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;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user