Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/sbin/disklabel Pull up revisions 1.16-1.17 (requested b...
details: https://anonhg.NetBSD.org/src/rev/c9277273ac3b
branches: netbsd-1-5
changeset: 490758:c9277273ac3b
user: he <he%NetBSD.org@localhost>
date: Mon Feb 26 22:27:45 2001 +0000
description:
Pull up revisions 1.16-1.17 (requested by lukem):
Several fixes and enhancements:
o with ``-I'', initialize the label if it's not there, it's
corrupt, or there's no ``fake'' label.
o correct partition table header
o move some functions into a separate file for other programs
to use
o fix examples and cross references
o various cleanups
diffstat:
sbin/disklabel/interact.c | 197 ++++++++++++++++++---------------------------
1 files changed, 81 insertions(+), 116 deletions(-)
diffs (truncated from 396 to 300 lines):
diff -r acbe5710dc23 -r c9277273ac3b sbin/disklabel/interact.c
--- a/sbin/disklabel/interact.c Mon Feb 26 22:27:23 2001 +0000
+++ b/sbin/disklabel/interact.c Mon Feb 26 22:27:45 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: interact.c,v 1.13.4.1 2000/10/18 02:53:09 tv Exp $ */
+/* $NetBSD: interact.c,v 1.13.4.2 2001/02/26 22:27:45 he Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: interact.c,v 1.13.4.1 2000/10/18 02:53:09 tv Exp $");
+__RCSID("$NetBSD: interact.c,v 1.13.4.2 2001/02/26 22:27:45 he Exp $");
#endif /* lint */
#include <sys/param.h>
@@ -47,28 +47,28 @@
#include "extern.h"
-static void cmd_help __P((struct disklabel *, char *, int));
-static void cmd_chain __P((struct disklabel *, char *, int));
-static void cmd_print __P((struct disklabel *, char *, int));
-static void cmd_printall __P((struct disklabel *, char *, int));
-static void cmd_info __P((struct disklabel *, char *, int));
-static void cmd_part __P((struct disklabel *, char *, int));
-static void cmd_label __P((struct disklabel *, char *, int));
-static void cmd_round __P((struct disklabel *, char *, int));
-static void cmd_name __P((struct disklabel *, char *, int));
-static int runcmd __P((char *, struct disklabel *, int));
-static int getinput __P((const char *, const char *, const char *, char *));
-static int alphacmp __P((const void *, const void *));
-static void defnum __P((char *, struct disklabel *, int));
-static void dumpnames __P((const char *, const char * const *, size_t));
-static int getnum __P((char *, int, struct disklabel *));
+static void cmd_help(struct disklabel *, char *, int);
+static void cmd_chain(struct disklabel *, char *, int);
+static void cmd_print(struct disklabel *, char *, int);
+static void cmd_printall(struct disklabel *, char *, int);
+static void cmd_info(struct disklabel *, char *, int);
+static void cmd_part(struct disklabel *, char *, int);
+static void cmd_label(struct disklabel *, char *, int);
+static void cmd_round(struct disklabel *, char *, int);
+static void cmd_name(struct disklabel *, char *, int);
+static int runcmd(struct disklabel *, char *, int);
+static int getinput(const char *, const char *, const char *, char *);
+static int alphacmp(const void *, const void *);
+static void defnum(struct disklabel *, char *, int);
+static void dumpnames(const char *, const char * const *, size_t);
+static int getnum(struct disklabel *, char *, int);
static int rounding = 0; /* sector rounding */
static int chaining = 0; /* make partitions contiguous */
static struct cmds {
const char *name;
- void (*func) __P((struct disklabel *, char *, int));
+ void (*func)(struct disklabel *, char *, int);
const char *help;
} cmds[] = {
{ "?", cmd_help, "print this menu" },
@@ -86,10 +86,7 @@
static void
-cmd_help(lp, s, fd)
- struct disklabel *lp;
- char *s;
- int fd;
+cmd_help(struct disklabel *lp, char *s, int fd)
{
struct cmds *cmd;
@@ -101,13 +98,10 @@
static void
-cmd_chain(lp, s, fd)
- struct disklabel *lp;
- char *s;
- int fd;
+cmd_chain(struct disklabel *lp, char *s, int fd)
{
- int i;
- char line[BUFSIZ];
+ int i;
+ char line[BUFSIZ];
i = getinput(":", "Automatically adjust partitions",
chaining ? "yes" : "no", line);
@@ -127,39 +121,34 @@
}
}
+
static void
-cmd_printall(lp, s, fd)
- struct disklabel *lp;
- char *s;
- int fd;
+cmd_printall(struct disklabel *lp, char *s, int fd)
{
- showinfo(stdout, lp);
- showpartitions(stdout, lp);
+ showinfo(stdout, lp, specname);
+ showpartitions(stdout, lp, Cflag);
}
+
static void
-cmd_print(lp, s, fd)
- struct disklabel *lp;
- char *s;
- int fd;
+cmd_print(struct disklabel *lp, char *s, int fd)
{
- showpartitions(stdout, lp);
+
+ showpartitions(stdout, lp, Cflag);
}
+
static void
-cmd_info(lp, s, fd)
- struct disklabel *lp;
- char *s;
- int fd;
+cmd_info(struct disklabel *lp, char *s, int fd)
{
- char line[BUFSIZ];
- char def[BUFSIZ];
- int v, i;
+ char line[BUFSIZ];
+ char def[BUFSIZ];
+ int v, i;
u_int32_t u;
printf("# Current values:\n");
- showinfo(stdout, lp);
+ showinfo(stdout, lp, specname);
/* d_type */
for (;;) {
@@ -189,7 +178,7 @@
continue;
}
lp->d_type = v;
-done_typename:
+ done_typename:
break;
}
@@ -401,15 +390,13 @@
}
}
+
static void
-cmd_name(lp, s, fd)
- struct disklabel *lp;
- char *s;
- int fd;
+cmd_name(struct disklabel *lp, char *s, int fd)
{
- char line[BUFSIZ];
- char def[BUFSIZ];
- int i;
+ char line[BUFSIZ];
+ char def[BUFSIZ];
+ int i;
snprintf(def, sizeof(def), "%.*s",
(int) sizeof(lp->d_packname), lp->d_packname);
@@ -419,14 +406,12 @@
(void) strncpy(lp->d_packname, line, sizeof(lp->d_packname));
}
+
static void
-cmd_round(lp, s, fd)
- struct disklabel *lp;
- char *s;
- int fd;
+cmd_round(struct disklabel *lp, char *s, int fd)
{
- int i;
- char line[BUFSIZ];
+ int i;
+ char line[BUFSIZ];
i = getinput(":", "Rounding", rounding ? "cylinders" : "sectors", line);
if (i <= 0)
@@ -445,18 +430,18 @@
}
}
+
static void
-cmd_part(lp, s, fd)
- struct disklabel *lp;
- char *s;
- int fd;
+cmd_part(struct disklabel *lp, char *s, int fd)
{
- int i;
- char line[BUFSIZ];
- char def[BUFSIZ];
- int part = *s - 'a';
- struct partition *p = &lp->d_partitions[part];
+ int i;
+ char line[BUFSIZ];
+ char def[BUFSIZ];
+ int part;
+ struct partition *p;
+ part = s[0] - 'a';
+ p = &lp->d_partitions[part];
if (part >= lp->d_npartitions)
lp->d_npartitions = part + 1;
@@ -482,17 +467,17 @@
}
printf("Invalid file system typename `%s'\n", line);
continue;
-done_typename:
+ done_typename:
break;
}
for (;;) {
- defnum(def, lp, p->p_offset);
+ defnum(lp, def, p->p_offset);
i = getinput(":", "Start offset", def, line);
if (i == -1)
return;
else if (i == 0)
break;
- if ((i = getnum(line, 0, lp)) == -1) {
+ if ((i = getnum(lp, line, 0)) == -1) {
printf("Bad offset `%s'\n", line);
continue;
}
@@ -500,14 +485,14 @@
break;
}
for (;;) {
- defnum(def, lp, p->p_size);
+ defnum(lp, def, p->p_size);
i = getinput(":", "Partition size ('$' for all remaining)",
def, line);
if (i == -1)
return;
else if (i == 0)
break;
- if ((i = getnum(line, lp->d_secperunit - p->p_offset, lp))
+ if ((i = getnum(lp, line, lp->d_secperunit - p->p_offset))
== -1) {
printf("Bad size `%s'\n", line);
continue;
@@ -531,13 +516,10 @@
static void
-cmd_label(lp, s, fd)
- struct disklabel *lp;
- char *s;
- int fd;
+cmd_label(struct disklabel *lp, char *s, int fd)
{
- char line[BUFSIZ];
- int i;
+ char line[BUFSIZ];
+ int i;
i = getinput("?", "Label disk", "n", line);
if (i <= 0 || (*line != 'y' && *line != 'Y') )
@@ -557,10 +539,7 @@
static int
-runcmd(line, lp, fd)
- char *line;
- struct disklabel *lp;
- int fd;
+runcmd(struct disklabel *lp, char *line, int fd)
{
struct cmds *cmd;
@@ -584,12 +563,9 @@
static int
-getinput(sep, prompt, def, line)
- const char *sep;
- const char *prompt;
- const char *def;
- char *line;
+getinput(const char *sep, const char *prompt, const char *def, char *line)
Home |
Main Index |
Thread Index |
Old Index