From 39d85a8b94c7682acc7bc2158a39ab370a94fb58 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 14 Oct 2009 15:44:22 -0700 Subject: [PATCH 1/3] Remove pragmas from new libefi files. --- lib/libefi/include/sys/efi_partition.h | 6 ++++-- lib/libefi/include/sys/uuid.h | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libefi/include/sys/efi_partition.h b/lib/libefi/include/sys/efi_partition.h index 46fb424c05..55a381c76a 100644 --- a/lib/libefi/include/sys/efi_partition.h +++ b/lib/libefi/include/sys/efi_partition.h @@ -26,8 +26,6 @@ #ifndef _SYS_EFI_PARTITION_H #define _SYS_EFI_PARTITION_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include #ifdef __cplusplus @@ -221,7 +219,11 @@ struct partition64 { /* * Number of EFI partitions */ +#if defined(__linux__) +#define EFI_NUMPAR 128 /* Expected by parted-1.8.1 */ +#else #define EFI_NUMPAR 9 +#endif #ifndef _KERNEL extern int efi_alloc_and_init(int, uint32_t, struct dk_gpt **); diff --git a/lib/libefi/include/sys/uuid.h b/lib/libefi/include/sys/uuid.h index 683643e312..9ce872e345 100644 --- a/lib/libefi/include/sys/uuid.h +++ b/lib/libefi/include/sys/uuid.h @@ -27,8 +27,6 @@ #ifndef _SYS_UUID_H #define _SYS_UUID_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif From 09a8c9909781329718511e108b59fe4242e68872 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 14 Oct 2009 15:47:41 -0700 Subject: [PATCH 2/3] Additional build system update for libefi library. This include updating all the Makefile.am to have the correct include paths and libraries. In addition, the zlib m4 macro was updated to more correctly integrate with the Makefiles. And I added two new macros libblkid and libuuid which will be needed by subsequent commits for blkid and uuid support respectively. The blkid support is optional, the uuid support is mandatory for libefi. --- cmd/zdb/Makefile.am | 4 +- cmd/zfs/Makefile.am | 4 +- cmd/zinject/Makefile.am | 4 +- cmd/zpool/Makefile.am | 2 +- cmd/ztest/Makefile.am | 4 +- config/user-libblkid.m4 | 94 +++++++++++++++++++++++++++++++++++++++++ config/user-libuuid.m4 | 18 ++++++++ config/user-zlib.m4 | 19 ++++++--- config/user.m4 | 2 + zfs.spec.in | 8 ++-- 10 files changed, 144 insertions(+), 15 deletions(-) create mode 100644 config/user-libblkid.m4 create mode 100644 config/user-libuuid.m4 diff --git a/cmd/zdb/Makefile.am b/cmd/zdb/Makefile.am index e58a2a1f43..469ff7f9ab 100644 --- a/cmd/zdb/Makefile.am +++ b/cmd/zdb/Makefile.am @@ -2,6 +2,7 @@ include $(top_srcdir)/config/Rules.am DEFAULT_INCLUDES += \ -I${top_srcdir}/lib/libspl/include \ + -I${top_srcdir}/lib/libefi/include \ -I${top_srcdir}/lib/libzpool/include \ -I${top_srcdir}/lib/libnvpair/include \ -I${top_srcdir}/lib/libzfs/include \ @@ -20,10 +21,11 @@ zdb_SOURCES = \ zdb_LDADD = \ $(top_builddir)/lib/libspl/libspl.la \ $(top_builddir)/lib/libavl/libavl.la \ + $(top_builddir)/lib/libefi/libefi.la \ $(top_builddir)/lib/libnvpair/libnvpair.la \ $(top_builddir)/lib/libunicode/libunicode.la \ $(top_builddir)/lib/libuutil/libuutil.la \ $(top_builddir)/lib/libzpool/libzpool.la \ $(top_builddir)/lib/libzfs/libzfs.la -zdb_LDFLAGS = -pthread -lm -lz -lrt +zdb_LDFLAGS = -pthread -lm $(ZLIB) -lrt $(LIBUUID) diff --git a/cmd/zfs/Makefile.am b/cmd/zfs/Makefile.am index 8b2dfd6be6..1d21a905a5 100644 --- a/cmd/zfs/Makefile.am +++ b/cmd/zfs/Makefile.am @@ -2,6 +2,7 @@ include $(top_srcdir)/config/Rules.am DEFAULT_INCLUDES += \ -I${top_srcdir}/lib/libspl/include \ + -I${top_srcdir}/lib/libefi/include \ -I${top_srcdir}/lib/libuutil/include \ -I${top_srcdir}/lib/libzfs/include \ -I${top_srcdir}/lib/libnvpair/include \ @@ -21,10 +22,11 @@ zfs_SOURCES = \ zfs_LDADD = \ $(top_builddir)/lib/libspl/libspl.la \ $(top_builddir)/lib/libavl/libavl.la \ + $(top_builddir)/lib/libefi/libefi.la \ $(top_builddir)/lib/libnvpair/libnvpair.la \ $(top_builddir)/lib/libunicode/libunicode.la \ $(top_builddir)/lib/libuutil/libuutil.la \ $(top_builddir)/lib/libzpool/libzpool.la \ $(top_builddir)/lib/libzfs/libzfs.la -zfs_LDFLAGS = -pthread -lm -lz -lrt +zfs_LDFLAGS = -pthread -lm $(ZLIB) -lrt $(LIBUUID) diff --git a/cmd/zinject/Makefile.am b/cmd/zinject/Makefile.am index 861d5933ad..3dc95532c7 100644 --- a/cmd/zinject/Makefile.am +++ b/cmd/zinject/Makefile.am @@ -2,6 +2,7 @@ include $(top_srcdir)/config/Rules.am DEFAULT_INCLUDES += \ -I${top_srcdir}/lib/libspl/include \ + -I${top_srcdir}/lib/libefi/include \ -I${top_srcdir}/lib/libzpool/include \ -I${top_srcdir}/lib/libuutil/include \ -I${top_srcdir}/lib/libzfs/include \ @@ -23,10 +24,11 @@ zinject_SOURCES = \ zinject_LDADD = \ $(top_builddir)/lib/libspl/libspl.la \ $(top_builddir)/lib/libavl/libavl.la \ + $(top_builddir)/lib/libefi/libefi.la \ $(top_builddir)/lib/libnvpair/libnvpair.la \ $(top_builddir)/lib/libunicode/libunicode.la \ $(top_builddir)/lib/libuutil/libuutil.la \ $(top_builddir)/lib/libzpool/libzpool.la \ $(top_builddir)/lib/libzfs/libzfs.la -zinject_LDFLAGS = -pthread -lm -lz -lrt +zinject_LDFLAGS = -pthread -lm $(ZLIB) -lrt $(LIBUUID) diff --git a/cmd/zpool/Makefile.am b/cmd/zpool/Makefile.am index 076954c039..2900abb2f8 100644 --- a/cmd/zpool/Makefile.am +++ b/cmd/zpool/Makefile.am @@ -30,4 +30,4 @@ zpool_LDADD = \ $(top_builddir)/lib/libzpool/libzpool.la \ $(top_builddir)/lib/libzfs/libzfs.la -zpool_LDFLAGS = -pthread -lm -lz -lrt +zpool_LDFLAGS = -pthread -lm $(ZLIB) -lrt $(LIBUUID) diff --git a/cmd/ztest/Makefile.am b/cmd/ztest/Makefile.am index c1dae8f592..5ed0890dea 100644 --- a/cmd/ztest/Makefile.am +++ b/cmd/ztest/Makefile.am @@ -2,6 +2,7 @@ include $(top_srcdir)/config/Rules.am DEFAULT_INCLUDES += \ -I${top_srcdir}/lib/libspl/include \ + -I${top_srcdir}/lib/libefi/include \ -I${top_srcdir}/lib/libzpool/include \ -I${top_srcdir}/lib/libuutil/include \ -I${top_srcdir}/lib/libzfs/include \ @@ -21,10 +22,11 @@ ztest_SOURCES = \ ztest_LDADD = \ $(top_builddir)/lib/libspl/libspl.la \ $(top_builddir)/lib/libavl/libavl.la \ + $(top_builddir)/lib/libefi/libefi.la \ $(top_builddir)/lib/libnvpair/libnvpair.la \ $(top_builddir)/lib/libunicode/libunicode.la \ $(top_builddir)/lib/libuutil/libuutil.la \ $(top_builddir)/lib/libzpool/libzpool.la \ $(top_builddir)/lib/libzfs/libzfs.la -ztest_LDFLAGS = -pthread -lm -lz -lrt -ldl +ztest_LDFLAGS = -pthread -lm $(ZLIB) -lrt -ldl $(LIBUUID) diff --git a/config/user-libblkid.m4 b/config/user-libblkid.m4 new file mode 100644 index 0000000000..8934d0ab80 --- /dev/null +++ b/config/user-libblkid.m4 @@ -0,0 +1,94 @@ +dnl # +dnl # Check for ZFS support in libblkid. This test needs to check +dnl # more than if the library exists because we expect there are +dnl # at least 3 flavors of the library out in the wild: +dnl # +dnl # 1) blkid which has no ZFS support +dnl # 2) blkid with ZFS support and a flawed method of probing +dnl # 3) blkid with ZFS support and a working method of probing +dnl # +dnl # To handle this the check first validates that there is a version +dnl # of the library installed. If there is it creates a simulated +dnl # ZFS filesystem and then links a small test app which attempts +dnl # to detect the simualated filesystem type. If it correctly +dnl # identifies the filesystem as ZFS we can safely assume case 3). +dnl # Otherwise we disable blkid support and resort to manual probing. +dnl # +AC_DEFUN([ZFS_AC_CONFIG_USER_LIBBLKID], [ + AC_ARG_WITH([blkid], + [AS_HELP_STRING([--with-blkid], + [support blkid caching @<:@default=check@:>@])], + [], + [with_blkid=check]) + + LIBBLKID= + AS_IF([test "x$with_blkid" != xno], + [ + AC_CHECK_LIB([blkid], [blkid_get_cache], + [ + AC_MSG_CHECKING([for blkid zfs support]) + + ZFS_DEV=`mktemp` + dd if=/dev/zero of=$ZFS_DEV bs=1024k count=8 \ + >/dev/null 2>/dev/null + echo -en "\x0c\xb1\xba\0\0\0\0\0" | \ + dd of=$ZFS_DEV bs=1k count=8 \ + seek=132 conv=notrunc &>/dev/null \ + >/dev/null 2>/dev/null + + saved_LDFLAGS="$LDFLAGS" + LDFLAGS="-lblkid" + + AC_RUN_IFELSE(AC_LANG_PROGRAM( + [ + #include + #include + ], + [ + blkid_cache cache; + char *value; + + if (blkid_get_cache(&cache, NULL) < 0) + return 1; + + value = blkid_get_tag_value(cache, "TYPE", + "$ZFS_DEV"); + if (!value) { + blkid_put_cache(cache); + return 2; + } + + if (strcmp(value, "zfs")) { + free(value); + blkid_put_cache(cache); + return 3; + } + + free(value); + blkid_put_cache(cache); + ]), + [ + rm -f $ZFS_DEV + AC_MSG_RESULT([yes]) + AC_SUBST([LIBBLKID], ["-lblkid"]) + AC_DEFINE([HAVE_LIBBLKID], 1, + [Define if you have libblkid]) + ], + [ + rm -f $ZFS_DEV + AC_MSG_RESULT([no]) + AS_IF([test "x$with_blkid" != xcheck], + [AC_MSG_FAILURE( + [--with-blkid given but unavailable])]) + ]) + + LDFLAGS="$saved_LDFLAGS" + ], + [ + AS_IF([test "x$with_blkid" != xcheck], + [AC_MSG_FAILURE( + [--with-blkid given but unavailable])]) + ] + []) + ]) +]) diff --git a/config/user-libuuid.m4 b/config/user-libuuid.m4 new file mode 100644 index 0000000000..0a669b7d6a --- /dev/null +++ b/config/user-libuuid.m4 @@ -0,0 +1,18 @@ +dnl # +dnl # Check for libuuid +dnl # +AC_DEFUN([ZFS_AC_CONFIG_USER_LIBUUID], [ + LIBUUID= + + AC_CHECK_HEADER([uuid/uuid.h], [], [AC_MSG_FAILURE([ + *** uuid/uuid.h missing, e2fsprogs-devel package required])]) + + AC_CHECK_LIB([uuid], [uuid_generate], [], [AC_MSG_FAILURE([ + *** uuid_generate() missing, e2fsprogs-devel package required])]) + + AC_CHECK_LIB([uuid], [uuid_is_null], [], [AC_MSG_FAILURE([ + *** uuid_is_null() missing, e2fsprogs-devel package required])]) + + AC_SUBST([LIBUUID], ["-luuid"]) + AC_DEFINE([HAVE_LIBUUID], 1, [Define if you have libuuid]) +]) diff --git a/config/user-zlib.m4 b/config/user-zlib.m4 index 999c409eda..5f2a545823 100644 --- a/config/user-zlib.m4 +++ b/config/user-zlib.m4 @@ -2,10 +2,17 @@ dnl # dnl # Check for zlib dnl # AC_DEFUN([ZFS_AC_CONFIG_USER_ZLIB], [ - AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([ - *** zlib.h missing, the zlib-devel package is required])]) - AC_CHECK_LIB([z], [compress2], [], [AC_MSG_ERROR([ - *** compress2() missing, the zlib-devel package is required])]) - AC_CHECK_LIB([z], [uncompress], [], [AC_MSG_ERROR([ - *** uncompress() missing, the zlib-devel package is required])]) + ZLIB= + + AC_CHECK_HEADER([zlib.h], [], [AC_MSG_FAILURE([ + *** zlib.h missing, zlib-devel package required])]) + + AC_CHECK_LIB([z], [compress2], [], [AC_MSG_FAILURE([ + *** compress2() missing, zlib-devel package required])]) + + AC_CHECK_LIB([z], [uncompress], [], [AC_MSG_FAILURE([ + *** uncompress() missing, zlib-devel package required])]) + + AC_SUBST([ZLIB], ["-lz"]) + AC_DEFINE([HAVE_ZLIB], 1, [Define if you have zlib]) ]) diff --git a/config/user.m4 b/config/user.m4 index 7ecc241afe..f8bda8e0ff 100644 --- a/config/user.m4 +++ b/config/user.m4 @@ -7,4 +7,6 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [ ZFS_AC_CONFIG_USER_LIBSHARE ZFS_AC_CONFIG_USER_IOCTL ZFS_AC_CONFIG_USER_ZLIB + ZFS_AC_CONFIG_USER_LIBUUID + ZFS_AC_CONFIG_USER_LIBBLKID ]) diff --git a/zfs.spec.in b/zfs.spec.in index 87093ea590..34c32a47f0 100644 --- a/zfs.spec.in +++ b/zfs.spec.in @@ -12,8 +12,8 @@ License: CDDL URL: git://eris.llnl.gov/zfs.git BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id} -un) Source: %{name}-%{version}.tar.gz -Requires: zlib -BuildRequires: zlib-devel +Requires: zlib e2fsprogs +BuildRequires: zlib-devel e2fsprogs-devel %description The %{name} package contains the libzfs library and support utilities @@ -22,8 +22,8 @@ for the zfs file system. %package devel Summary: ZFS File System User Headers Group: Development/Libraries -Requires: zlib -BuildRequires: zlib-devel +Requires: zlib e2fsprogs +BuildRequires: zlib-devel e2fsprogs-devel %description devel The %{name}-devel package contains the header files needed for building From 8a905e7dcc5e26d54c13021e50470531743aa14f Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 14 Oct 2009 15:52:24 -0700 Subject: [PATCH 3/3] Update vtoc.h header and add missing mhd.h header needed by libefi. --- lib/libspl/include/sys/mhd.h | 159 ++++++++++++++++++++++++++++++++++ lib/libspl/include/sys/vtoc.h | 157 ++++++++++++++++++++++++++++++--- 2 files changed, 304 insertions(+), 12 deletions(-) create mode 100644 lib/libspl/include/sys/mhd.h diff --git a/lib/libspl/include/sys/mhd.h b/lib/libspl/include/sys/mhd.h new file mode 100644 index 0000000000..fcc062d51c --- /dev/null +++ b/lib/libspl/include/sys/mhd.h @@ -0,0 +1,159 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MHD_H +#define _SYS_MHD_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions for multi-host device I/O control commands + */ +#define MHIOC ('M'<<8) +#define MHIOCENFAILFAST (MHIOC|1) +#define MHIOCTKOWN (MHIOC|2) +#define MHIOCRELEASE (MHIOC|3) +#define MHIOCSTATUS (MHIOC|4) +#define MHIOCGRP_INKEYS (MHIOC|5) +#define MHIOCGRP_INRESV (MHIOC|6) +#define MHIOCGRP_REGISTER (MHIOC|7) +#define MHIOCGRP_RESERVE (MHIOC|8) +#define MHIOCGRP_PREEMPTANDABORT (MHIOC|9) +#define MHIOCGRP_PREEMPT (MHIOC|10) +#define MHIOCGRP_CLEAR (MHIOC|11) +#define MHIOCGRP_REGISTERANDIGNOREKEY (MHIOC|14) +#define MHIOCQRESERVE (MHIOC|12) +#define MHIOCREREGISTERDEVID (MHIOC|13) + +/* + * Following is the structure to specify the delay parameters in + * milliseconds, via the MHIOCTKOWN ioctl. + */ +struct mhioctkown { + int reinstate_resv_delay; + int min_ownership_delay; + int max_ownership_delay; +}; + +#define MHIOC_RESV_KEY_SIZE 8 +typedef struct mhioc_resv_key { + uchar_t key[MHIOC_RESV_KEY_SIZE]; +} mhioc_resv_key_t; + +typedef struct mhioc_key_list { + uint32_t listsize; + uint32_t listlen; + mhioc_resv_key_t *list; +} mhioc_key_list_t; + +typedef struct mhioc_inkeys { + uint32_t generation; + mhioc_key_list_t *li; +} mhioc_inkeys_t; + +#if defined(_SYSCALL32) +struct mhioc_key_list32 { + uint32_t listsize; + uint32_t listlen; + caddr32_t list; +} mhioc_key_list32_t; + +struct mhioc_inkeys32 { + uint32_t generation; + caddr32_t li; +} mhioc_inkeys32_t; +#endif + +typedef struct mhioc_resv_desc { + mhioc_resv_key_t key; + uint8_t type; + uint8_t scope; + uint32_t scope_specific_addr; +} mhioc_resv_desc_t; + +typedef struct mhioc_resv_desc_list { + uint32_t listsize; + uint32_t listlen; + mhioc_resv_desc_t *list; +} mhioc_resv_desc_list_t; + +typedef struct mhioc_inresvs { + uint32_t generation; + mhioc_resv_desc_list_t *li; +} mhioc_inresvs_t; + +#if defined(_SYSCALL32) +struct mhioc_resv_desc_list32 { + uint32_t listsize; + uint32_t listlen; + caddr32_t list; +} mhioc_resv_desc_list32_t; + +typedef struct mhioc_inresvs32 { + uint32_t generation; + caddr32_t li; +} mhioc_inresvs32_t; +#endif + +typedef struct mhioc_register { + mhioc_resv_key_t oldkey; + mhioc_resv_key_t newkey; + boolean_t aptpl; /* True if persistent across power failures */ +} mhioc_register_t; + +typedef struct mhioc_preemptandabort { + mhioc_resv_desc_t resvdesc; + mhioc_resv_key_t victim_key; +} mhioc_preemptandabort_t; + +typedef struct mhioc_registerandignorekey { + mhioc_resv_key_t newkey; + boolean_t aptpl; /* True if persistent across power failures */ +} mhioc_registerandignorekey_t; + +/* + * SCSI-3 PGR Reservation Type Codes. Codes with the _OBSOLETE suffix + * have been removed from the SCSI3 PGR standard. + */ +#define SCSI3_RESV_READSHARED_OBSOLETE 0 +#define SCSI3_RESV_WRITEEXCLUSIVE 1 +#define SCSI3_RESV_READEXCLUSIVE_OBSOLETE 2 +#define SCSI3_RESV_EXCLUSIVEACCESS 3 +#define SCSI3_RESV_SHAREDACCESS_OBSOLETE 4 +#define SCSI3_RESV_WRITEEXCLUSIVEREGISTRANTSONLY 5 +#define SCSI3_RESV_EXCLUSIVEACCESSREGISTRANTSONLY 6 + +#define SCSI3_SCOPE_LOGICALUNIT 0 +#define SCSI3_SCOPE_EXTENT_OBSOLETE 1 +#define SCSI3_SCOPE_ELEMENT 2 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MHD_H */ diff --git a/lib/libspl/include/sys/vtoc.h b/lib/libspl/include/sys/vtoc.h index 3dd25eeb10..004b49097a 100644 --- a/lib/libspl/include/sys/vtoc.h +++ b/lib/libspl/include/sys/vtoc.h @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,8 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 1997-1998,2002 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -32,8 +32,6 @@ #ifndef _SYS_VTOC_H #define _SYS_VTOC_H - - #include #ifdef __cplusplus @@ -64,6 +62,7 @@ extern "C" { #define VTOC_SANE 0x600DDEEE /* Indicates a sane VTOC */ #define V_VERSION 0x01 /* layout version number */ +#define V_EXTVERSION V_VERSION /* extvtoc layout version number */ /* * Partition identification tags @@ -94,10 +93,12 @@ extern "C" { #define VT_EIO (-3) /* I/O error accessing vtoc */ #define VT_EINVAL (-4) /* illegal value in vtoc or request */ #define VT_ENOTSUP (-5) /* VTOC op. not supported */ +#define VT_ENOSPC (-6) /* requested space not found */ +#define VT_EOVERFLOW (-7) /* VTOC op. data struct limited */ struct partition { ushort_t p_tag; /* ID tag of partition */ - ushort_t p_flag; /* permision flags */ + ushort_t p_flag; /* permission flags */ daddr_t p_start; /* start sector no of partition */ long p_size; /* # of blocks in partition */ }; @@ -115,10 +116,83 @@ struct vtoc { char v_asciilabel[LEN_DKL_ASCII]; /* for compatibility */ }; +struct extpartition { + ushort_t p_tag; /* ID tag of partition */ + ushort_t p_flag; /* permission flags */ + ushort_t p_pad[2]; + diskaddr_t p_start; /* start sector no of partition */ + diskaddr_t p_size; /* # of blocks in partition */ +}; + + +struct extvtoc { + uint64_t v_bootinfo[3]; /* info needed by mboot (unsupported) */ + uint64_t v_sanity; /* to verify vtoc sanity */ + uint64_t v_version; /* layout version */ + char v_volume[LEN_DKL_VVOL]; /* volume name */ + ushort_t v_sectorsz; /* sector size in bytes */ + ushort_t v_nparts; /* number of partitions */ + ushort_t pad[2]; + uint64_t v_reserved[10]; + struct extpartition v_part[V_NUMPAR]; /* partition headers */ + uint64_t timestamp[V_NUMPAR]; /* partition timestamp (unsupported) */ + char v_asciilabel[LEN_DKL_ASCII]; /* for compatibility */ +}; + +#ifdef _KERNEL +#define extvtoctovtoc(extv, v) \ + { \ + int i; \ + v.v_bootinfo[0] = (unsigned long)extv.v_bootinfo[0]; \ + v.v_bootinfo[1] = (unsigned long)extv.v_bootinfo[1]; \ + v.v_bootinfo[2] = (unsigned long)extv.v_bootinfo[2]; \ + v.v_sanity = (unsigned long)extv.v_sanity; \ + v.v_version = (unsigned long)extv.v_version; \ + bcopy(extv.v_volume, v.v_volume, LEN_DKL_VVOL); \ + v.v_sectorsz = extv.v_sectorsz; \ + v.v_nparts = extv.v_nparts; \ + for (i = 0; i < 10; i++) \ + v.v_reserved[i] = (unsigned long)extv.v_reserved[i]; \ + for (i = 0; i < V_NUMPAR; i++) { \ + v.v_part[i].p_tag = extv.v_part[i].p_tag; \ + v.v_part[i].p_flag = extv.v_part[i].p_flag; \ + v.v_part[i].p_start = (daddr_t)extv.v_part[i].p_start; \ + v.v_part[i].p_size = (long)extv.v_part[i].p_size; \ + v.timestamp[i] = (time_t)extv.timestamp[i]; \ + } \ + bcopy(extv.v_asciilabel, v.v_asciilabel, LEN_DKL_ASCII); \ + } + +#define vtoctoextvtoc(v, extv) \ + { \ + int i; \ + extv.v_bootinfo[0] = (uint64_t)v.v_bootinfo[0]; \ + extv.v_bootinfo[1] = (uint64_t)v.v_bootinfo[1]; \ + extv.v_bootinfo[2] = (uint64_t)v.v_bootinfo[2]; \ + extv.v_sanity = (uint64_t)v.v_sanity; \ + extv.v_version = (uint64_t)v.v_version; \ + bcopy(v.v_volume, extv.v_volume, LEN_DKL_VVOL); \ + extv.v_sectorsz = v.v_sectorsz; \ + extv.v_nparts = v.v_nparts; \ + for (i = 0; i < 10; i++) \ + extv.v_reserved[i] = (uint64_t)v.v_reserved[i]; \ + for (i = 0; i < V_NUMPAR; i++) { \ + extv.v_part[i].p_tag = v.v_part[i].p_tag; \ + extv.v_part[i].p_flag = v.v_part[i].p_flag; \ + extv.v_part[i].p_start = \ + (diskaddr_t)(unsigned long)v.v_part[i].p_start; \ + extv.v_part[i].p_size = \ + (diskaddr_t)(unsigned long)v.v_part[i].p_size; \ + extv.timestamp[i] = (uint64_t)v.timestamp[i]; \ + } \ + bcopy(v.v_asciilabel, extv.v_asciilabel, LEN_DKL_ASCII); \ + } +#endif /* _KERNEL */ + #if defined(_SYSCALL32) struct partition32 { uint16_t p_tag; /* ID tag of partition */ - uint16_t p_flag; /* permision flags */ + uint16_t p_flag; /* permission flags */ daddr32_t p_start; /* start sector no of partition */ int32_t p_size; /* # of blocks in partition */ }; @@ -153,14 +227,39 @@ struct vtoc32 { for (i = 0; i < V_NUMPAR; i++) { \ v.v_part[i].p_tag = (ushort_t)v32.v_part[i].p_tag; \ v.v_part[i].p_flag = (ushort_t)v32.v_part[i].p_flag; \ - v.v_part[i].p_start = (daddr_t)v32.v_part[i].p_start; \ - v.v_part[i].p_size = (long)v32.v_part[i].p_size; \ + v.v_part[i].p_start = (unsigned)v32.v_part[i].p_start; \ + v.v_part[i].p_size = (unsigned)v32.v_part[i].p_size; \ } \ for (i = 0; i < V_NUMPAR; i++) \ v.timestamp[i] = (time_t)v32.timestamp[i]; \ bcopy(v32.v_asciilabel, v.v_asciilabel, LEN_DKL_ASCII); \ } +#define vtoc32toextvtoc(v32, extv) \ + { \ + int i; \ + extv.v_bootinfo[0] = v32.v_bootinfo[0]; \ + extv.v_bootinfo[1] = v32.v_bootinfo[1]; \ + extv.v_bootinfo[2] = v32.v_bootinfo[2]; \ + extv.v_sanity = v32.v_sanity; \ + extv.v_version = v32.v_version; \ + bcopy(v32.v_volume, extv.v_volume, LEN_DKL_VVOL); \ + extv.v_sectorsz = v32.v_sectorsz; \ + extv.v_nparts = v32.v_nparts; \ + extv.v_version = v32.v_version; \ + for (i = 0; i < 10; i++) \ + extv.v_reserved[i] = v32.v_reserved[i]; \ + for (i = 0; i < V_NUMPAR; i++) { \ + extv.v_part[i].p_tag = (ushort_t)v32.v_part[i].p_tag; \ + extv.v_part[i].p_flag = (ushort_t)v32.v_part[i].p_flag; \ + extv.v_part[i].p_start = (diskaddr_t)v32.v_part[i].p_start; \ + extv.v_part[i].p_size = (diskaddr_t)v32.v_part[i].p_size; \ + extv.timestamp[i] = (time_t)v32.timestamp[i]; \ + } \ + bcopy(v32.v_asciilabel, extv.v_asciilabel, LEN_DKL_ASCII); \ + } + + #define vtoctovtoc32(v, v32) \ { \ int i; \ @@ -178,8 +277,8 @@ struct vtoc32 { for (i = 0; i < V_NUMPAR; i++) { \ v32.v_part[i].p_tag = (ushort_t)v.v_part[i].p_tag; \ v32.v_part[i].p_flag = (ushort_t)v.v_part[i].p_flag; \ - v32.v_part[i].p_start = (daddr32_t)v.v_part[i].p_start; \ - v32.v_part[i].p_size = (int32_t)v.v_part[i].p_size; \ + v32.v_part[i].p_start = (unsigned)v.v_part[i].p_start; \ + v32.v_part[i].p_size = (unsigned)v.v_part[i].p_size; \ } \ for (i = 0; i < V_NUMPAR; i++) { \ if (v.timestamp[i] > TIME32_MAX) \ @@ -190,6 +289,36 @@ struct vtoc32 { bcopy(v.v_asciilabel, v32.v_asciilabel, LEN_DKL_ASCII); \ } +#define extvtoctovtoc32(extv, v32) \ + { \ + int i; \ + v32.v_bootinfo[0] = extv.v_bootinfo[0]; \ + v32.v_bootinfo[1] = extv.v_bootinfo[1]; \ + v32.v_bootinfo[2] = extv.v_bootinfo[2]; \ + v32.v_sanity = extv.v_sanity; \ + v32.v_version = extv.v_version; \ + bcopy(extv.v_volume, v32.v_volume, LEN_DKL_VVOL); \ + v32.v_sectorsz = extv.v_sectorsz; \ + v32.v_nparts = extv.v_nparts; \ + v32.v_version = extv.v_version; \ + for (i = 0; i < 10; i++) \ + v32.v_reserved[i] = extv.v_reserved[i]; \ + for (i = 0; i < V_NUMPAR; i++) { \ + v32.v_part[i].p_tag = (ushort_t)extv.v_part[i].p_tag; \ + v32.v_part[i].p_flag = (ushort_t)extv.v_part[i].p_flag; \ + v32.v_part[i].p_start = (unsigned)extv.v_part[i].p_start; \ + v32.v_part[i].p_size = (unsigned)extv.v_part[i].p_size; \ + } \ + for (i = 0; i < V_NUMPAR; i++) { \ + if (extv.timestamp[i] > TIME32_MAX) \ + v32.timestamp[i] = TIME32_MAX; \ + else \ + v32.timestamp[i] = (time32_t)extv.timestamp[i]; \ + } \ + bcopy(extv.v_asciilabel, v32.v_asciilabel, LEN_DKL_ASCII); \ + } + + #endif /* _SYSCALL32 */ /* @@ -202,11 +331,15 @@ struct vtoc32 { extern int read_vtoc(int, struct vtoc *); extern int write_vtoc(int, struct vtoc *); +extern int read_extvtoc(int, struct extvtoc *); +extern int write_extvtoc(int, struct extvtoc *); #else extern int read_vtoc(); extern int write_vtoc(); +extern int read_extvtoc(); +extern int write_extvtoc(); #endif /* __STDC__ */