diff options
author | Rob Landley <rob@landley.net> | 2019-09-17 05:32:21 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-09-17 05:32:21 -0500 |
commit | 861d1c76cd2ddf3c2feab0cd439f325b96541610 (patch) | |
tree | 716bccd100004f9233bb9d2c1e293c87eb5be967 | |
parent | f921a00032aa3baba92a034104b2a538097cda73 (diff) | |
download | toybox-861d1c76cd2ddf3c2feab0cd439f325b96541610.tar.gz |
Implement -s.
-rw-r--r-- | toys/posix/file.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/toys/posix/file.c b/toys/posix/file.c index 17bc45f7..869bf108 100644 --- a/toys/posix/file.c +++ b/toys/posix/file.c @@ -455,8 +455,12 @@ void file_main(void) xprintf("%s: %*s", name, (int)(TT.max_name_len - strlen(name)), ""); sb.st_size = 0; - if (fd || !((toys.optflags & FLAG_L) ? stat : lstat)(name, &sb)) { - if (fd || S_ISREG(sb.st_mode)) { + if (fd || !(FLAG(L) ? stat : lstat)(name, &sb)) { + if (!fd && !FLAG(s) && (S_ISBLK(sb.st_mode) || S_ISCHR(sb.st_mode))) { + sprintf(what = toybuf, "%s special (%u/%u)", + S_ISBLK(sb.st_mode) ? "block" : "character", + dev_major(sb.st_rdev), dev_minor(sb.st_rdev)); + } else if (fd || S_ISREG(sb.st_mode)) { TT.len = sb.st_size; // This test identifies an empty file we don't have permission to read if (!fd && !sb.st_size) what = "empty"; @@ -466,10 +470,6 @@ void file_main(void) continue; } } else if (S_ISFIFO(sb.st_mode)) what = "fifo"; - else if (S_ISBLK(sb.st_mode) || S_ISCHR(sb.st_mode)) - sprintf(what = toybuf, "%s special (%u/%u)", - S_ISBLK(sb.st_mode) ? "block" : "character", - dev_major(sb.st_rdev), dev_minor(sb.st_rdev)); else if (S_ISDIR(sb.st_mode)) what = "directory"; else if (S_ISSOCK(sb.st_mode)) what = "socket"; else if (S_ISLNK(sb.st_mode)) { |