SCCS-vsn: bin/ls/ls.c 5.33
SCCS-vsn: bin/ls/ls.h 5.8
SCCS-vsn: bin/ls/print.c 5.15
SCCS-vsn: bin/ls/util.c 5.5
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)ls.c 5.32 (Berkeley) %G%";
+static char sccsid[] = "@(#)ls.c 5.33 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
int f_group; /* show group ownership of a file */
int f_ignorelink; /* indirect through symbolic link operands */
int f_inode; /* print inode */
int f_group; /* show group ownership of a file */
int f_ignorelink; /* indirect through symbolic link operands */
int f_inode; /* print inode */
+int f_kblocks; /* print size in kilobytes */
int f_listalldot; /* list . and .. as well */
int f_listdir; /* list actual directory, not contents */
int f_listdot; /* list files beginning with . */
int f_listalldot; /* list . and .. as well */
int f_listdir; /* list actual directory, not contents */
int f_listdot; /* list files beginning with . */
if (!getuid())
f_listdot = 1;
if (!getuid())
f_listdot = 1;
- while ((ch = getopt(argc, argv, "1ACFLRacdgilqrstu")) != EOF) {
+ while ((ch = getopt(argc, argv, "1ACFLRacdgiklqrstu")) != EOF) {
switch (ch) {
/*
* -1, -C and -l all override each other
switch (ch) {
/*
* -1, -C and -l all override each other
case 'i':
f_inode = 1;
break;
case 'i':
f_inode = 1;
break;
+ case 'k':
+ f_kblocks = 1;
+ break;
case 'q':
f_nonprint = 1;
break;
case 'q':
f_nonprint = 1;
break;
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#)ls.h 5.7 (Berkeley) %G%
+ * @(#)ls.h 5.8 (Berkeley) %G%
*/
typedef struct _lsstruct {
*/
typedef struct _lsstruct {
extern int f_accesstime; /* use time of last access */
extern int f_group; /* show group ownership of a file */
extern int f_inode; /* print inode */
extern int f_accesstime; /* use time of last access */
extern int f_group; /* show group ownership of a file */
extern int f_inode; /* print inode */
+extern int f_kblocks; /* print size in kilobytes */
extern int f_longform; /* long listing format */
extern int f_singlecol; /* use single column output */
extern int f_size; /* list size in short listing */
extern int f_longform; /* long listing format */
extern int f_singlecol; /* use single column output */
extern int f_size; /* list size in short listing */
-static char sccsid[] = "@(#)print.c 5.14 (Berkeley) %G%";
+static char sccsid[] = "@(#)print.c 5.15 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
register int num;
{
if (f_total)
register int num;
{
if (f_total)
- (void)printf("total %lu\n", stats[0].lstat.st_btotal);
+ (void)printf("total %lu\n", f_kblocks ?
+ howmany(stats[0].lstat.st_btotal, 2) :
+ stats[0].lstat.st_btotal);
for (; num--; ++stats) {
if (f_inode)
(void)printf("%6lu ", stats->lstat.st_ino);
if (f_size)
for (; num--; ++stats) {
if (f_inode)
(void)printf("%6lu ", stats->lstat.st_ino);
if (f_size)
- (void)printf("%4ld ", stats->lstat.st_blocks);
+ (void)printf("%4ld ", f_kblocks ?
+ howmany(stats->lstat.st_blocks, 2) :
+ stats->lstat.st_blocks);
printperms(stats->lstat.st_mode);
printperms(stats->lstat.st_mode);
- (void)printf("%3d ", stats->lstat.st_nlink);
+ (void)printf("%3u ", stats->lstat.st_nlink);
printowner(stats->lstat.st_uid);
if (f_group)
printgrp(stats->lstat.st_gid);
printowner(stats->lstat.st_uid);
if (f_group)
printgrp(stats->lstat.st_gid);
++numrows;
if (f_size && f_total)
++numrows;
if (f_size && f_total)
- (void)printf("total %lu\n", stats[0].lstat.st_btotal);
+ (void)printf("total %lu\n", f_kblocks ?
+ howmany(stats[0].lstat.st_btotal, 2) :
+ stats[0].lstat.st_btotal);
for (row = 0; row < numrows; ++row) {
endcol = colwidth;
for (base = row, chcnt = col = 0; col < numcols; ++col) {
for (row = 0; row < numrows; ++row) {
endcol = colwidth;
for (base = row, chcnt = col = 0; col < numcols; ++col) {
if (f_inode)
chcnt += printf("%5lu ", lp->lstat.st_ino);
if (f_size)
if (f_inode)
chcnt += printf("%5lu ", lp->lstat.st_ino);
if (f_size)
- chcnt += printf("%4ld ", lp->lstat.st_blocks);
+ chcnt += printf("%4ld ", f_kblocks ?
+ howmany(lp->lstat.st_blocks, 2) : lp->lstat.st_blocks);
chcnt += printf("%s", lp->name);
if (f_type)
chcnt += printtype(lp->lstat.st_mode);
chcnt += printf("%s", lp->name);
if (f_type)
chcnt += printtype(lp->lstat.st_mode);
-static char sccsid[] = "@(#)util.c 5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)util.c 5.5 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
- (void)fprintf(stderr, "usage: ls [-1ACFLRacdgilqrstu] [file ...]\n");
+ (void)fprintf(stderr, "usage: ls [-1ACFLRacdgiklqrstu] [file ...]\n");