ccdconfig.c (15678bfa0353347ff79322b508941e53e9919ae5) | ccdconfig.c (9ad54eb7b35925afd76550bbee3929252f59ad3a) |
---|---|
1/* $Id: ccdconfig.c,v 1.7 1997/06/10 11:04:50 charnier Exp $ */ 2 | |
3/* $NetBSD: ccdconfig.c,v 1.2.2.1 1995/11/11 02:43:35 thorpej Exp $ */ 4 5/* 6 * Copyright (c) 1995 Jason R. Thorpe. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions --- 18 unchanged lines hidden (view full) --- 29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 31 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 | 1/* $NetBSD: ccdconfig.c,v 1.2.2.1 1995/11/11 02:43:35 thorpej Exp $ */ 2 3/* 4 * Copyright (c) 1995 Jason R. Thorpe. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 18 unchanged lines hidden (view full) --- 27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 */ 34 |
35#ifndef lint 36static const char rcsid[] = 37 "$Id$"; 38#endif /* not lint */ 39 |
|
37#include <sys/param.h> | 40#include <sys/param.h> |
38#include <sys/ioctl.h> | |
39#include <sys/disklabel.h> 40#include <sys/device.h> 41#include <sys/disk.h> 42#include <sys/stat.h> | 41#include <sys/disklabel.h> 42#include <sys/device.h> 43#include <sys/disk.h> 44#include <sys/stat.h> |
43#include <sys/sysctl.h> | |
44#include <ctype.h> 45#include <err.h> 46#include <errno.h> 47#include <fcntl.h> 48#include <kvm.h> 49#include <limits.h> | 45#include <ctype.h> 46#include <err.h> 47#include <errno.h> 48#include <fcntl.h> 49#include <kvm.h> 50#include <limits.h> |
50#include <nlist.h> | |
51#include <stdio.h> 52#include <stdlib.h> 53#include <string.h> 54#include <unistd.h> 55 56#include <sys/ccdvar.h> 57 58#include "pathnames.h" --- 33 unchanged lines hidden (view full) --- 92static int checkdev __P((char *)); 93static int do_io __P((char *, u_long, struct ccd_ioctl *)); 94static int do_single __P((int, char **, int)); 95static int do_all __P((int)); 96static int dump_ccd __P((int, char **)); 97static int getmaxpartitions __P((void)); 98static int getrawpartition __P((void)); 99static int flags_to_val __P((char *)); | 51#include <stdio.h> 52#include <stdlib.h> 53#include <string.h> 54#include <unistd.h> 55 56#include <sys/ccdvar.h> 57 58#include "pathnames.h" --- 33 unchanged lines hidden (view full) --- 92static int checkdev __P((char *)); 93static int do_io __P((char *, u_long, struct ccd_ioctl *)); 94static int do_single __P((int, char **, int)); 95static int do_all __P((int)); 96static int dump_ccd __P((int, char **)); 97static int getmaxpartitions __P((void)); 98static int getrawpartition __P((void)); 99static int flags_to_val __P((char *)); |
100static int pathtodevt __P((char *, dev_t *)); | |
101static void print_ccd_info __P((struct ccd_softc *, kvm_t *)); 102static char *resolve_ccdname __P((char *)); 103static void usage __P((void)); 104 105int 106main(argc, argv) 107 int argc; 108 char **argv; --- 72 unchanged lines hidden (view full) --- 181 exit(do_all(action)); 182 /* NOTREACHED */ 183 184 case CCD_DUMP: 185 exit(dump_ccd(argc, argv)); 186 /* NOTREACHED */ 187 } 188 /* NOTREACHED */ | 100static void print_ccd_info __P((struct ccd_softc *, kvm_t *)); 101static char *resolve_ccdname __P((char *)); 102static void usage __P((void)); 103 104int 105main(argc, argv) 106 int argc; 107 char **argv; --- 72 unchanged lines hidden (view full) --- 180 exit(do_all(action)); 181 /* NOTREACHED */ 182 183 case CCD_DUMP: 184 exit(dump_ccd(argc, argv)); 185 /* NOTREACHED */ 186 } 187 /* NOTREACHED */ |
188 return (0); |
|
189} 190 191static int 192do_single(argc, argv, action) 193 int argc; 194 char **argv; 195 int action; 196{ 197 struct ccd_ioctl ccio; 198 char *ccd, *cp, *cp2, **disks; | 189} 190 191static int 192do_single(argc, argv, action) 193 int argc; 194 char **argv; 195 int action; 196{ 197 struct ccd_ioctl ccio; 198 char *ccd, *cp, *cp2, **disks; |
199 int noflags = 0, i, ileave, flags, j, error; | 199 int noflags = 0, i, ileave, flags, j; |
200 201 bzero(&ccio, sizeof(ccio)); 202 203 /* 204 * If unconfiguring, all arguments are treated as ccds. 205 */ 206 if (action == CCD_UNCONFIG || action == CCD_UNCONFIGALL) { 207 for (i = 0; argc != 0; ) { --- 180 unchanged lines hidden (view full) --- 388} 389 390static int 391pathtounit(path, unitp) 392 char *path; 393 int *unitp; 394{ 395 struct stat st; | 200 201 bzero(&ccio, sizeof(ccio)); 202 203 /* 204 * If unconfiguring, all arguments are treated as ccds. 205 */ 206 if (action == CCD_UNCONFIG || action == CCD_UNCONFIGALL) { 207 for (i = 0; argc != 0; ) { --- 180 unchanged lines hidden (view full) --- 388} 389 390static int 391pathtounit(path, unitp) 392 char *path; 393 int *unitp; 394{ 395 struct stat st; |
396 dev_t dev; | |
397 int maxpartitions; 398 399 if (stat(path, &st) != 0) 400 return (errno); 401 402 if (!S_ISBLK(st.st_mode) && !S_ISCHR(st.st_mode)) 403 return (EINVAL); 404 --- 4 unchanged lines hidden (view full) --- 409 410 return (0); 411} 412 413static char * 414resolve_ccdname(name) 415 char *name; 416{ | 396 int maxpartitions; 397 398 if (stat(path, &st) != 0) 399 return (errno); 400 401 if (!S_ISBLK(st.st_mode) && !S_ISCHR(st.st_mode)) 402 return (EINVAL); 403 --- 4 unchanged lines hidden (view full) --- 408 409 return (0); 410} 411 412static char * 413resolve_ccdname(name) 414 char *name; 415{ |
417 char c, *cp, *path; | 416 char c, *path; |
418 size_t len, newlen; 419 int rawpart; 420 421 if (name[0] == '/' || name[0] == '.') { 422 /* Assume they gave the correct pathname. */ 423 return (strdup(name)); 424 } 425 --- 299 unchanged lines hidden --- | 417 size_t len, newlen; 418 int rawpart; 419 420 if (name[0] == '/' || name[0] == '.') { 421 /* Assume they gave the correct pathname. */ 422 return (strdup(name)); 423 } 424 --- 299 unchanged lines hidden --- |