diff options
| author | mrg <mrg@NetBSD.org> | 2021-05-17 08:50:36 +0000 |
|---|---|---|
| committer | mrg <mrg@NetBSD.org> | 2021-05-17 08:50:36 +0000 |
| commit | 4a1c505c3aa01c4085b1bdc1943f01b32f74686f (patch) | |
| tree | 0d9476e7c683b787419e0b7842856654b9b20245 /sys/lib/libsa | |
| parent | 03d5e513598dab88a575ee4f59a0e37083a6c8ef (diff) | |
move bi-endian disklabel support from the kernel and libsa into libkern.
- dkcksum() and dkcksum_sized() move from subr_disk.c and from
libsa into libkern/dkcksum.c (which is missing _sized() version),
using the version from usr.sbin/disklabel.
- swap_disklabel() moves from subr_disk_mbr.c into libkern, now called
disklabel_swap(). (the sh3 version should be updated to use this.)
- DISKLABEL_EI becomes a first-class option with opt_disklabel.h.
- add libkern.h to libsa/disklabel.c.
this enables future work for bi-endian libsa/ufs.c (relevant for ffsv1,
ffsv2, lfsv1, and lfsv2), as well as making it possible for ports not
using subr_disk_mbr.c to include bi-endian disklabel support (which,
afaict, includes any disk on mbr-supporting platforms that do not have
an mbr as well as disklabel.)
builds successsfully on: alpha, i386, amd64, sun2, sun3, evbarm64,
evbarm64-eb, sparc, and sparc64. tested in anita on i386 and sparc,
testing in hardware on evbarm64*.
Diffstat (limited to 'sys/lib/libsa')
| -rw-r--r-- | sys/lib/libsa/Makefile | 4 | ||||
| -rw-r--r-- | sys/lib/libsa/disklabel.c | 3 | ||||
| -rw-r--r-- | sys/lib/libsa/dkcksum.c | 52 | ||||
| -rw-r--r-- | sys/lib/libsa/stand.h | 3 |
4 files changed, 5 insertions, 57 deletions
diff --git a/sys/lib/libsa/Makefile b/sys/lib/libsa/Makefile index c308c7dc8da..82528340450 100644 --- a/sys/lib/libsa/Makefile +++ b/sys/lib/libsa/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.93 2020/09/07 01:54:26 mrg Exp $ +# $NetBSD: Makefile,v 1.94 2021/05/17 08:50:36 mrg Exp $ LIB= sa LIBISPRIVATE?= yes @@ -46,7 +46,7 @@ SRCS+= memcmp.c memcpy.c memmove.c memset.c strchr.c SRCS+= bcopy.c bzero.c # Remove me eventually. # io routines -SRCS+= closeall.c dev.c disklabel.c dkcksum.c ioctl.c nullfs.c stat.c fstat.c +SRCS+= closeall.c dev.c disklabel.c ioctl.c nullfs.c stat.c fstat.c SRCS+= close.c lseek.c open.c read.c write.c .if (${SA_USE_CREAD} == "yes") CPPFLAGS+= -D__INTERNAL_LIBSA_CREAD diff --git a/sys/lib/libsa/disklabel.c b/sys/lib/libsa/disklabel.c index f6aca5a7c68..de0c2223c33 100644 --- a/sys/lib/libsa/disklabel.c +++ b/sys/lib/libsa/disklabel.c @@ -1,4 +1,4 @@ -/* $NetBSD: disklabel.c,v 1.10 2007/11/24 13:20:54 isaki Exp $ */ +/* $NetBSD: disklabel.c,v 1.11 2021/05/17 08:50:36 mrg Exp $ */ /*- * Copyright (c) 1993 @@ -33,6 +33,7 @@ #include <sys/param.h> #include <sys/disklabel.h> +#include <lib/libkern/libkern.h> #include "stand.h" diff --git a/sys/lib/libsa/dkcksum.c b/sys/lib/libsa/dkcksum.c deleted file mode 100644 index 3a96cc48bbc..00000000000 --- a/sys/lib/libsa/dkcksum.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: dkcksum.c,v 1.5 2005/12/11 12:24:46 christos Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. 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. 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. - * - * @(#)disklabel.c 8.1 (Berkeley) 6/11/93 - */ - -#include <sys/param.h> -#include <sys/disklabel.h> -#include "stand.h" - -/* - * Compute checksum for disk label. - */ -int -dkcksum(const struct disklabel *lp) -{ - const u_short *start, *end; - u_short sum = 0; - - start = (const void *)lp; - end = (const void *)&lp->d_partitions[lp->d_npartitions]; - while (start < end) - sum ^= *start++; - return sum; -} diff --git a/sys/lib/libsa/stand.h b/sys/lib/libsa/stand.h index c6d0a7bbd56..7c92ea34eb9 100644 --- a/sys/lib/libsa/stand.h +++ b/sys/lib/libsa/stand.h @@ -1,4 +1,4 @@ -/* $NetBSD: stand.h,v 1.82 2016/08/27 18:59:18 dholland Exp $ */ +/* $NetBSD: stand.h,v 1.83 2021/05/17 08:50:36 mrg Exp $ */ /* * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved. @@ -246,7 +246,6 @@ void *alloc(size_t) __compactcall; void dealloc(void *, size_t) __compactcall; struct disklabel; char *getdisklabel(const char *, struct disklabel *); -int dkcksum(const struct disklabel *); void printf(const char *, ...) __attribute__((__format__(__printf__, 1, 2))); |
