summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorpst <pst@FreeBSD.org>1994-09-19 07:49:56 +0000
committerpst <pst@FreeBSD.org>1994-09-19 07:49:56 +0000
commit7963d9a8035c8f4510fd75bb0ec76c0031bd7abc (patch)
treecf0a2a31ce925702a635a6801dce68c240bd4a56 /bin
parent9bb294712c868682f12e34bd7cd578b09226e274 (diff)
downloadFreeBSD-src-7963d9a8035c8f4510fd75bb0ec76c0031bd7abc.zip
FreeBSD-src-7963d9a8035c8f4510fd75bb0ec76c0031bd7abc.tar.gz
Add support for '-k' option to print file allocation space in 'K' instead of
system blocks. This is semi-original code, not the same way this crufty option was handled in FreeBSD 1.x.
Diffstat (limited to 'bin')
-rw-r--r--bin/ls/ls.13
-rw-r--r--bin/ls/ls.c10
2 files changed, 11 insertions, 2 deletions
diff --git a/bin/ls/ls.1 b/bin/ls/ls.1
index cb45555..f43ae52 100644
--- a/bin/ls/ls.1
+++ b/bin/ls/ls.1
@@ -104,6 +104,9 @@ symbolic links in the argument list are not indirected through.
Output is not sorted.
.It Fl i
For each file, print the file's file serial number (inode number).
+.It Fl k
+If the 's' option is specified, print the file size allocation in kilobytes,
+not blocks.
.It Fl l
(The lowercase letter ``ell.'') List in long format. (See below.)
If the output is to a terminal, a total sum for all the file
diff --git a/bin/ls/ls.c b/bin/ls/ls.c
index 1cea616..db1ee39 100644
--- a/bin/ls/ls.c
+++ b/bin/ls/ls.c
@@ -75,6 +75,7 @@ int f_accesstime; /* use time of last access */
int f_column; /* columnated format */
int f_flags; /* show flags associated with a file */
int f_inode; /* print inode */
+int f_kblocks; /* print size in kilobytes */
int f_listdir; /* list actual directory, not contents */
int f_listdot; /* list files beginning with . */
int f_longform; /* long listing format */
@@ -119,7 +120,7 @@ main(argc, argv)
f_listdot = 1;
fts_options = FTS_PHYSICAL;
- while ((ch = getopt(argc, argv, "1ACFLRTacdfgiloqrstu")) != EOF) {
+ while ((ch = getopt(argc, argv, "1ACFLRTacdfgikloqrstu")) != EOF) {
switch (ch) {
/*
* The -1, -C and -l options all override each other so shell
@@ -175,6 +176,9 @@ main(argc, argv)
case 'i':
f_inode = 1;
break;
+ case 'k':
+ f_kblocks = 1;
+ break;
case 'o':
f_flags = 1;
break;
@@ -218,7 +222,9 @@ main(argc, argv)
/* If -l or -s, figure out block size. */
if (f_longform || f_size) {
(void)getbsize(&notused, &blocksize);
- blocksize /= 512;
+ blocksize /= 512;
+ if (f_kblocks)
+ blocksize *= 2;
}
/* Select a sort function. */
OpenPOWER on IntegriCloud