int aflg
, dflg
, lflg
, sflg
, tflg
, uflg
, iflg
, fflg
, gflg
, cflg
;
struct lbuf
*flist
[NFILES
];
struct lbuf
**lastp
= flist
;
struct lbuf
**firstp
= flist
;
register struct lbuf
*ep
, **ep1
;
register struct lbuf
**slastp
;
year
= lb
.lmtime
- 6L*30L*24L*60L*60L; /* 6 months ago */
if (--argc
> 0 && *argv
[1] == '-') {
while (*++*argv
) switch (**argv
) {
for (i
=0; i
< argc
; i
++) {
if ((ep
= gstat(*++argv
, 1))==NULL
)
qsort(firstp
, lastp
- firstp
, sizeof *lastp
, compar
);
for (epp
=firstp
; epp
<slastp
; epp
++) {
if (ep
->ltype
=='d' && dflg
==0 || fflg
) {
printf("\n%s:\n", ep
->ln
.namep
);
qsort(slastp
,lastp
- slastp
,sizeof *lastp
,compar
);
printf("total %D\n", tblocks
);
for (ep1
=slastp
; ep1
<lastp
; ep1
++)
struct { char dminor
, dmajor
;};
printf("%4D ", nblock(p
->lsize
));
if (p
->ltype
=='b' || p
->ltype
=='c')
printf("%3d,%3d", major((int)p
->lsize
), minor((int)p
->lsize
));
printf("%7ld", p
->lsize
);
printf(" %-7.7s %-4.4s ", cp
+4, cp
+20); else
printf(" %-12.12s ", cp
+4);
printf("%s\n", p
->ln
.namep
);
printf("%.14s\n", p
->ln
.lname
);
while((c
=fgetc(pwdf
)) != '\n') {
int m1
[] = { 1, S_IREAD
>>0, 'r', '-' };
int m2
[] = { 1, S_IWRITE
>>0, 'w', '-' };
int m3
[] = { 2, S_ISUID
, 's', S_IEXEC
>>0, 'x', '-' };
int m4
[] = { 1, S_IREAD
>>3, 'r', '-' };
int m5
[] = { 1, S_IWRITE
>>3, 'w', '-' };
int m6
[] = { 2, S_ISGID
, 's', S_IEXEC
>>3, 'x', '-' };
int m7
[] = { 1, S_IREAD
>>6, 'r', '-' };
int m8
[] = { 1, S_IWRITE
>>6, 'w', '-' };
int m9
[] = { 2, S_ISVTX
, 't', S_IEXEC
>>6, 'x', '-' };
int *m
[] = { m1
, m2
, m3
, m4
, m5
, m6
, m7
, m8
, m9
};
for (mp
= &m
[0]; mp
< &m
[sizeof(m
)/sizeof(m
[0])];)
while (--n
>=0 && (flags
&*pairp
++)==0)
static struct direct dentry
;
register struct lbuf
*ep
;
if ((dirf
= fopen(dir
, "r")) == NULL
) {
printf("%s unreadable\n", dir
);
if (fread((char *)&dentry
, sizeof(dentry
), 1, dirf
) != 1)
|| aflg
==0 && dentry
.d_name
[0]=='.' && (dentry
.d_name
[1]=='\0'
|| dentry
.d_name
[1]=='.' && dentry
.d_name
[2]=='\0'))
ep
= gstat(makename(dir
, dentry
.d_name
), 0);
ep
->ln
.lname
[j
] = dentry
.d_name
[j
];
register struct lbuf
*rep
;
rep
= (struct lbuf
*)malloc(sizeof(struct lbuf
));
fprintf(stderr
, "ls: out of memory\n");
if (lastp
>= &flist
[NFILES
]) {
fprintf(stderr
, "ls: too many files\n");
if (stat(file
, &statb
)<0) {
printf("%s not found\n", file
);
rep
->lnum
= statb
.st_ino
;
rep
->lsize
= statb
.st_size
;
switch(statb
.st_mode
&S_IFMT
) {
rep
->lsize
= statb
.st_rdev
;
rep
->lsize
= statb
.st_rdev
;
rep
->lflags
= statb
.st_mode
& ~S_IFMT
;
rep
->luid
= statb
.st_uid
;
rep
->lgid
= statb
.st_gid
;
rep
->lnl
= statb
.st_nlink
;
rep
->lmtime
= statb
.st_atime
;
rep
->lmtime
= statb
.st_ctime
;
rep
->lmtime
= statb
.st_mtime
;
tblocks
+= nblock(statb
.st_size
);
struct lbuf
**pp1
, **pp2
;
register struct lbuf
*p1
, *p2
;
if (p1
->lflags
&ISARG
&& p1
->ltype
=='d') {
if (!(p2
->lflags
&ISARG
&& p2
->ltype
=='d'))
if (p2
->lflags
&ISARG
&& p2
->ltype
=='d')
if(p2
->lmtime
== p1
->lmtime
)
if(p2
->lmtime
> p1
->lmtime
)
return(rflg
* strcmp(p1
->lflags
&ISARG
? p1
->ln
.namep
: p1
->ln
.lname
,
p2
->lflags
&ISARG
? p2
->ln
.namep
: p2
->ln
.lname
));