2 * Copyright (c) 2000-2002 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include <sys/sysmacros.h>
30 timesince(long timesec)
32 long d_since; /* days */
33 long h_since; /* hours */
34 long m_since; /* minutes */
35 long s_since; /* seconds */
37 s_since = timebuf - timesec;
38 d_since = s_since / 86400l ;
39 s_since -= d_since * 86400l ;
40 h_since = s_since / 3600l ;
41 s_since -= h_since * 3600l ;
42 m_since = s_since / 60l ;
43 s_since -= m_since * 60l ;
45 printf("(%05ld.%02ld:%02ld:%02ld)\n",
46 d_since, h_since, m_since, s_since);
52 fprintf(stderr, "Usage: lstat64 [-t] filename ...\n");
57 main(int argc, char **argv)
63 while ((c = getopt(argc, argv, "t")) != EOF) {
79 for (i = optind; i < argc; i++) {
80 char mode[] = "----------";
82 if( lstat64(argv[i], &sbuf) < 0) {
88 printf("%s %llu ", argv[i], (unsigned long long)sbuf.st_size);
91 printf(" File: \"%s\"\n", argv[i]);
92 printf(" Size: %-10llu", (unsigned long long)sbuf.st_size);
95 if (sbuf.st_mode & S_IXOTH)
97 if (sbuf.st_mode & S_IWOTH)
99 if (sbuf.st_mode & S_IROTH)
101 if (sbuf.st_mode & S_IXGRP)
103 if (sbuf.st_mode & S_IWGRP)
105 if (sbuf.st_mode & S_IRGRP)
107 if (sbuf.st_mode & S_IXUSR)
109 if (sbuf.st_mode & S_IWUSR)
111 if (sbuf.st_mode & S_IRUSR)
113 if (sbuf.st_mode & S_ISVTX)
115 if (sbuf.st_mode & S_ISGID)
117 if (sbuf.st_mode & S_ISUID)
121 printf(" Filetype: ");
122 switch (sbuf.st_mode & S_IFMT) {
135 puts("Character Device");
140 puts("Block Device");
145 puts("Regular File");
150 puts("Symbolic Link");
165 printf("%s %d,%d\n", mode, (int)sbuf.st_uid, (int)sbuf.st_gid);
169 printf(" Mode: (%04o/%s)", (unsigned int)(sbuf.st_mode & 07777), mode);
170 printf(" Uid: (%d)", (int)sbuf.st_uid);
171 printf(" Gid: (%d)\n", (int)sbuf.st_gid);
172 printf("Device: %2d,%-2d", major(sbuf.st_dev),
174 printf(" Inode: %-9llu", (unsigned long long)sbuf.st_ino);
175 printf(" Links: %-5ld", (long)sbuf.st_nlink);
177 if ( ((sbuf.st_mode & S_IFMT) == S_IFCHR)
178 || ((sbuf.st_mode & S_IFMT) == S_IFBLK) )
179 printf(" Device type: %2d,%-2d\n",
180 major(sbuf.st_rdev), minor(sbuf.st_rdev));
184 printf("Access: %.24s",ctime(&sbuf.st_atime));
185 timesince(sbuf.st_atime);
186 printf("Modify: %.24s",ctime(&sbuf.st_mtime));
187 timesince(sbuf.st_mtime);
188 printf("Change: %.24s",ctime(&sbuf.st_ctime));
189 timesince(sbuf.st_ctime);