2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
36 #include <sys/sysmacros.h>
41 timesince(long timesec)
43 long d_since; /* days */
44 long h_since; /* hours */
45 long m_since; /* minutes */
46 long s_since; /* seconds */
48 s_since = timebuf - timesec;
49 d_since = s_since / 86400l ;
50 s_since -= d_since * 86400l ;
51 h_since = s_since / 3600l ;
52 s_since -= h_since * 3600l ;
53 m_since = s_since / 60l ;
54 s_since -= m_since * 60l ;
56 printf("(%05ld.%02ld:%02ld:%02ld)\n",
57 d_since, h_since, m_since, s_since);
61 main(int argc, char **argv)
69 for (i = 1; i < argc; i++) {
71 if( lstat64(argv[i], &sbuf) < 0) {
76 printf(" File: \"%s\"\n", argv[i]);
77 printf(" Size: %-10llu", sbuf.st_size);
79 strcpy(mode,"----------");
80 if (sbuf.st_mode & (S_IEXEC>>6))
82 if (sbuf.st_mode & (S_IWRITE>>6))
84 if (sbuf.st_mode & (S_IREAD>>6))
86 if (sbuf.st_mode & (S_IEXEC>>3))
88 if (sbuf.st_mode & (S_IWRITE>>3))
90 if (sbuf.st_mode & (S_IREAD>>3))
92 if (sbuf.st_mode & S_IEXEC)
94 if (sbuf.st_mode & S_IWRITE)
96 if (sbuf.st_mode & S_IREAD)
98 if (sbuf.st_mode & S_ISVTX)
100 if (sbuf.st_mode & S_ISGID)
102 if (sbuf.st_mode & S_ISUID)
105 printf(" Filetype: ");
106 switch (sbuf.st_mode & S_IFMT) {
116 puts("Character Device");
120 puts("Block Device");
124 puts("Regular File");
128 puts("Symbolic Link");
140 printf(" Mode: (%04o/%s)", sbuf.st_mode & 07777, mode);
141 printf(" Uid: (%d)", sbuf.st_uid);
142 printf(" Gid: (%d)\n", sbuf.st_gid);
143 printf("Device: %2d,%-2d", major(sbuf.st_dev),
145 printf(" Inode: %-10lu", sbuf.st_ino);
146 printf("Links: %-5d", sbuf.st_nlink);
148 if ( ((sbuf.st_mode & S_IFMT) == S_IFCHR)
149 || ((sbuf.st_mode & S_IFMT) == S_IFBLK) )
150 printf(" Device type: %2d,%-2d\n",
151 major(sbuf.st_rdev), minor(sbuf.st_rdev));
155 printf("Access: %.24s",ctime(&sbuf.st_atime));
156 timesince(sbuf.st_atime);
157 printf("Modify: %.24s",ctime(&sbuf.st_mtime));
158 timesince(sbuf.st_mtime);
159 printf("Change: %.24s",ctime(&sbuf.st_ctime));
160 timesince(sbuf.st_ctime);
166 fprintf(stderr, "Usage: lstat64 filename...\n");