Source-Changes-HG archive

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

[src/trunk]: src Replace shell script version of newdisk utility with C version.



details:   https://anonhg.NetBSD.org/src/rev/863e14b294ab
branches:  trunk
changeset: 479880:863e14b294ab
user:      minoura <minoura%NetBSD.org@localhost>
date:      Fri Dec 24 16:51:24 1999 +0000

description:
Replace shell script version of newdisk utility with C version.
Add the man page newdisk(8).

diffstat:

 share/man/man8/man8.x68k/Makefile     |    4 +-
 share/man/man8/man8.x68k/newdisk.8    |   83 ++++++++++++
 sys/arch/x68k/stand/Makefile          |    4 +-
 sys/arch/x68k/stand/mboot/Makefile    |    4 +-
 sys/arch/x68k/stand/mboot/newdisk.sh  |  221 ----------------------------------
 sys/arch/x68k/stand/newdisk/Makefile  |   12 +
 sys/arch/x68k/stand/newdisk/newdisk.c |  202 +++++++++++++++++++++++++++++++
 7 files changed, 302 insertions(+), 228 deletions(-)

diffs (truncated from 576 to 300 lines):

diff -r d3b75ab16797 -r 863e14b294ab share/man/man8/man8.x68k/Makefile
--- a/share/man/man8/man8.x68k/Makefile Fri Dec 24 15:14:29 1999 +0000
+++ b/share/man/man8/man8.x68k/Makefile Fri Dec 24 16:51:24 1999 +0000
@@ -1,6 +1,6 @@
-#      $NetBSD: Makefile,v 1.6 1998/11/20 11:01:25 itohy Exp $
+#      $NetBSD: Makefile,v 1.7 1999/12/24 16:51:25 minoura Exp $
 
-MAN=   MAKEDEV.8 boot.8 loadbsd.8 poffd.8 rtcalarm.8
+MAN=   MAKEDEV.8 boot.8 loadbsd.8 newdisk.8 poffd.8 rtcalarm.8
 MLINKS=        MAKEDEV.8 makedev.8
 MLINKS+=loadbsd.8 loadbsd.x.8
 MANSUBDIR=/x68k
diff -r d3b75ab16797 -r 863e14b294ab share/man/man8/man8.x68k/newdisk.8
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/share/man/man8/man8.x68k/newdisk.8        Fri Dec 24 16:51:24 1999 +0000
@@ -0,0 +1,83 @@
+.\"    $NetBSD: newdisk.8,v 1.1 1999/12/24 16:51:25 minoura Exp $
+.\"
+.\" Copyright (c) 1998 MINOURA Makoto.
+.\" All rights reserved.
+.\"
+.\" 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. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"    This product includes software developed by Minoura Makoto.
+.\" 4. The name of the author may not be used to endorse or promote products
+.\"    derived from this software without specific prior written permission
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+.\"
+.Dd December 24, 1999
+.Os
+.Dt NEWDISK 8
+.Sh NAME
+.Nm newdisk
+.Nd "Prepare a new disk to be usable for X680x0"
+.Sh SYNOPSIS
+.Nm
+.Op Fl vnfc
+.Op Fl m Ar mboot
+.Ar raw_device
+.Sh DESCRIPTION
+.Nm
+prepares a new hard disk to be bootable from by X680x0.  It should NOT be used
+for floppy disks.
+.Pp
+It creates a disk mark for IOCS to determine the disk geometry,
+writes the primary boot program (mboot), and creates empty partition table.
+The option are as follows:
+.Bl -tag -width flag
+.It Fl v
+Verbose mode.
+.It Fl n
+Dryrun mode.  Nothing is written to the disk.
+.It Fl f
+Force.  Usually, when
+.Nm
+detects existing disk mark, it aborts with some error messages.
+.Fl f
+option prevents this behaviour.
+.It Fl c
+Check only.
+.Nm
+looks at the disk wheter it is already marked.
+.It Fl m Ar mboot
+Specifies the mboot program to be written.
+.El
+.Sh FILES
+.Bl -tag -width /usr/mdec/mboot -compact
+.It Pa /usr/mdec/mboot
+The default primary boot program.
+.El
+.Sh SEE ALSO
+.Xr boot 8 ,
+.Xr installboot 8
+.Sh AUTHOR
+.Nm
+was written by MINOURA Makoto <minoura%netbsd.org@localhost>.
+.Sh HISTORY
+The
+.Nm
+utility first appeared in
+.Nx 1.5 .
diff -r d3b75ab16797 -r 863e14b294ab sys/arch/x68k/stand/Makefile
--- a/sys/arch/x68k/stand/Makefile      Fri Dec 24 15:14:29 1999 +0000
+++ b/sys/arch/x68k/stand/Makefile      Fri Dec 24 16:51:24 1999 +0000
@@ -1,6 +1,6 @@
-#      $NetBSD: Makefile,v 1.4 1999/07/04 04:39:12 minoura Exp $
+#      $NetBSD: Makefile,v 1.5 1999/12/24 16:51:24 minoura Exp $
 
-SUBDIR=        aout2hux libdos libiocs loadbsd xxboot mboot # common
+SUBDIR=        aout2hux libdos libiocs loadbsd xxboot mboot newdisk # common
 
 all-loadbsd: all-aout2hux all-libdos all-libiocs
 
diff -r d3b75ab16797 -r 863e14b294ab sys/arch/x68k/stand/mboot/Makefile
--- a/sys/arch/x68k/stand/mboot/Makefile        Fri Dec 24 15:14:29 1999 +0000
+++ b/sys/arch/x68k/stand/mboot/Makefile        Fri Dec 24 16:51:24 1999 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.1 1999/07/04 04:38:54 minoura Exp $
+#      $NetBSD: Makefile,v 1.2 1999/12/24 16:51:25 minoura Exp $
 
 BOOT=          mboot
 VERSION=       0.1
@@ -10,8 +10,6 @@
 PROG=          ${BOOT}
 BINDIR=                /usr/mdec
 BINMODE=       444
-SCRIPTSMODE=   555
-SCRIPTS=       newdisk.sh
 MKMAN=         no
 STRIPFLAG=
 
diff -r d3b75ab16797 -r 863e14b294ab sys/arch/x68k/stand/mboot/newdisk.sh
--- a/sys/arch/x68k/stand/mboot/newdisk.sh      Fri Dec 24 15:14:29 1999 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,221 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 1999 The NetBSD Foundation, Inc.
-# All rights reserved.
-#
-# This code is derived from software contributed to The NetBSD Foundation
-# by Minoura Makoto.
-#
-# 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. All advertising materials mentioning features or use of this software
-#    must display the following acknowledgement:
-#      This product includes software developed by the NetBSD
-#      Foundation, Inc. and its contributors.
-# 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
-#
-
-# Create the disk mark for x68k SCSI IPL.
-#  Problem: The script requires awk, which is toooo large for miniroot.
-#  Solution: Write C version in distrib/utils/sysinst/arch/x68k/md.c.
-
-# Usage: /usr/mdec/newdisk [-vnfc] [-m /usr/mdec/mboot] /dev/rsd?c
-
-prog=$0
-verbose=0
-dryrun=0
-force=0
-checkonly=0
-Usage="Usage: $prog [-v] [-n] [-f] [-c] [-m /usr/mdec/mboot] /dev/rsdXc"
-mboot=/usr/mdec/mboot
-AWK=/usr/bin/awk
-SED=/usr/bin/sed
-DD=/bin/dd
-DISKLABEL=/sbin/disklabel
-C="NetBSD/x68k SCSI Primary Boot. \
-(C) 1999 by The NetBSD Foundation, Inc."
-
-vmessage () {
-    if [ "$verbose" = "1" ]; then
-       echo "$@" 1>&2
-    fi
-    return 0
-}
-message () {
-    echo "$@" 1>&2
-    return 0
-}
-
-
-##
-## Process command line.
-##
-args=`getopt vnfcm: $*`
-if [ $? != 0 ]; then
-    message $Usage
-    exit 1
-fi
-
-set -- $args
-for i; do
-    case "$i" in
-    -v)
-       verbose=1; shift;;
-    -n)
-       dryrun=1; shift;;
-    -f)
-       force=1; shift;;
-    -c)
-       checkonly=1; shift;;
-    -m)
-       mboot=$2; shift; shift;;
-    --)
-       shift; break;;
-    esac
-done
-if [ $# != 1 ]; then
-    message $Usage
-    exit 1
-fi
-dev=$1
-case $dev in
-    /dev/rsd[0-9]c|/dev/rvnd[0-9]c)
-       ;;
-    /dev/sd[0-9]c|/dev/vnd[0-9]c)
-       dev=`echo $dev | $SED -e 's+/dev/+/dev/r+'`;;
-    rsd[0-9]c|rvnd[0-9]c)
-       dev=/dev/$dev;;
-    rsd[0-9]|rvnd[0-9])
-       dev=/dev/${dev}c;;
-    sd[0-9]c|vnd[0-9]c)
-       dev=/dev/r$dev;;
-    sd[0-9]|vnd[0-9])
-       dev=/dev/r${dev}c;;
-    *)
-       message $Usage
-       exit 1;;
-esac
-
-
-if [ ! -f $mboot ]; then
-    message "$prog: $mboot: No such file or directory."
-    exit 1
-fi
-if [ \( ! -s $mboot \) -o `wc -c < $mboot` -gt 1024 ]; then
-    message "$prog: $mboot: Invalid mboot."
-    exit 1
-fi
-if [ ! -c $dev ]; then
-    message "$prog: $dev: No such file or directory."
-    exit 1
-fi
-
-
-##
-## Collect disk information.
-##
-if [ X`$DD if=$dev | $DD bs=8 count=1 2> /dev/null` = X"X68SCSI1" ]; then
-    if [ "$force" = "0" ]; then
-       message "$dev is already marked.  Use -f to overwrite the existing mark."
-       exit 1
-    fi
-fi
-if [ "$checkonly" = "1" ]; then
-    exit 0
-fi
-vmessage -n "Inspecting $dev... "
-sect=`$DISKLABEL $dev 2> /dev/null | \
-       $AWK -F: '/^bytes\/sector:/ \
-                   {if ( $2 != 512 ) {
-                       print "This type of disk is not supported." \
-                               > "/dev/stderr"
-                       exit 1
-                   }
-                }
-                /total sectors:/ \
-                   {print $2}'` \
-       || exit 1
-vmessage "total number of sector is $sect."
-
-##
-## Build the disk mark.
-##
-vmessage -n "Building disk mark... "
-$AWK -v "n=$sect" -v "C=$C" '
-       BEGIN {
-           printf "X68SCSI1%c%c%c%c%c%c%c%c%s", \



Home | Main Index | Thread Index | Old Index