print.c (163480) | print.c (177907) |
---|---|
1/*- 2 * Copyright (c) 1989, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Michael Fischbein. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 22 unchanged lines hidden (view full) --- 31 */ 32 33#if 0 34#ifndef lint 35static char sccsid[] = "@(#)print.c 8.4 (Berkeley) 4/17/94"; 36#endif /* not lint */ 37#endif 38#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1989, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Michael Fischbein. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 22 unchanged lines hidden (view full) --- 31 */ 32 33#if 0 34#ifndef lint 35static char sccsid[] = "@(#)print.c 8.4 (Berkeley) 4/17/94"; 36#endif /* not lint */ 37#endif 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/bin/ls/print.c 163480 2006-10-18 10:58:27Z ru $"); | 39__FBSDID("$FreeBSD: head/bin/ls/print.c 177907 2008-04-04 03:57:46Z grog $"); |
40 41#include <sys/param.h> 42#include <sys/stat.h> 43#include <sys/acl.h> 44 45#include <err.h> 46#include <errno.h> 47#include <fts.h> --- 115 unchanged lines hidden (view full) --- 163 * Cache whether or not the filesystem supports ACL's to 164 * avoid expensive syscalls. Try again when we change devices. 165 */ 166 if (haveacls || sp->st_dev != prevdev) { 167 aclmode(buf, p, &haveacls); 168 prevdev = sp->st_dev; 169 } 170 np = p->fts_pointer; | 40 41#include <sys/param.h> 42#include <sys/stat.h> 43#include <sys/acl.h> 44 45#include <err.h> 46#include <errno.h> 47#include <fts.h> --- 115 unchanged lines hidden (view full) --- 163 * Cache whether or not the filesystem supports ACL's to 164 * avoid expensive syscalls. Try again when we change devices. 165 */ 166 if (haveacls || sp->st_dev != prevdev) { 167 aclmode(buf, p, &haveacls); 168 prevdev = sp->st_dev; 169 } 170 np = p->fts_pointer; |
171 (void)printf("%s %*u %-*s %-*s ", buf, dp->s_nlink, | 171 (void)printf("%s %*u %-*s %-*s ", buf, dp->s_nlink, |
172 sp->st_nlink, dp->s_user, np->user, dp->s_group, 173 np->group); 174 if (f_flags) 175 (void)printf("%-*s ", dp->s_flags, np->flags); 176 if (f_label) 177 (void)printf("%-*s ", dp->s_label, np->label); 178 if (S_ISCHR(sp->st_mode) || S_ISBLK(sp->st_mode)) 179 if (minor(sp->st_rdev) > 255 || minor(sp->st_rdev) < 0) --- 52 unchanged lines hidden (view full) --- 232 if (p->fts_link) { 233 printf(", "); 234 chcnt += 2; 235 } 236 } 237 if (chcnt) 238 putchar('\n'); 239} | 172 sp->st_nlink, dp->s_user, np->user, dp->s_group, 173 np->group); 174 if (f_flags) 175 (void)printf("%-*s ", dp->s_flags, np->flags); 176 if (f_label) 177 (void)printf("%-*s ", dp->s_label, np->label); 178 if (S_ISCHR(sp->st_mode) || S_ISBLK(sp->st_mode)) 179 if (minor(sp->st_rdev) > 255 || minor(sp->st_rdev) < 0) --- 52 unchanged lines hidden (view full) --- 232 if (p->fts_link) { 233 printf(", "); 234 chcnt += 2; 235 } 236 } 237 if (chcnt) 238 putchar('\n'); 239} |
240 | 240 |
241void 242printcol(const DISPLAY *dp) 243{ 244 static FTSENT **array; 245 static int lastentries = -1; 246 FTSENT *p; 247 FTSENT **narray; 248 int base; --- 124 unchanged lines hidden (view full) --- 373 static int d_first = -1; 374 375 if (d_first < 0) 376 d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); 377 if (now == 0) 378 now = time(NULL); 379 380#define SIXMONTHS ((365 / 2) * 86400) | 241void 242printcol(const DISPLAY *dp) 243{ 244 static FTSENT **array; 245 static int lastentries = -1; 246 FTSENT *p; 247 FTSENT **narray; 248 int base; --- 124 unchanged lines hidden (view full) --- 373 static int d_first = -1; 374 375 if (d_first < 0) 376 d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); 377 if (now == 0) 378 now = time(NULL); 379 380#define SIXMONTHS ((365 / 2) * 86400) |
381 if (f_sectime) | 381 if (f_timeformat) /* user specified format */ 382 format = f_timeformat; 383 else if (f_sectime) |
382 /* mmm dd hh:mm:ss yyyy || dd mmm hh:mm:ss yyyy */ | 384 /* mmm dd hh:mm:ss yyyy || dd mmm hh:mm:ss yyyy */ |
383 format = d_first ? "%e %b %T %Y " : "%b %e %T %Y "; | 385 format = d_first ? "%e %b %T %Y" : "%b %e %T %Y"; |
384 else if (ftime + SIXMONTHS > now && ftime < now + SIXMONTHS) 385 /* mmm dd hh:mm || dd mmm hh:mm */ | 386 else if (ftime + SIXMONTHS > now && ftime < now + SIXMONTHS) 387 /* mmm dd hh:mm || dd mmm hh:mm */ |
386 format = d_first ? "%e %b %R " : "%b %e %R "; | 388 format = d_first ? "%e %b %R" : "%b %e %R"; |
387 else 388 /* mmm dd yyyy || dd mmm yyyy */ | 389 else 390 /* mmm dd yyyy || dd mmm yyyy */ |
389 format = d_first ? "%e %b %Y " : "%b %e %Y "; | 391 format = d_first ? "%e %b %Y" : "%b %e %Y"; |
390 strftime(longstring, sizeof(longstring), format, localtime(&ftime)); 391 fputs(longstring, stdout); | 392 strftime(longstring, sizeof(longstring), format, localtime(&ftime)); 393 fputs(longstring, stdout); |
394 fputc(' ', stdout); |
|
392} 393 394static int 395printtype(u_int mode) 396{ 397 398 if (f_slash) { 399 if ((mode & S_IFMT) == S_IFDIR) { --- 220 unchanged lines hidden (view full) --- 620 /* 621 * Add a + after the standard rwxrwxrwx mode if the file has an 622 * extended ACL. strmode() reserves space at the end of the string. 623 */ 624 if (p->fts_level == FTS_ROOTLEVEL) 625 snprintf(name, sizeof(name), "%s", p->fts_name); 626 else 627 snprintf(name, sizeof(name), "%s/%s", | 395} 396 397static int 398printtype(u_int mode) 399{ 400 401 if (f_slash) { 402 if ((mode & S_IFMT) == S_IFDIR) { --- 220 unchanged lines hidden (view full) --- 623 /* 624 * Add a + after the standard rwxrwxrwx mode if the file has an 625 * extended ACL. strmode() reserves space at the end of the string. 626 */ 627 if (p->fts_level == FTS_ROOTLEVEL) 628 snprintf(name, sizeof(name), "%s", p->fts_name); 629 else 630 snprintf(name, sizeof(name), "%s/%s", |
628 p->fts_parent->fts_accpath, p->fts_name); | 631 p->fts_parent->fts_accpath, p->fts_name); |
629 /* 630 * We have no way to tell whether a symbolic link has an ACL since 631 * pathconf() and acl_get_file() both follow them. They also don't 632 * support whiteouts. 633 */ 634 if (S_ISLNK(p->fts_statp->st_mode) || S_ISWHT(p->fts_statp->st_mode)) { 635 *haveacls = 1; 636 return; --- 28 unchanged lines hidden --- | 632 /* 633 * We have no way to tell whether a symbolic link has an ACL since 634 * pathconf() and acl_get_file() both follow them. They also don't 635 * support whiteouts. 636 */ 637 if (S_ISLNK(p->fts_statp->st_mode) || S_ISWHT(p->fts_statp->st_mode)) { 638 *haveacls = 1; 639 return; --- 28 unchanged lines hidden --- |