Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/disklabel Make disklabel(8) into a host-tool, "nbdiskla...



details:   https://anonhg.NetBSD.org/src/rev/090e9d57f68a
branches:  trunk
changeset: 581976:090e9d57f68a
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Sun Jun 12 19:18:34 2005 +0000

description:
Make disklabel(8) into a host-tool, "nbdisklabel."  Move disklabel.c
to main.c to avoid a name collision with lib/libc/gen/disklabel.c
when we build nbdisklabel.  Still todo: commit host-tool build
infrastructure to src/tools/disklabel/.

diffstat:

 sbin/disklabel/Makefile     |     4 +-
 sbin/disklabel/disklabel.c  |  1945 -----------------------------------------
 sbin/disklabel/dkcksum.c    |    12 +-
 sbin/disklabel/interact.c   |    16 +-
 sbin/disklabel/main.c       |  1993 +++++++++++++++++++++++++++++++++++++++++++
 sbin/disklabel/printlabel.c |    12 +-
 6 files changed, 2028 insertions(+), 1954 deletions(-)

diffs (truncated from 4074 to 300 lines):

diff -r 9725a7a0c83b -r 090e9d57f68a sbin/disklabel/Makefile
--- a/sbin/disklabel/Makefile   Sun Jun 12 19:14:10 2005 +0000
+++ b/sbin/disklabel/Makefile   Sun Jun 12 19:18:34 2005 +0000
@@ -1,8 +1,8 @@
-#      $NetBSD: Makefile,v 1.54 2005/01/20 16:39:23 xtraeme Exp $
+#      $NetBSD: Makefile,v 1.55 2005/06/12 19:18:34 dyoung Exp $
 #      @(#)Makefile    8.2 (Berkeley) 3/17/94
 
 PROG=  disklabel
-SRCS=  disklabel.c dkcksum.c interact.c printlabel.c
+SRCS=  main.c dkcksum.c interact.c printlabel.c
 MAN=   disklabel.5 disklabel.8
 LDADD+= -lutil
 DPADD+= ${LIBUTIL}
diff -r 9725a7a0c83b -r 090e9d57f68a sbin/disklabel/disklabel.c
--- a/sbin/disklabel/disklabel.c        Sun Jun 12 19:14:10 2005 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,1945 +0,0 @@
-/*     $NetBSD: disklabel.c,v 1.135 2004/11/12 01:00:40 hubertf Exp $  */
-
-/*
- * Copyright (c) 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Symmetric Computer Systems.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1987, 1993\n\
-       The Regents of the University of California.  All rights reserved.\n");
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)disklabel.c        8.4 (Berkeley) 5/4/95";
-/* from static char sccsid[] = "@(#)disklabel.c        1.2 (Symmetric) 11/28/85"; */
-#else
-__RCSID("$NetBSD: disklabel.c,v 1.135 2004/11/12 01:00:40 hubertf Exp $");
-#endif
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#define DKTYPENAMES
-#define FSTYPENAMES
-#include <sys/disklabel.h>
-#include <sys/bootblock.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ffs/fs.h>
-
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <unistd.h>
-#include <signal.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <util.h>
-
-#include <disktab.h>
-
-#include "pathnames.h"
-#include "extern.h"
-#include "dkcksum.h"
-
-/*
- * Disklabel: read and write disklabels.
- * The label is usually placed on one of the first sectors of the disk.
- * Many machines also place a bootstrap in the same area,
- * in which case the label is embedded in the bootstrap.
- * The bootstrap source must leave space at the proper offset
- * for the label on such machines.
- */
-
-#ifndef BBSIZE
-#define        BBSIZE  8192                    /* size of boot area, with label */
-#endif
-
-#ifndef NUMBOOT
-#define NUMBOOT 0
-#endif
-
-#define        DEFEDITOR       _PATH_VI
-
-static char    *dkname;
-static char    tmpfil[MAXPATHLEN];
-
-static char    namebuf[BBSIZE], *np = namebuf;
-static struct  disklabel lab;
-
-char    bootarea[BBSIZE];
-char   *specname;
-
-
-#if NUMBOOT > 0
-static int     installboot; /* non-zero if we should install a boot program */
-static char    *bootbuf;    /* pointer to buffer with remainder of boot prog */
-static int     bootsize;    /* size of remaining boot program */
-static char    *xxboot;     /* primary boot */
-static char    *bootxx;     /* secondary boot */
-static char    boot0[MAXPATHLEN];
-#if NUMBOOT > 1
-static char    boot1[MAXPATHLEN];
-#endif /* NUMBOOT > 1 */
-#endif /* NUMBOOT > 0 */
-
-static enum    {
-       UNSPEC, EDIT, READ, RESTORE, SETWRITABLE, WRITE, WRITEBOOT, INTERACT
-} op = UNSPEC;
-
-static int     Fflag;
-static int     rflag;
-static int     tflag;
-       int     Cflag;
-static int     Iflag;
-
-#define COMMON_OPTIONS "BCFINRWb:ef:irs:tw"
-
-#ifdef DEBUG
-static int     debug;
-#define OPTIONS        COMMON_OPTIONS "d"
-#else  /* ! DEBUG */
-#define OPTIONS        COMMON_OPTIONS
-#endif /* ! DEBUG */
-
-#ifdef USE_MBR
-static struct mbr_partition    *dosdp; /* i386 DOS partition, if found */
-static struct mbr_partition    *readmbr(int);
-#endif /* USE_MBR */
-
-#ifdef USE_ACORN
-static u_int            filecore_partition_offset;
-static u_int            get_filecore_partition(int);
-static int              filecore_checksum(u_char *);
-#endif /* USE_ACORN */
-
-#if defined(USE_MBR) || (defined(USE_ACORN) && defined(notyet))
-static void             confirm(const char *);
-#endif
-
-int                     main(int, char *[]);
-
-static void             makedisktab(FILE *, struct disklabel *);
-static void             makelabel(const char *, const char *,
-                           struct disklabel *);
-static void             l_perror(const char *);
-static struct disklabel        *readlabel(int);
-static struct disklabel        *makebootarea(char *, struct disklabel *, int);
-static int              edit(struct disklabel *, int);
-static int              editit(void);
-static char            *skip(char *);
-static char            *word(char *);
-static int              getasciilabel(FILE *, struct disklabel *);
-#if NUMBOOT > 0
-static void             setbootflag(struct disklabel *);
-#endif
-static void             usage(void);
-static int              getulong(const char *, char, char **,
-    unsigned long *, unsigned long);
-#define GETNUM32(a, v) getulong(a, '\0', NULL, v, UINT32_MAX)
-#define GETNUM16(a, v) getulong(a, '\0', NULL, v, UINT16_MAX)
-#define GETNUM8(a, v)  getulong(a, '\0', NULL, v, UINT8_MAX)
-
-int
-main(int argc, char *argv[])
-{
-       struct disklabel *lp;
-       FILE    *t;
-       int      ch, f, writable, error;
-
-       error = 0;
-       while ((ch = getopt(argc, argv, OPTIONS)) != -1)
-               switch (ch) {
-#if NUMBOOT > 0
-               case 'B':
-                       ++installboot;
-                       break;
-               case 'b':
-                       xxboot = optarg;
-                       break;
-#if NUMBOOT > 1
-               case 's':
-                       bootxx = optarg;
-                       break;
-#endif /* NUMBOOT > 1 */
-#endif /* NUMBOOT > 0 */
-               case 'C':
-                       ++Cflag;
-                       break;
-               case 'F':
-                       ++Fflag;
-                       break;
-               case 'I':
-                       ++Iflag;
-                       break;
-               case 'N':
-                       if (op != UNSPEC)
-                               usage();
-                       writable = 0;
-                       op = SETWRITABLE;
-                       break;
-               case 'R':
-                       if (op != UNSPEC)
-                               usage();
-                       op = RESTORE;
-                       break;
-               case 'W':
-                       if (op != UNSPEC)
-                               usage();
-                       writable = 1;
-                       op = SETWRITABLE;
-                       break;
-               case 'e':
-                       if (op != UNSPEC)
-                               usage();
-                       op = EDIT;
-                       break;
-               case 'f':
-                       if (setdisktab(optarg) == -1)
-                               usage();
-                       break;
-               case 'i':
-                       if (op != UNSPEC)
-                               usage();
-                       op = INTERACT;
-                       break;
-               case 't':
-                       ++tflag;
-                       break;
-               case 'r':
-                       ++rflag;
-                       break;
-               case 'w':
-                       if (op != UNSPEC)
-                               usage();
-                       op = WRITE;
-                       break;
-#ifdef DEBUG
-               case 'd':
-                       debug++;
-                       break;
-#endif
-               case '?':
-               default:
-                       usage();
-       }
-       argc -= optind;
-       argv += optind;
-
-#if NUMBOOT > 0
-       if (installboot) {
-               rflag++;
-               if (op == UNSPEC)
-                       op = WRITEBOOT;
-       } else {
-               if (op == UNSPEC)
-                       op = READ;
-       }
-#else  /* NUMBOOT <= 0 */
-       if (op == UNSPEC)
-               op = READ;
-#endif /* NUMBOOT <= 0 */
-
-       if (argc < 1)
-               usage();
-
-       if (Iflag && op != EDIT && op != INTERACT)
-               usage();



Home | Main Index | Thread Index | Old Index