Source-Changes-HG archive

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

[src/trunk]: src/sys centralize setdisklabel(9)



details:   https://anonhg.NetBSD.org/src/rev/c1b49a2cae1d
branches:  trunk
changeset: 450046:c1b49a2cae1d
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Apr 03 22:10:49 2019 +0000

description:
centralize setdisklabel(9)

diffstat:

 sys/arch/alpha/alpha/disksubr.c               |  57 +-------------------
 sys/arch/amiga/amiga/disksubr.c               |  43 +--------------
 sys/arch/arc/arc/disksubr.c                   |  59 +--------------------
 sys/arch/arm/arm/disksubr.c                   |  63 +---------------------
 sys/arch/atari/atari/disksubr.c               |  56 +-------------------
 sys/arch/cobalt/cobalt/disksubr.c             |  59 +--------------------
 sys/arch/evbmips/evbmips/disksubr.c           |  49 +----------------
 sys/arch/evbmips/sbmips/disksubr.c            |  58 +-------------------
 sys/arch/evbppc/evbppc/disksubr.c             |  55 +------------------
 sys/arch/ews4800mips/include/disklabel.h      |   5 +-
 sys/arch/hp300/hp300/disksubr.c               |  43 +--------------
 sys/arch/hpc/hpc/disksubr.c                   |  59 +--------------------
 sys/arch/hppa/hppa/disksubr.c                 |  67 +-----------------------
 sys/arch/luna68k/luna68k/disksubr.c           |  48 +----------------
 sys/arch/mac68k/include/disklabel.h           |   4 +-
 sys/arch/mac68k/mac68k/disksubr.c             |  54 +------------------
 sys/arch/macppc/include/disklabel.h           |   4 +-
 sys/arch/mipsco/mipsco/disksubr.c             |  43 +--------------
 sys/arch/mvme68k/mvme68k/disksubr.c           |  71 +------------------------
 sys/arch/news68k/news68k/disksubr.c           |  43 +--------------
 sys/arch/newsmips/newsmips/disksubr.c         |  43 +--------------
 sys/arch/next68k/next68k/disksubr.c           |  42 +--------------
 sys/arch/ofppc/ofppc/disksubr.c               |  56 +-------------------
 sys/arch/playstation2/playstation2/disksubr.c |  59 +--------------------
 sys/arch/pmax/pmax/disksubr.c                 |  44 +--------------
 sys/arch/sbmips/sbmips/disksubr.c             |  58 +-------------------
 sys/arch/sgimips/sgimips/disksubr.c           |  39 +-------------
 sys/arch/sh3/sh3/disksubr.c                   |  59 +--------------------
 sys/arch/vax/vax/disksubr.c                   |  44 +--------------
 sys/arch/x68k/x68k/disksubr.c                 |  60 +--------------------
 sys/dev/sun/disksubr.c                        |  44 +--------------
 sys/kern/subr_disk.c                          |  76 ++++++++++++++++++++++++++-
 sys/kern/subr_disk_mbr.c                      |  57 +-------------------
 33 files changed, 143 insertions(+), 1478 deletions(-)

diffs (truncated from 2286 to 300 lines):

diff -r 814f99af686e -r c1b49a2cae1d sys/arch/alpha/alpha/disksubr.c
--- a/sys/arch/alpha/alpha/disksubr.c   Wed Apr 03 21:41:21 2019 +0000
+++ b/sys/arch/alpha/alpha/disksubr.c   Wed Apr 03 22:10:49 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: disksubr.c,v 1.41 2012/02/06 02:14:11 matt Exp $ */
+/* $NetBSD: disksubr.c,v 1.42 2019/04/03 22:10:49 christos Exp $ */
 
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.41 2012/02/06 02:14:11 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.42 2019/04/03 22:10:49 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -141,59 +141,6 @@
 }
 
 /*
- * Check new disk label for sensibility before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask, struct cpu_disklabel *clp)
-{
-       int i;
-       struct partition *opp, *npp;
-
-       /* sanity clause */
-       if (nlp->d_secpercyl == 0 || nlp->d_secsize == 0 ||
-           (nlp->d_secsize % DEV_BSIZE) != 0)
-               return(EINVAL);
-
-#ifdef notdef
-       /* XXX WHY WAS THIS HERE?! */
-       /* special case to allow disklabel to be invalidated */
-       if (nlp->d_magic == 0xffffffff) {
-               *olp = *nlp;
-               return (0);
-       }
-#endif
-
-       if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
-               dkcksum(nlp) != 0)
-               return (EINVAL);
-
-       while ((i = ffs(openmask)) != 0) {
-               i--;
-               openmask &= ~(1 << i);
-               if (nlp->d_npartitions <= i)
-                       return (EBUSY);
-               opp = &olp->d_partitions[i];
-               npp = &nlp->d_partitions[i];
-               if (npp->p_offset != opp->p_offset || npp->p_size < opp->p_size)
-                       return (EBUSY);
-               /*
-               * Copy internally-set partition information
-               * if new label doesn't include it.             XXX
-               */
-               if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) {
-                       npp->p_fstype = opp->p_fstype;
-                       npp->p_fsize = opp->p_fsize;
-                       npp->p_frag = opp->p_frag;
-                       npp->p_cpg = opp->p_cpg;
-               }
-       }
-       nlp->d_checksum = 0;
-       nlp->d_checksum = dkcksum(nlp);
-       *olp = *nlp;
-       return (0);
-}
-
-/*
  * Write disk label back to device after modification.
  * This means write out the rigid disk blocks to represent the
  * label.  Hope the user was careful.
diff -r 814f99af686e -r c1b49a2cae1d sys/arch/amiga/amiga/disksubr.c
--- a/sys/arch/amiga/amiga/disksubr.c   Wed Apr 03 21:41:21 2019 +0000
+++ b/sys/arch/amiga/amiga/disksubr.c   Wed Apr 03 22:10:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disksubr.c,v 1.69 2018/09/03 16:29:22 riastradh Exp $  */
+/*     $NetBSD: disksubr.c,v 1.70 2019/04/03 22:10:49 christos Exp $   */
 
 /*
  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.69 2018/09/03 16:29:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.70 2019/04/03 22:10:49 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -499,45 +499,6 @@
 }
 
 /*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask, struct cpu_disklabel *clp)
-{
-       int i;
-       struct partition *opp, *npp;
-
-       if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
-           dkcksum(nlp) != 0)
-               return (EINVAL);
-       while ((i = ffs(openmask)) != 0) {
-               i--;
-               openmask &= ~(1 << i);
-               if (nlp->d_npartitions <= i)
-                       return (EBUSY);
-               opp = &olp->d_partitions[i];
-               npp = &nlp->d_partitions[i];
-               if (npp->p_offset != opp->p_offset || npp->p_size < opp->p_size)
-                       return (EBUSY);
-               /*
-                * Copy internally-set partition information
-                * if new label doesn't include it.             XXX
-                */
-               if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) {
-                       npp->p_fstype = opp->p_fstype;
-                       npp->p_fsize = opp->p_fsize;
-                       npp->p_frag = opp->p_frag;
-                       npp->p_cpg = opp->p_cpg;
-               }
-       }
-       nlp->d_checksum = 0;
-       nlp->d_checksum = dkcksum(nlp);
-       *olp = *nlp;
-       return (0);
-}
-
-/*
  * Write disk label back to device after modification.
  * this means write out the Rigid disk blocks to represent the
  * label.  Hope the user was carefull.
diff -r 814f99af686e -r c1b49a2cae1d sys/arch/arc/arc/disksubr.c
--- a/sys/arch/arc/arc/disksubr.c       Wed Apr 03 21:41:21 2019 +0000
+++ b/sys/arch/arc/arc/disksubr.c       Wed Apr 03 22:10:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disksubr.c,v 1.29 2013/05/16 19:06:44 christos Exp $   */
+/*     $NetBSD: disksubr.c,v 1.30 2019/04/03 22:10:49 christos Exp $   */
 /*     $OpenBSD: disksubr.c,v 1.14 1997/05/08 00:14:29 deraadt Exp $   */
 /*     NetBSD: disksubr.c,v 1.40 1999/05/06 15:45:51 christos Exp      */
 
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.29 2013/05/16 19:06:44 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.30 2019/04/03 22:10:49 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -356,61 +356,6 @@
 }
 
 /*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask,
-    struct cpu_disklabel *osdep)
-{
-       int i;
-       struct partition *opp, *npp;
-
-       /* sanity clause */
-       if (nlp->d_secpercyl == 0 || nlp->d_secsize == 0 ||
-           (nlp->d_secsize % DEV_BSIZE) != 0)
-               return EINVAL;
-
-       /* special case to allow disklabel to be invalidated */
-       if (nlp->d_magic == 0xffffffff) {
-               *olp = *nlp;
-               return 0;
-       }
-
-       if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
-           dkcksum(nlp) != 0)
-               return EINVAL;
-
-       /* XXX missing check if other dos partitions will be overwritten */
-
-       while (openmask != 0) {
-               i = ffs(openmask) - 1;
-               openmask &= ~(1 << i);
-               if (nlp->d_npartitions <= i)
-                       return EBUSY;
-               opp = &olp->d_partitions[i];
-               npp = &nlp->d_partitions[i];
-               if (npp->p_offset != opp->p_offset || npp->p_size < opp->p_size)
-                       return EBUSY;
-               /*
-                * Copy internally-set partition information
-                * if new label doesn't include it.             XXX
-                */
-               if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) {
-                       npp->p_fstype = opp->p_fstype;
-                       npp->p_fsize = opp->p_fsize;
-                       npp->p_frag = opp->p_frag;
-                       npp->p_cpg = opp->p_cpg;
-               }
-       }
-       nlp->d_checksum = 0;
-       nlp->d_checksum = dkcksum(nlp);
-       *olp = *nlp;
-       return 0;
-}
-
-
-/*
  * Write disk label back to device after modification.
  */
 int
diff -r 814f99af686e -r c1b49a2cae1d sys/arch/arm/arm/disksubr.c
--- a/sys/arch/arm/arm/disksubr.c       Wed Apr 03 21:41:21 2019 +0000
+++ b/sys/arch/arm/arm/disksubr.c       Wed Apr 03 22:10:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disksubr.c,v 1.25 2014/04/25 20:17:28 martin Exp $     */
+/*     $NetBSD: disksubr.c,v 1.26 2019/04/03 22:10:49 christos Exp $   */
 
 /*
  * Copyright (c) 1998 Christopher G. Demetriou.  All rights reserved.
@@ -97,7 +97,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.25 2014/04/25 20:17:28 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.26 2019/04/03 22:10:49 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -264,65 +264,6 @@
 
 
 /*
- * Check new disk label for sensibility
- * before setting it.
- */
-
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask,
-    struct cpu_disklabel *osdep)
-{
-       int i;
-       struct partition *opp, *npp;
-
-       /* sanity clause */
-
-       if (nlp->d_secpercyl == 0 || nlp->d_secsize == 0
-           || (nlp->d_secsize % DEV_BSIZE) != 0)
-               return(EINVAL);
-
-       /* special case to allow disklabel to be invalidated */
-
-       if (nlp->d_magic == 0xffffffff) {
-               *olp = *nlp;
-               return (0);
-       }
-
-       if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC
-           || dkcksum(nlp) != 0)
-               return (EINVAL);
-
-       /* XXX add check if other acorn/dos partitions will be overwritten */
-
-       while (openmask != 0) {
-               i = ffs(openmask) - 1;
-               openmask &= ~(1 << i);
-               if (nlp->d_npartitions <= i)
-                       return (EBUSY);
-               opp = &olp->d_partitions[i];
-               npp = &nlp->d_partitions[i];
-               if (npp->p_offset != opp->p_offset || npp->p_size < opp->p_size)
-                       return (EBUSY);
-               /*
-                * Copy internally-set partition information
-                * if new label doesn't include it.             XXX
-                */
-               if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) {
-                       npp->p_fstype = opp->p_fstype;
-                       npp->p_fsize = opp->p_fsize;
-                       npp->p_frag = opp->p_frag;
-                       npp->p_cpg = opp->p_cpg;
-               }
-       }
-
-       nlp->d_checksum = 0;
-       nlp->d_checksum = dkcksum(nlp);
-       *olp = *nlp;
-       return (0);
-}



Home | Main Index | Thread Index | Old Index