devinfo.c (bc2e39ce) | devinfo.c (342440ec) |
---|---|
1/* 2 * CDDL HEADER START 3 * 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. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 4 unchanged lines hidden (view full) --- 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] 18 * 19 * CDDL HEADER END 20 */ | 1/* 2 * CDDL HEADER START 3 * 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. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 4 unchanged lines hidden (view full) --- 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] 18 * 19 * CDDL HEADER END 20 */ |
21 |
|
21/* | 22/* |
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. | 23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
23 * Use is subject to license terms. 24 */ 25 26/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 27/* All Rights Reserved */ 28 | 24 * Use is subject to license terms. 25 */ 26 27/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28/* All Rights Reserved */ 29 |
29#pragma ident "%Z%%M% %I% %E% SMI" 30 | |
31/* 32 * Two output fields under the -i option will always be 33 * output as zero, since they are not supported by Sun: 34 * Software version, and 35 * Drive id number. 36 * AT&T filled these 2 fields with data from their "pdsector", 37 * which Sun doesn't support per se. 38 */ --- 18 unchanged lines hidden (view full) --- 57/* 58 * Standard I/O file descriptors. 59 */ 60#define STDOUT 1 /* Standard output */ 61#define STDERR 2 /* Standard error */ 62 63static void partinfo(int fd, char *device); 64static void devinfo(struct dk_geom *geom, int fd, char *device); | 30/* 31 * Two output fields under the -i option will always be 32 * output as zero, since they are not supported by Sun: 33 * Software version, and 34 * Drive id number. 35 * AT&T filled these 2 fields with data from their "pdsector", 36 * which Sun doesn't support per se. 37 */ --- 18 unchanged lines hidden (view full) --- 56/* 57 * Standard I/O file descriptors. 58 */ 59#define STDOUT 1 /* Standard output */ 60#define STDERR 2 /* Standard error */ 61 62static void partinfo(int fd, char *device); 63static void devinfo(struct dk_geom *geom, int fd, char *device); |
65static int readvtoc(int fd, char *name, struct vtoc *vtoc); | 64static int readvtoc(int fd, char *name, struct extvtoc *vtoc); |
66static int warn(char *what, char *why); 67static void usage(void); 68 69int 70main(int argc, char **argv) 71{ 72 struct dk_geom geom; 73 int errflg, iflg, pflg, fd, c; --- 54 unchanged lines hidden (view full) --- 128static void 129partinfo(int fd, char *device) 130{ 131 int i; 132 int slice; 133 major_t maj; 134 minor_t min; 135 struct stat64 statbuf; | 65static int warn(char *what, char *why); 66static void usage(void); 67 68int 69main(int argc, char **argv) 70{ 71 struct dk_geom geom; 72 int errflg, iflg, pflg, fd, c; --- 54 unchanged lines hidden (view full) --- 127static void 128partinfo(int fd, char *device) 129{ 130 int i; 131 int slice; 132 major_t maj; 133 minor_t min; 134 struct stat64 statbuf; |
136 struct vtoc vtdata; | 135 struct extvtoc vtdata; |
137 struct dk_gpt *efi; 138 139 i = stat64(device, &statbuf); 140 if (i < 0) 141 exit(DRERR); 142 maj = major(statbuf.st_rdev); 143 min = minor(statbuf.st_rdev); 144 145 if ((slice = readvtoc(fd, device, &vtdata)) >= 0) { 146 | 136 struct dk_gpt *efi; 137 138 i = stat64(device, &statbuf); 139 if (i < 0) 140 exit(DRERR); 141 maj = major(statbuf.st_rdev); 142 min = minor(statbuf.st_rdev); 143 144 if ((slice = readvtoc(fd, device, &vtdata)) >= 0) { 145 |
147 (void) printf("%s\t%0lx\t%0lx\t%ld\t%ld\t%x\t%x\n", | 146 (void) printf("%s\t%0lx\t%0lx\t%llu\t%llu\t%x\t%x\n", |
148 device, maj, min, 149 vtdata.v_part[slice].p_start, 150 vtdata.v_part[slice].p_size, 151 vtdata.v_part[slice].p_flag, 152 vtdata.v_part[slice].p_tag); 153 } else if ((slice == VT_ENOTSUP) && 154 (slice = efi_alloc_and_read(fd, &efi)) >= 0) { 155 (void) printf("%s\t%lx\t%lx\t%lld\t%lld\t%hx\t%hx\n", --- 7 unchanged lines hidden (view full) --- 163 } 164} 165 166static void 167devinfo(struct dk_geom *geom, int fd, char *device) 168{ 169 int i; 170 unsigned int nopartitions, sectorcyl, bytes; | 147 device, maj, min, 148 vtdata.v_part[slice].p_start, 149 vtdata.v_part[slice].p_size, 150 vtdata.v_part[slice].p_flag, 151 vtdata.v_part[slice].p_tag); 152 } else if ((slice == VT_ENOTSUP) && 153 (slice = efi_alloc_and_read(fd, &efi)) >= 0) { 154 (void) printf("%s\t%lx\t%lx\t%lld\t%lld\t%hx\t%hx\n", --- 7 unchanged lines hidden (view full) --- 162 } 163} 164 165static void 166devinfo(struct dk_geom *geom, int fd, char *device) 167{ 168 int i; 169 unsigned int nopartitions, sectorcyl, bytes; |
171 struct vtoc vtdata; | 170 struct extvtoc vtdata; |
172/* 173 * unsigned int version = 0; 174 * unsigned int driveid = 0; 175 */ 176 177 nopartitions = 0; 178 sectorcyl = 0; 179 bytes = 0; --- 22 unchanged lines hidden (view full) --- 202 203 204/* 205 * readvtoc() 206 * 207 * Read a partition map. 208 */ 209static int | 171/* 172 * unsigned int version = 0; 173 * unsigned int driveid = 0; 174 */ 175 176 nopartitions = 0; 177 sectorcyl = 0; 178 bytes = 0; --- 22 unchanged lines hidden (view full) --- 201 202 203/* 204 * readvtoc() 205 * 206 * Read a partition map. 207 */ 208static int |
210readvtoc(int fd, char *name, struct vtoc *vtoc) | 209readvtoc(int fd, char *name, struct extvtoc *vtoc) |
211{ 212 int retval; 213 | 210{ 211 int retval; 212 |
214 retval = read_vtoc(fd, vtoc); | 213 retval = read_extvtoc(fd, vtoc); |
215 216 switch (retval) { 217 case (VT_ERROR): 218 return (warn(name, strerror(errno))); 219 case (VT_EIO): 220 return (warn(name, "I/O error accessing VTOC")); 221 case (VT_EINVAL): 222 return (warn(name, "Invalid field in VTOC")); --- 34 unchanged lines hidden --- | 214 215 switch (retval) { 216 case (VT_ERROR): 217 return (warn(name, strerror(errno))); 218 case (VT_EIO): 219 return (warn(name, "I/O error accessing VTOC")); 220 case (VT_EINVAL): 221 return (warn(name, "Invalid field in VTOC")); --- 34 unchanged lines hidden --- |