Source-Changes-HG archive

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

[src/netbsd-1-5]: src/sys/arch/atari/stand/ahdilabel Pullup ahdilabel. Reques...



details:   https://anonhg.NetBSD.org/src/rev/6d3bddeb87f3
branches:  netbsd-1-5
changeset: 489109:6d3bddeb87f3
user:      leo <leo%NetBSD.org@localhost>
date:      Mon Aug 14 07:59:58 2000 +0000

description:
Pullup ahdilabel. Requested by leo, approved by thorpej.

ahdilabel allows to edit AHDI (== the native Atari format) disklabels from
within NetBSD. From Julian Coleman.

diffstat:

 sys/arch/atari/stand/ahdilabel/Makefile    |   13 +
 sys/arch/atari/stand/ahdilabel/ahdilabel.8 |  167 +++++++++++++
 sys/arch/atari/stand/ahdilabel/ahdilabel.c |  362 +++++++++++++++++++++++++++++
 sys/arch/atari/stand/ahdilabel/build.c     |   92 +++++++
 sys/arch/atari/stand/ahdilabel/check.c     |  146 +++++++++++
 sys/arch/atari/stand/ahdilabel/cksum.c     |   73 +++++
 sys/arch/atari/stand/ahdilabel/magic.c     |   81 ++++++
 sys/arch/atari/stand/ahdilabel/openraw.c   |   68 +++++
 sys/arch/atari/stand/ahdilabel/privahdi.h  |   94 +++++++
 sys/arch/atari/stand/ahdilabel/read.c      |  280 ++++++++++++++++++++++
 sys/arch/atari/stand/ahdilabel/write.c     |  351 ++++++++++++++++++++++++++++
 sys/arch/atari/stand/ahdilabel/writedtab.c |  116 +++++++++
 12 files changed, 1843 insertions(+), 0 deletions(-)

diffs (truncated from 1891 to 300 lines):

diff -r a4fcc4f051aa -r 6d3bddeb87f3 sys/arch/atari/stand/ahdilabel/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/atari/stand/ahdilabel/Makefile   Mon Aug 14 07:59:58 2000 +0000
@@ -0,0 +1,13 @@
+#      $NetBSD: Makefile,v 1.1.1.1.2.2 2000/08/14 07:59:58 leo Exp $
+
+PROG=  ahdilabel
+SRCS=  ahdilabel.c build.c check.c cksum.c magic.c openraw.c read.c write.c \
+       writedtab.c
+
+MAN=   ahdilabel.8
+MANSUBDIR=     /atari
+
+WARNS= 1
+
+CFLAGS += -g
+.include <bsd.prog.mk>
diff -r a4fcc4f051aa -r 6d3bddeb87f3 sys/arch/atari/stand/ahdilabel/ahdilabel.8
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/atari/stand/ahdilabel/ahdilabel.8        Mon Aug 14 07:59:58 2000 +0000
@@ -0,0 +1,167 @@
+.\"    $NetBSD: ahdilabel.8,v 1.1.1.1.2.2 2000/08/14 07:59:58 leo Exp $
+.\"
+.\"
+.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Julian Coleman and Leo Weppelman.
+.\"
+.\" 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.
+
+.Dd July 29, 2000
+.Dt AHDILABEL 8
+.Os
+.Sh NAME
+.Nm ahdilabel
+.Nd modify AHDI partitions
+.Sh SYNOPSIS
+.Nm ahdilabel
+.Ar disk
+.Sh DESCRIPTION
+.Nm ahdilabel
+allows you to modify the AHDI partition table on a disk partitioned with
+AHDI or an AHDI compatible formatter.  The AHDI partition format is usually
+only present on disks shared between
+.Nx
+and some other OS. The partition identifiers are used by
+.Nx
+as a guideline to emulate a disklabel on such a disk.
+.Pp
+.Nm ahdilabel
+supports the following options:
+.Pp
+.Bl -tag -width disk
+.It Ar disk
+The name of the disk you want to edit.
+.Nm ahdilabel
+will first try to open a disk of this name.  If this cannot
+be opened, it will attempt to open
+.Ar r Ns <disk> Ns Ar c .
+Finally, if this also cannot be opened, it will attempt to open
+.Ar /dev/r Ns <disk> Ns Ar c .
+.El
+.Pp
+.Nm ahdilabel
+will display information about the number of sectors, tracks
+and sectors on the disk, as well as the current AHDI partition information.
+It will then prompt for input.  The input choices are:
+.Pp
+.Bl -tag -width a-p
+.It Ar a-p
+Modify a partition.  You will be prompted for a partition id, root, start
+and size.
+.Nx
+recognises the following partition id's:
+.Pp
+.Bl -tag -width "GEM or BGM" -compact
+.It NBD
+Partition is reserved for
+.Nx .
+This can be either a root or an user partition. The first NBD
+partition on a disk will be mapped to
+.Nx partition
+letter
+.Em a .
+The following NBD partitions will be mapped from letter
+.Em d
+up.
+The filesystem type is ffs by default.
+.It SWP
+The first SWP partition is mapped to partition
+.Em b.
+.It GEM or BGM
+These partitions are mapped from 
+.Em d
+up. The filesystem type is msdos.
+.El
+.Pp
+The root, start and size parameters can be entered using sector or
+cylinder/track/sector notation.  Whole numbers of cylinders can be entered
+using the shorthand <cylinder>/.  Likewise, whole numbers of tracks can be
+entered using the shorthand <cylinder>/<track>/.
+.Pp
+The sector holding the primary AHDI partition table only has space for four
+partitions.  Thus, if a disk has more than four partitions, the extra
+partition information is held in auxilliary root sectors.  There is one
+auxilliary root for each additional partition (and also for the fourth
+partition, if the disk has more than four partitions).
+.It Ar r
+Recalculate the root sectors.  This will automatically assign auxilliary
+root sectors if the disk has more than 4 partitions.  The auxilliary root
+sectors will be positioned in a default location preceeding the relevant
+partition.
+.It Ar s
+Show the current partition information.
+.It Ar u
+Toggle the unit display between sector and cylinder/track/sector notation.
+.It Ar w
+Write the AHDI partition table to the disk.
+.It Ar q
+Quit
+.El
+.Sh EXAMPLES
+.Dl ahdilabel sd0
+Edit the AHDI label for disk sd0.
+.Sh CAVEATS
+The changes made to the AHDI partitions will become active on the next
+.Em first open
+of the disk. You are advised to use
+.Nm ahdilabel
+only on a disk without any mounted or otherwise active partitions. This
+is not enforced by
+.Nm ahdilabel.
+.Pp
+Because of way
+.Nx
+interprets AHDI partition tables to create the
+.Nx
+disklabel, the
+.Nx
+partition ordering may change if partitions labelled NBD are created or
+removed.
+.Pp
+Creating an AHDI partition table on a disk that previously did not have
+one will almost certainly overwrite any existing partition information
+and/or data on that disk.  This is especially the case if auxilliary root
+sectors are needed for the AHDI partition table.
+.Pp
+As soon as a disk contains at least one NBD partition, you are allowed to
+write
+.Nx
+disklabels and install bootstraps.
+.Sh SEE ALSO
+.Xr bootpref 8 ,
+.Xr disklabel 8 ,
+.Xr installboot 8
+.Sh HISTORY
+The
+.Nm ahdilabel
+command first appeared in
+.Nx 1.5 .
diff -r a4fcc4f051aa -r 6d3bddeb87f3 sys/arch/atari/stand/ahdilabel/ahdilabel.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/atari/stand/ahdilabel/ahdilabel.c        Mon Aug 14 07:59:58 2000 +0000
@@ -0,0 +1,362 @@
+/* $NetBSD: ahdilabel.c,v 1.1.1.1.2.2 2000/08/14 07:59:59 leo Exp $ */
+
+/*
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Julian Coleman.
+ *
+ * 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.
+ */
+
+#include "privahdi.h"
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+
+/*
+ * I think we can safely assume a fixed blocksize - AHDI won't support
+ * something different...
+ */
+#define        BLPM            ((1024 * 1024) / DEV_BSIZE)
+#define        UNITS_SECTORS   0
+#define        UNITS_CTS       1
+
+int             main (int, char*[]);
+void            show_parts (struct ahdi_ptable*, int, int, int);
+void            get_input (char *, int);
+char           *sec_to_cts (struct ahdi_ptable*, u_int32_t, char *);
+u_int32_t       read_sector (struct ahdi_ptable*,char *);
+void            change_part (struct ahdi_ptable*, int, int);
+
+int
+main (argc, argv)
+       int      argc;
+       char    *argv[];
+{
+       struct ahdi_ptable      ptable;
+       int                     flags, rv, key, units;
+
+       if (argc < 2) {
+               fprintf (stderr, "usage: %s raw_disk\n", argv[0]);
+               exit (EXIT_FAILURE);
+       }
+       
+       flags = 0;
+       while ((rv = ahdi_readlabel(&ptable, argv[1], flags)) != 1) {
+               switch (rv) {
+               case -1:
+                       fprintf (stderr,
+                           "%s: %s: %s\n", argv[0], argv[1],
+                           strerror (errno));
+                       exit (EXIT_FAILURE);
+                       break;
+               case -2:
+                       fprintf (stderr,
+                           "%s: disk not 512 bytes/sector\n", argv[0]);
+                       exit (EXIT_FAILURE);
+                       break;
+               case -3:
+                       printf ("No AHDI partitions found.  Continue (y/N)?");
+                       if (toupper(getchar()) == 'Y') {
+                               (void) fpurge(stdin);
+                               flags |= FORCE_AHDI;
+                       } else
+                               exit (EXIT_FAILURE);
+                       break;
+               case -4:
+               case -5:
+               case -6:
+                       printf ("Errors reading AHDI partition table.  Override (y/N)? ");
+                       if (toupper(getchar()) == 'Y') {
+                               (void) fpurge(stdin);
+                               flags |= AHDI_IGN_EXISTS | AHDI_IGN_EXT |
+                                   AHDI_IGN_CKSUM | AHDI_IGN_SPU;
+                       } else
+                               exit (EXIT_FAILURE);
+                       break;
+               case 1:
+                       /* Everything is OK */



Home | Main Index | Thread Index | Old Index