17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
58fd04b83SRoger A. Faulkner * Common Development and Distribution License (the "License").
68fd04b83SRoger A. Faulkner * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
218fd04b83SRoger A. Faulkner
227c478bd9Sstevel@tonic-gate /*
238fd04b83SRoger A. Faulkner * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28*27aa4812SToomas Soome /* All Rights Reserved */
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate #define _SYSCALL32
317c478bd9Sstevel@tonic-gate
327c478bd9Sstevel@tonic-gate #include <stdio.h>
337c478bd9Sstevel@tonic-gate #include <stdlib.h>
347c478bd9Sstevel@tonic-gate #include <unistd.h>
357c478bd9Sstevel@tonic-gate #include <sys/types.h>
367c478bd9Sstevel@tonic-gate #include <sys/stat.h>
377c478bd9Sstevel@tonic-gate #include <sys/signal.h>
387c478bd9Sstevel@tonic-gate #include <sys/fault.h>
397c478bd9Sstevel@tonic-gate #include <sys/syscall.h>
407c478bd9Sstevel@tonic-gate #include <libproc.h>
417c478bd9Sstevel@tonic-gate #include "ramdata.h"
427c478bd9Sstevel@tonic-gate #include "proto.h"
437c478bd9Sstevel@tonic-gate
447c478bd9Sstevel@tonic-gate void show_stat32(private_t *, long);
457c478bd9Sstevel@tonic-gate void show_stat64(private_t *, long);
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gate void
show_stat(private_t * pri,long offset)487c478bd9Sstevel@tonic-gate show_stat(private_t *pri, long offset)
497c478bd9Sstevel@tonic-gate {
507c478bd9Sstevel@tonic-gate if (data_model == PR_MODEL_LP64)
517c478bd9Sstevel@tonic-gate show_stat64(pri, offset);
527c478bd9Sstevel@tonic-gate else
537c478bd9Sstevel@tonic-gate show_stat32(pri, offset);
547c478bd9Sstevel@tonic-gate }
557c478bd9Sstevel@tonic-gate
567c478bd9Sstevel@tonic-gate void
show_stat32(private_t * pri,long offset)577c478bd9Sstevel@tonic-gate show_stat32(private_t *pri, long offset)
587c478bd9Sstevel@tonic-gate {
597c478bd9Sstevel@tonic-gate struct stat32 statb;
607c478bd9Sstevel@tonic-gate timestruc_t ts;
617c478bd9Sstevel@tonic-gate
62*27aa4812SToomas Soome if (offset != 0 &&
637c478bd9Sstevel@tonic-gate Pread(Proc, &statb, sizeof (statb), offset) == sizeof (statb)) {
647c478bd9Sstevel@tonic-gate (void) printf(
657c478bd9Sstevel@tonic-gate "%s d=0x%.8X i=%-5u m=0%.6o l=%-2u u=%-5u g=%-5u",
667c478bd9Sstevel@tonic-gate pri->pname,
677c478bd9Sstevel@tonic-gate statb.st_dev,
687c478bd9Sstevel@tonic-gate statb.st_ino,
697c478bd9Sstevel@tonic-gate statb.st_mode,
707c478bd9Sstevel@tonic-gate statb.st_nlink,
717c478bd9Sstevel@tonic-gate statb.st_uid,
727c478bd9Sstevel@tonic-gate statb.st_gid);
737c478bd9Sstevel@tonic-gate
747c478bd9Sstevel@tonic-gate switch (statb.st_mode & S_IFMT) {
757c478bd9Sstevel@tonic-gate case S_IFCHR:
767c478bd9Sstevel@tonic-gate case S_IFBLK:
777c478bd9Sstevel@tonic-gate (void) printf(" rdev=0x%.8X\n", statb.st_rdev);
787c478bd9Sstevel@tonic-gate break;
797c478bd9Sstevel@tonic-gate default:
807c478bd9Sstevel@tonic-gate (void) printf(" sz=%u\n", statb.st_size);
817c478bd9Sstevel@tonic-gate break;
827c478bd9Sstevel@tonic-gate }
837c478bd9Sstevel@tonic-gate
847c478bd9Sstevel@tonic-gate TIMESPEC32_TO_TIMESPEC(&ts, &statb.st_atim);
857c478bd9Sstevel@tonic-gate prtimestruc(pri, "at = ", &ts);
867c478bd9Sstevel@tonic-gate TIMESPEC32_TO_TIMESPEC(&ts, &statb.st_mtim);
877c478bd9Sstevel@tonic-gate prtimestruc(pri, "mt = ", &ts);
887c478bd9Sstevel@tonic-gate TIMESPEC32_TO_TIMESPEC(&ts, &statb.st_ctim);
897c478bd9Sstevel@tonic-gate prtimestruc(pri, "ct = ", &ts);
907c478bd9Sstevel@tonic-gate
917c478bd9Sstevel@tonic-gate (void) printf(
927c478bd9Sstevel@tonic-gate "%s bsz=%-5d blks=%-5d fs=%.*s\n",
937c478bd9Sstevel@tonic-gate pri->pname,
947c478bd9Sstevel@tonic-gate statb.st_blksize,
957c478bd9Sstevel@tonic-gate statb.st_blocks,
967c478bd9Sstevel@tonic-gate _ST_FSTYPSZ,
977c478bd9Sstevel@tonic-gate statb.st_fstype);
987c478bd9Sstevel@tonic-gate }
997c478bd9Sstevel@tonic-gate }
1007c478bd9Sstevel@tonic-gate
1017c478bd9Sstevel@tonic-gate void
show_stat64_32(private_t * pri,long offset)1027c478bd9Sstevel@tonic-gate show_stat64_32(private_t *pri, long offset)
1037c478bd9Sstevel@tonic-gate {
1047c478bd9Sstevel@tonic-gate struct stat64_32 statb;
1057c478bd9Sstevel@tonic-gate timestruc_t ts;
1067c478bd9Sstevel@tonic-gate
107*27aa4812SToomas Soome if (offset != 0 &&
1087c478bd9Sstevel@tonic-gate Pread(Proc, &statb, sizeof (statb), offset) == sizeof (statb)) {
1097c478bd9Sstevel@tonic-gate (void) printf(
1107c478bd9Sstevel@tonic-gate "%s d=0x%.8X i=%-5llu m=0%.6o l=%-2u u=%-5u g=%-5u",
1117c478bd9Sstevel@tonic-gate pri->pname,
1127c478bd9Sstevel@tonic-gate statb.st_dev,
1137c478bd9Sstevel@tonic-gate (u_longlong_t)statb.st_ino,
1147c478bd9Sstevel@tonic-gate statb.st_mode,
1157c478bd9Sstevel@tonic-gate statb.st_nlink,
1167c478bd9Sstevel@tonic-gate statb.st_uid,
1177c478bd9Sstevel@tonic-gate statb.st_gid);
1187c478bd9Sstevel@tonic-gate
1197c478bd9Sstevel@tonic-gate switch (statb.st_mode & S_IFMT) {
1207c478bd9Sstevel@tonic-gate case S_IFCHR:
1217c478bd9Sstevel@tonic-gate case S_IFBLK:
1227c478bd9Sstevel@tonic-gate (void) printf(" rdev=0x%.8X\n", statb.st_rdev);
1237c478bd9Sstevel@tonic-gate break;
1247c478bd9Sstevel@tonic-gate default:
1257c478bd9Sstevel@tonic-gate (void) printf(" sz=%llu\n", (long long)statb.st_size);
1267c478bd9Sstevel@tonic-gate break;
1277c478bd9Sstevel@tonic-gate }
1287c478bd9Sstevel@tonic-gate
1297c478bd9Sstevel@tonic-gate TIMESPEC32_TO_TIMESPEC(&ts, &statb.st_atim);
1307c478bd9Sstevel@tonic-gate prtimestruc(pri, "at = ", &ts);
1317c478bd9Sstevel@tonic-gate TIMESPEC32_TO_TIMESPEC(&ts, &statb.st_mtim);
1327c478bd9Sstevel@tonic-gate prtimestruc(pri, "mt = ", &ts);
1337c478bd9Sstevel@tonic-gate TIMESPEC32_TO_TIMESPEC(&ts, &statb.st_ctim);
1347c478bd9Sstevel@tonic-gate prtimestruc(pri, "ct = ", &ts);
1357c478bd9Sstevel@tonic-gate
1367c478bd9Sstevel@tonic-gate (void) printf("%s bsz=%-5d blks=%-5lld fs=%.*s\n",
1377c478bd9Sstevel@tonic-gate pri->pname,
1387c478bd9Sstevel@tonic-gate statb.st_blksize,
1397c478bd9Sstevel@tonic-gate (longlong_t)statb.st_blocks,
1407c478bd9Sstevel@tonic-gate _ST_FSTYPSZ,
1417c478bd9Sstevel@tonic-gate statb.st_fstype);
1427c478bd9Sstevel@tonic-gate }
1437c478bd9Sstevel@tonic-gate }
1447c478bd9Sstevel@tonic-gate
1457c478bd9Sstevel@tonic-gate void
show_stat64(private_t * pri,long offset)1467c478bd9Sstevel@tonic-gate show_stat64(private_t *pri, long offset)
1477c478bd9Sstevel@tonic-gate {
1487c478bd9Sstevel@tonic-gate struct stat64 statb;
1497c478bd9Sstevel@tonic-gate
150*27aa4812SToomas Soome if (offset != 0 &&
1517c478bd9Sstevel@tonic-gate Pread(Proc, &statb, sizeof (statb), offset) == sizeof (statb)) {
1527c478bd9Sstevel@tonic-gate (void) printf(
1537c478bd9Sstevel@tonic-gate "%s d=0x%.16lX i=%-5lu m=0%.6o l=%-2u u=%-5u g=%-5u",
1547c478bd9Sstevel@tonic-gate pri->pname,
1557c478bd9Sstevel@tonic-gate statb.st_dev,
1567c478bd9Sstevel@tonic-gate statb.st_ino,
1577c478bd9Sstevel@tonic-gate statb.st_mode,
1587c478bd9Sstevel@tonic-gate statb.st_nlink,
1597c478bd9Sstevel@tonic-gate statb.st_uid,
1607c478bd9Sstevel@tonic-gate statb.st_gid);
1617c478bd9Sstevel@tonic-gate
1627c478bd9Sstevel@tonic-gate switch (statb.st_mode & S_IFMT) {
1637c478bd9Sstevel@tonic-gate case S_IFCHR:
1647c478bd9Sstevel@tonic-gate case S_IFBLK:
1657c478bd9Sstevel@tonic-gate (void) printf(" rdev=0x%.16lX\n", statb.st_rdev);
1667c478bd9Sstevel@tonic-gate break;
1677c478bd9Sstevel@tonic-gate default:
1687c478bd9Sstevel@tonic-gate (void) printf(" sz=%lu\n", statb.st_size);
1697c478bd9Sstevel@tonic-gate break;
1707c478bd9Sstevel@tonic-gate }
1717c478bd9Sstevel@tonic-gate
1727c478bd9Sstevel@tonic-gate prtimestruc(pri, "at = ", (timestruc_t *)&statb.st_atim);
1737c478bd9Sstevel@tonic-gate prtimestruc(pri, "mt = ", (timestruc_t *)&statb.st_mtim);
1747c478bd9Sstevel@tonic-gate prtimestruc(pri, "ct = ", (timestruc_t *)&statb.st_ctim);
1757c478bd9Sstevel@tonic-gate
1767c478bd9Sstevel@tonic-gate (void) printf(
1777c478bd9Sstevel@tonic-gate "%s bsz=%-5d blks=%-5ld fs=%.*s\n",
1787c478bd9Sstevel@tonic-gate pri->pname,
1797c478bd9Sstevel@tonic-gate statb.st_blksize,
1807c478bd9Sstevel@tonic-gate statb.st_blocks,
1817c478bd9Sstevel@tonic-gate _ST_FSTYPSZ,
1827c478bd9Sstevel@tonic-gate statb.st_fstype);
1837c478bd9Sstevel@tonic-gate }
1847c478bd9Sstevel@tonic-gate }
185