diff options
author | charnier <charnier@FreeBSD.org> | 2000-11-28 18:09:08 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 2000-11-28 18:09:08 +0000 |
commit | 46ed81751fc2748cd7d10705ac47b37aa7bb6fb1 (patch) | |
tree | 8fc515624778bfad48b59a5b293c54c52fdded2b /usr.sbin | |
parent | af07d8d1cf94f5342171b1b095f524f205bb576b (diff) | |
download | FreeBSD-src-46ed81751fc2748cd7d10705ac47b37aa7bb6fb1.zip FreeBSD-src-46ed81751fc2748cd7d10705ac47b37aa7bb6fb1.tar.gz |
-Wall cleaning. Use getopt(3).
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/diskpart/diskpart.c | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/usr.sbin/diskpart/diskpart.c b/usr.sbin/diskpart/diskpart.c index 6c4d4ad..4d2ea9c 100644 --- a/usr.sbin/diskpart/diskpart.c +++ b/usr.sbin/diskpart/diskpart.c @@ -55,6 +55,9 @@ static const char rcsid[] = #include <ctype.h> #include <err.h> #include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> #define for_now /* show all of `c' partition for disklabel */ #define NPARTITIONS 8 @@ -114,7 +117,9 @@ int pflag; /* print device driver partition tables */ int dflag; /* print disktab entry */ struct disklabel *promptfordisk(); +int gettype __P((char *, char **)); static void usage __P((void)); +int ustrcmp __P((char *, char *)); int main(argc, argv) @@ -125,23 +130,29 @@ main(argc, argv) register int curcyl, spc, def, part, layout, j; int threshhold, numcyls[NPARTITIONS], startcyl[NPARTITIONS]; int totsize = 0; - char *lp, *tyname; + char *lp, *tyname = NULL; + int ch; - argc--, argv++; - if (argc < 1) + while ((ch = getopt(argc, argv, "dps:")) != -1) + switch(ch) { + case 'd': + dflag++; + break; + case 'p': + pflag++; + break; + case 's': + totsize = atoi(optarg); + break; + default: + usage(); + } + argv += optind; + argc -= optind; + + if (argc != 1) usage(); - if (argc > 0 && strcmp(*argv, "-p") == 0) { - pflag++; - argc--, argv++; - } - if (argc > 0 && strcmp(*argv, "-d") == 0) { - dflag++; - argc--, argv++; - } - if (argc > 1 && strcmp(*argv, "-s") == 0) { - totsize = atoi(argv[1]); - argc += 2, argv += 2; - } + dp = getdiskbyname(*argv); if (dp == NULL) { if (isatty(0)) @@ -337,6 +348,7 @@ main(argc, argv) startcyl[part], startcyl[part] + numcyls[part] - 1, defpart[def][part] % spc ? "*" : ""); } + return(0); } static void @@ -465,6 +477,7 @@ again: return (dp); } +int gettype(t, names) char *t; char **names; @@ -479,6 +492,7 @@ gettype(t, names) return (-1); } +int ustrcmp(s1, s2) register char *s1, *s2; { |