8982 Support building with OpenSSL 1.1
[unleashed.git] / usr / src / cmd / truss / stat.c
blobf5ecab0c62c2264269eaf0c3922825c203abc96f
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
30 #define _SYSCALL32
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <unistd.h>
35 #include <sys/types.h>
36 #include <sys/stat.h>
37 #include <sys/signal.h>
38 #include <sys/fault.h>
39 #include <sys/syscall.h>
40 #include <libproc.h>
41 #include "ramdata.h"
42 #include "proto.h"
44 void show_stat32(private_t *, long);
45 #ifdef _LP64
46 void show_stat64(private_t *, long);
47 #endif
49 void
50 show_stat(private_t *pri, long offset)
52 #ifdef _LP64
53 if (data_model == PR_MODEL_LP64)
54 show_stat64(pri, offset);
55 else
56 show_stat32(pri, offset);
57 #else
58 show_stat32(pri, offset);
59 #endif
62 void
63 show_stat32(private_t *pri, long offset)
65 struct stat32 statb;
66 timestruc_t ts;
68 if (offset != NULL &&
69 Pread(Proc, &statb, sizeof (statb), offset) == sizeof (statb)) {
70 (void) printf(
71 "%s d=0x%.8X i=%-5u m=0%.6o l=%-2u u=%-5u g=%-5u",
72 pri->pname,
73 statb.st_dev,
74 statb.st_ino,
75 statb.st_mode,
76 statb.st_nlink,
77 statb.st_uid,
78 statb.st_gid);
80 switch (statb.st_mode & S_IFMT) {
81 case S_IFCHR:
82 case S_IFBLK:
83 (void) printf(" rdev=0x%.8X\n", statb.st_rdev);
84 break;
85 default:
86 (void) printf(" sz=%u\n", statb.st_size);
87 break;
90 TIMESPEC32_TO_TIMESPEC(&ts, &statb.st_atim);
91 prtimestruc(pri, "at = ", &ts);
92 TIMESPEC32_TO_TIMESPEC(&ts, &statb.st_mtim);
93 prtimestruc(pri, "mt = ", &ts);
94 TIMESPEC32_TO_TIMESPEC(&ts, &statb.st_ctim);
95 prtimestruc(pri, "ct = ", &ts);
97 (void) printf(
98 "%s bsz=%-5d blks=%-5d fs=%.*s\n",
99 pri->pname,
100 statb.st_blksize,
101 statb.st_blocks,
102 _ST_FSTYPSZ,
103 statb.st_fstype);
107 void
108 show_stat64_32(private_t *pri, long offset)
110 struct stat64_32 statb;
111 timestruc_t ts;
113 if (offset != NULL &&
114 Pread(Proc, &statb, sizeof (statb), offset) == sizeof (statb)) {
115 (void) printf(
116 "%s d=0x%.8X i=%-5llu m=0%.6o l=%-2u u=%-5u g=%-5u",
117 pri->pname,
118 statb.st_dev,
119 (u_longlong_t)statb.st_ino,
120 statb.st_mode,
121 statb.st_nlink,
122 statb.st_uid,
123 statb.st_gid);
125 switch (statb.st_mode & S_IFMT) {
126 case S_IFCHR:
127 case S_IFBLK:
128 (void) printf(" rdev=0x%.8X\n", statb.st_rdev);
129 break;
130 default:
131 (void) printf(" sz=%llu\n", (long long)statb.st_size);
132 break;
135 TIMESPEC32_TO_TIMESPEC(&ts, &statb.st_atim);
136 prtimestruc(pri, "at = ", &ts);
137 TIMESPEC32_TO_TIMESPEC(&ts, &statb.st_mtim);
138 prtimestruc(pri, "mt = ", &ts);
139 TIMESPEC32_TO_TIMESPEC(&ts, &statb.st_ctim);
140 prtimestruc(pri, "ct = ", &ts);
142 (void) printf("%s bsz=%-5d blks=%-5lld fs=%.*s\n",
143 pri->pname,
144 statb.st_blksize,
145 (longlong_t)statb.st_blocks,
146 _ST_FSTYPSZ,
147 statb.st_fstype);
151 #ifdef _LP64
152 void
153 show_stat64(private_t *pri, long offset)
155 struct stat64 statb;
157 if (offset != NULL &&
158 Pread(Proc, &statb, sizeof (statb), offset) == sizeof (statb)) {
159 (void) printf(
160 "%s d=0x%.16lX i=%-5lu m=0%.6o l=%-2u u=%-5u g=%-5u",
161 pri->pname,
162 statb.st_dev,
163 statb.st_ino,
164 statb.st_mode,
165 statb.st_nlink,
166 statb.st_uid,
167 statb.st_gid);
169 switch (statb.st_mode & S_IFMT) {
170 case S_IFCHR:
171 case S_IFBLK:
172 (void) printf(" rdev=0x%.16lX\n", statb.st_rdev);
173 break;
174 default:
175 (void) printf(" sz=%lu\n", statb.st_size);
176 break;
179 prtimestruc(pri, "at = ", (timestruc_t *)&statb.st_atim);
180 prtimestruc(pri, "mt = ", (timestruc_t *)&statb.st_mtim);
181 prtimestruc(pri, "ct = ", (timestruc_t *)&statb.st_ctim);
183 (void) printf(
184 "%s bsz=%-5d blks=%-5ld fs=%.*s\n",
185 pri->pname,
186 statb.st_blksize,
187 statb.st_blocks,
188 _ST_FSTYPSZ,
189 statb.st_fstype);
192 #endif /* _LP64 */