Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coreutils/ls.c2
-rw-r--r--include/libbb.h5
-rw-r--r--libbb/mode_string.c20
3 files changed, 12 insertions, 15 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 9a1264e65..48f5eb482 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -504,7 +504,7 @@ static NOINLINE unsigned display_single(const struct dnode *dn)
if (opt & OPT_l) {
/* long listing: show mode */
char modestr[12];
- column += printf("%-10s ", (char *) bb_mode_string(modestr, dn->dn_mode));
+ column += printf("%-10s ", bb_mode_string(modestr, dn->dn_mode));
/* long listing: show number of links */
column += printf("%4lu ", (long) dn->dn_nlink);
/* long listing: show user/group */
diff --git a/include/libbb.h b/include/libbb.h
index b0312e5d4..dfcaa05ec 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -440,9 +440,8 @@ void *xmmap_anon(size_t size) FAST_FUNC;
# define cached_pagesize(var) (var)
#endif
-
-//TODO: supply a pointer to char[11] buffer (avoid statics)?
-extern char *bb_mode_string(char buf[12], mode_t mode) FAST_FUNC;
+/* Generate ls-style "mode string" like "-rwsr-xr-x" or "drwxrwxrwt" */
+extern char *bb_mode_string(char buf[11], mode_t mode) FAST_FUNC;
extern int is_directory(const char *name, int followLinks) FAST_FUNC;
enum { /* cp.c, mv.c, install.c depend on these values. CAREFUL when changing them! */
FILEUTILS_PRESERVE_STATUS = 1 << 0, /* -p */
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;