[Midnightbsd-cvs] src [11206] sync up

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun Jul 1 16:41:50 EDT 2018


Revision: 11206
          http://svnweb.midnightbsd.org/src/?rev=11206
Author:   laffer1
Date:     2018-07-01 16:41:49 -0400 (Sun, 01 Jul 2018)
Log Message:
-----------
sync up

Modified Paths:
--------------
    trunk/sbin/geom/class/Makefile.inc
    trunk/sbin/geom/class/cache/Makefile
    trunk/sbin/geom/class/cache/gcache.8
    trunk/sbin/geom/class/cache/geom_cache.c
    trunk/sbin/geom/class/concat/Makefile
    trunk/sbin/geom/class/concat/gconcat.8
    trunk/sbin/geom/class/concat/geom_concat.c
    trunk/sbin/geom/class/eli/Makefile
    trunk/sbin/geom/class/eli/geli.8
    trunk/sbin/geom/class/eli/geom_eli.c
    trunk/sbin/geom/class/journal/Makefile
    trunk/sbin/geom/class/journal/geom_journal.c
    trunk/sbin/geom/class/journal/geom_journal.h
    trunk/sbin/geom/class/journal/geom_journal_ufs.c
    trunk/sbin/geom/class/journal/gjournal.8
    trunk/sbin/geom/class/label/Makefile
    trunk/sbin/geom/class/label/geom_label.c
    trunk/sbin/geom/class/label/glabel.8
    trunk/sbin/geom/class/mirror/Makefile
    trunk/sbin/geom/class/mirror/geom_mirror.c
    trunk/sbin/geom/class/mirror/gmirror.8
    trunk/sbin/geom/class/mountver/Makefile
    trunk/sbin/geom/class/mountver/geom_mountver.c
    trunk/sbin/geom/class/mountver/gmountver.8
    trunk/sbin/geom/class/multipath/Makefile
    trunk/sbin/geom/class/multipath/geom_multipath.c
    trunk/sbin/geom/class/multipath/gmultipath.8
    trunk/sbin/geom/class/nop/Makefile
    trunk/sbin/geom/class/nop/geom_nop.c
    trunk/sbin/geom/class/nop/gnop.8
    trunk/sbin/geom/class/part/Makefile
    trunk/sbin/geom/class/part/geom_part.c
    trunk/sbin/geom/class/part/gpart.8
    trunk/sbin/geom/class/raid3/Makefile
    trunk/sbin/geom/class/raid3/geom_raid3.c
    trunk/sbin/geom/class/raid3/graid3.8
    trunk/sbin/geom/class/sched/Makefile
    trunk/sbin/geom/class/sched/geom_sched.c
    trunk/sbin/geom/class/sched/gsched.8
    trunk/sbin/geom/class/shsec/Makefile
    trunk/sbin/geom/class/shsec/geom_shsec.c
    trunk/sbin/geom/class/shsec/gshsec.8
    trunk/sbin/geom/class/stripe/Makefile
    trunk/sbin/geom/class/stripe/geom_stripe.c
    trunk/sbin/geom/class/stripe/gstripe.8
    trunk/sbin/geom/class/virstor/Makefile
    trunk/sbin/geom/class/virstor/geom_virstor.c
    trunk/sbin/geom/class/virstor/gvirstor.8

Property Changed:
----------------
    trunk/sbin/geom/class/Makefile.inc
    trunk/sbin/geom/class/cache/gcache.8
    trunk/sbin/geom/class/concat/gconcat.8
    trunk/sbin/geom/class/eli/geli.8
    trunk/sbin/geom/class/journal/gjournal.8
    trunk/sbin/geom/class/label/glabel.8
    trunk/sbin/geom/class/mirror/gmirror.8
    trunk/sbin/geom/class/mountver/gmountver.8
    trunk/sbin/geom/class/multipath/gmultipath.8
    trunk/sbin/geom/class/nop/gnop.8
    trunk/sbin/geom/class/part/gpart.8
    trunk/sbin/geom/class/raid3/graid3.8
    trunk/sbin/geom/class/sched/gsched.8
    trunk/sbin/geom/class/shsec/gshsec.8
    trunk/sbin/geom/class/stripe/gstripe.8
    trunk/sbin/geom/class/virstor/gvirstor.8

Modified: trunk/sbin/geom/class/Makefile.inc
===================================================================
--- trunk/sbin/geom/class/Makefile.inc	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/Makefile.inc	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sbin/geom/class/Makefile.inc 249657 2013-04-19 19:45:00Z ed $
 
 SHLIBDIR?=${GEOM_CLASS_DIR}
 SHLIB_NAME?=geom_${GEOM_CLASS}.so
@@ -6,6 +7,8 @@
 MAN=	g${GEOM_CLASS}.8
 SRCS+=	geom_${GEOM_CLASS}.c subr.c
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
 CFLAGS+= -I${.CURDIR}/../..
 
 .include "../Makefile.inc"


Property changes on: trunk/sbin/geom/class/Makefile.inc
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/geom/class/cache/Makefile
===================================================================
--- trunk/sbin/geom/class/cache/Makefile	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/cache/Makefile	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sbin/geom/class/cache/Makefile 216468 2010-12-15 23:24:34Z obrien $
 
 .PATH: ${.CURDIR}/../../misc
 

Modified: trunk/sbin/geom/class/cache/gcache.8
===================================================================
--- trunk/sbin/geom/class/cache/gcache.8	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/cache/gcache.8	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\"-
 .\" Copyright (c) 2010 Edward Tomasz Napierala
 .\" All rights reserved.
@@ -23,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/geom/class/cache/gcache.8 307403 2016-10-16 22:02:50Z sevan $
 .\"
 .Dd January 3, 2010
 .Dt GCACHE 8
@@ -189,4 +190,4 @@
 utility appeared in
 .Fx 7.0 .
 .Sh AUTHORS
-.An Ruslan Ermilov Aq ru at FreeBSD.org
+.An Ruslan Ermilov Aq Mt ru at FreeBSD.org


Property changes on: trunk/sbin/geom/class/cache/gcache.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/geom/class/cache/geom_cache.c
===================================================================
--- trunk/sbin/geom/class/cache/geom_cache.c	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/cache/geom_cache.c	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 Ruslan Ermilov <ru at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/geom/class/cache/geom_cache.c 330737 2018-03-10 04:17:01Z asomers $");
 
 #include <errno.h>
 #include <stdio.h>
@@ -135,6 +136,7 @@
 	int error, nargs;
 	intmax_t val;
 
+	bzero(sector, sizeof(sector));
 	nargs = gctl_get_int(req, "nargs");
 	if (nargs != 2) {
 		gctl_error(req, "Invalid number of arguments.");

Modified: trunk/sbin/geom/class/concat/Makefile
===================================================================
--- trunk/sbin/geom/class/concat/Makefile	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/concat/Makefile	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sbin/geom/class/concat/Makefile 216468 2010-12-15 23:24:34Z obrien $
 
 .PATH: ${.CURDIR}/../../misc
 

Modified: trunk/sbin/geom/class/concat/gconcat.8
===================================================================
--- trunk/sbin/geom/class/concat/gconcat.8	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/concat/gconcat.8	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd at FreeBSD.org>
 .\" All rights reserved.
 .\"
@@ -22,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/geom/class/concat/gconcat.8 307403 2016-10-16 22:02:50Z sevan $
 .\"
 .Dd May 21, 2004
 .Dt GCONCAT 8
@@ -183,11 +184,11 @@
 .Xr loader.conf 5 ,
 .Xr geom 8 ,
 .Xr growfs 8 ,
+.Xr gvinum 8 ,
 .Xr mount 8 ,
 .Xr newfs 8 ,
 .Xr sysctl 8 ,
-.Xr umount 8 ,
-.Xr vinum 8
+.Xr umount 8
 .Sh HISTORY
 The
 .Nm
@@ -194,4 +195,4 @@
 utility appeared in
 .Fx 5.3 .
 .Sh AUTHORS
-.An Pawel Jakub Dawidek Aq pjd at FreeBSD.org
+.An Pawel Jakub Dawidek Aq Mt pjd at FreeBSD.org


Property changes on: trunk/sbin/geom/class/concat/gconcat.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/geom/class/concat/geom_concat.c
===================================================================
--- trunk/sbin/geom/class/concat/geom_concat.c	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/concat/geom_concat.c	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/geom/class/concat/geom_concat.c 330737 2018-03-10 04:17:01Z asomers $");
 
 #include <sys/param.h>
 #include <errno.h>
@@ -117,6 +118,7 @@
 	const char *name;
 	int error, i, hardcode, nargs;
 
+	bzero(sector, sizeof(sector));
 	nargs = gctl_get_int(req, "nargs");
 	if (nargs < 2) {
 		gctl_error(req, "Too few arguments.");

Modified: trunk/sbin/geom/class/eli/Makefile
===================================================================
--- trunk/sbin/geom/class/eli/Makefile	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/eli/Makefile	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sbin/geom/class/eli/Makefile 314327 2017-02-27 08:27:38Z avg $
 
 .PATH: ${.CURDIR}/../../misc ${.CURDIR}/../../../../sys/geom/eli ${.CURDIR}/../../../../sys/crypto/sha2
 
@@ -6,7 +7,8 @@
 SRCS=	g_eli_crypto.c
 SRCS+=	g_eli_key.c
 SRCS+=	pkcs5v2.c
-SRCS+=	sha2.c
+SRCS+=	sha256c.c
+SRCS+=	sha512c.c
 
 DPADD=	${LIBMD} ${LIBCRYPTO}
 LDADD=	-lmd -lcrypto

Modified: trunk/sbin/geom/class/eli/geli.8
===================================================================
--- trunk/sbin/geom/class/eli/geli.8	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/eli/geli.8	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2005-2011 Pawel Jakub Dawidek <pawel at dawidek.net>
 .\" All rights reserved.
 .\"
@@ -22,16 +23,16 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/geom/class/eli/geli.8 307403 2016-10-16 22:02:50Z sevan $
 .\"
-.Dd March 9, 2011
+.Dd June 18, 2014
 .Dt GELI 8
 .Os
 .Sh NAME
 .Nm geli
-.Nd "control utility for cryptographic GEOM class"
+.Nd "control utility for the cryptographic GEOM class"
 .Sh SYNOPSIS
-To compile GEOM_ELI into your kernel, place the following lines in your kernel
+To compile GEOM_ELI into your kernel, add the following lines to your kernel
 configuration file:
 .Bd -ragged -offset indent
 .Cd "device crypto"
@@ -38,8 +39,8 @@
 .Cd "options GEOM_ELI"
 .Ed
 .Pp
-Alternately, to load the GEOM_ELI module at boot time, place the following line
-in your
+Alternatively, to load the GEOM_ELI module at boot time, add the following line
+to your
 .Xr loader.conf 5 :
 .Bd -literal -offset indent
 geom_eli_load="YES"
@@ -46,7 +47,7 @@
 .Ed
 .Pp
 Usage of the
-.Xr geli 8
+.Nm
 utility:
 .Pp
 .Nm
@@ -60,6 +61,7 @@
 .Op Fl K Ar newkeyfile
 .Op Fl l Ar keylen
 .Op Fl s Ar sectorsize
+.Op Fl V Ar version
 .Ar prov
 .Nm
 .Cm label - an alias for
@@ -134,6 +136,9 @@
 .Fl s Ar oldsize
 .Ar prov
 .Nm
+.Cm version
+.Op Ar prov ...
+.Nm
 .Cm clear
 .Op Fl v
 .Ar prov ...
@@ -182,13 +187,15 @@
 or
 .Nm HMAC/SHA512 .
 .It
-Can create a key from a couple of components (user entered passphrase, random
-bits from a file, etc.).
+Can create a User Key from up to two, piecewise components: a passphrase
+entered via prompt or read from one or more passfiles; a keyfile read from
+one or more files.
 .It
-Allows to encrypt the root partition - the user will be asked for the
+Allows encryption of the root partition.
+The user will be asked for the
 passphrase before the root file system is mounted.
 .It
-The passphrase of the user is strengthened with:
+Strengthens the passphrase component of the User Key with:
 .Rs
 .%A B. Kaliski
 .%T "PKCS #5: Password-Based Cryptography Specification, Version 2.0."
@@ -196,9 +203,9 @@
 .%N 2898
 .Re
 .It
-Allows to use two independent keys (e.g.
+Allows the use of two independent User Keys (e.g., a
 .Qq "user key"
-and
+and a
 .Qq "company key" ) .
 .It
 It is fast -
@@ -205,20 +212,21 @@
 .Nm
 performs simple sector-to-sector encryption.
 .It
-Allows to backup/restore Master Keys, so when a user has to quickly
-destroy his keys,
-it is possible to get the data back by restoring keys from the backup.
+Allows the encrypted Master Key to be backed up and restored,
+so that if a user has to quickly destroy key material,
+it is possible to get the data back by restoring keys from
+backup.
 .It
 Providers can be configured to automatically detach on last close
 (so users do not have to remember to detach providers after unmounting
 the file systems).
 .It
-Allows to attach a provider with a random, one-time key - useful for swap
-partitions and temporary file systems.
+Allows attaching a provider with a random, one-time Master Key -
+useful for swap partitions and temporary file systems.
 .It
-Allows to verify data integrity (data authentication).
+Allows verification of data integrity (data authentication).
 .It
-Allows to suspend and resume encrypted devices.
+Allows suspending and resuming encrypted devices.
 .El
 .Pp
 The first argument to
@@ -226,12 +234,13 @@
 indicates an action to be performed:
 .Bl -tag -width ".Cm configure"
 .It Cm init
-Initialize provider which needs to be encrypted.
-Here you can set up the cryptographic algorithm to use, key length, etc.
-The last provider's sector is used to store metadata.
+Initialize the provider which needs to be encrypted.
+Here you can set up the cryptographic algorithm to use, Data Key length,
+etc.
+The last sector of the provider is used to store metadata.
 The
 .Cm init
-subcommand also automatically backups metadata in
+subcommand also automatically writes metadata backups to
 .Pa /var/backups/<prov>.eli
 file.
 The metadata can be recovered with the
@@ -242,7 +251,7 @@
 .Bl -tag -width ".Fl J Ar newpassfile"
 .It Fl a Ar aalgo
 Enable data integrity verification (authentication) using the given algorithm.
-This will reduce size of available storage and also reduce speed.
+This will reduce the size of storage available and also reduce speed.
 For example, when using 4096 bytes sector and
 .Nm HMAC/SHA256
 algorithm, 89% of the original provider storage will be available for use.
@@ -277,54 +286,88 @@
 .Nm AES-XTS ,
 .Nm AES-CBC ,
 .Nm Blowfish-CBC ,
-.Nm Camellia-CBC
+.Nm Camellia-CBC ,
+.Nm 3DES-CBC ,
 and
-.Nm 3DES-CBC .
+.Nm NULL .
 The default and recommended algorithm is
 .Nm AES-XTS .
+.Nm NULL
+is unencrypted.
 .It Fl i Ar iterations
-Number of iterations to use with PKCS#5v2.
+Number of iterations to use with PKCS#5v2 when processing User Key
+passphrase component.
 If this option is not specified,
 .Nm
 will find the number of iterations which is equal to 2 seconds of crypto work.
 If 0 is given, PKCS#5v2 will not be used.
+PKCS#5v2 processing is performed once, after all parts of the passphrase
+component have been read.
 .It Fl J Ar newpassfile
-Specifies a file which contains the passphrase or its part.
+Specifies a file which contains the passphrase component of the User Key
+(or part of it).
 If
 .Ar newpassfile
 is given as -, standard input will be used.
 Only the first line (excluding new-line character) is taken from the given file.
-This argument can be specified multiple times.
+This argument can be specified multiple times, which has the effect of
+reassembling a single passphrase split across multiple files.
+Cannot be combined with the
+.Fl P
+option.
 .It Fl K Ar newkeyfile
-Specifies a file which contains part of the key.
+Specifies a file which contains the keyfile component of the User Key
+(or part of it).
 If
 .Ar newkeyfile
 is given as -, standard input will be used.
-This argument can be specified multiple times.
+This argument can be specified multiple times, which has the effect of
+reassembling a single keyfile split across multiple keyfile parts.
 .It Fl l Ar keylen
-Key length to use with the given cryptographic algorithm.
-If not given, the default key length for the given algorithm is used, which is:
-128 for
-.Nm AES-XTS ,
-.Nm AES-CBC ,
-.Nm Blowfish-CBC
-and
-.Nm Camellia-CBC
-and 192 for
-.Nm 3DES-CBC .
+Data Key length to use with the given cryptographic algorithm.
+If the length is not specified, the selected algorithm uses its
+.Em default
+key length.
+.Bl -ohang -offset indent
+.It Nm AES-XTS
+.Em 128 ,
+256
+.It Nm AES-CBC , Nm Camellia-CBC
+.Em 128 ,
+192,
+256
+.It Nm Blowfish-CBC
+.Em 128
++ n * 32, for n=[0..10]
+.It Nm 3DES-CBC
+.Em 192
+.El
 .It Fl P
-Do not use passphrase as the key component.
+Do not use a passphrase as a component of the User Key.
+Cannot be combined with the
+.Fl J
+option.
 .It Fl s Ar sectorsize
 Change decrypted provider's sector size.
-Increasing sector size allows to increase performance, because we need to
-generate an IV and do encrypt/decrypt for every single sector - less number
-of sectors means less work to do.
+Increasing the sector size allows increased performance,
+because encryption/decryption which requires an initialization vector
+is done per sector; fewer sectors means less computational work.
+.It Fl V Ar version
+Metadata version to use.
+This option is helpful when creating a provider that may be used by older
+.Nm FreeBSD/GELI
+versions.
+Consult the
+.Sx HISTORY
+section to find which metadata version is supported by which FreeBSD version.
+Note that using an older version of metadata may limit the number of
+features available.
 .El
 .It Cm attach
 Attach the given provider.
-The master key will be decrypted using the given
-passphrase/keyfile and a new GEOM provider will be created using the given
-provider's name with an
+The encrypted Master Key will be loaded from the metadata and decrypted
+using the given passphrase/keyfile and a new GEOM provider will be created
+using the given provider's name with an
 .Qq .eli
 suffix.
 .Pp
@@ -332,7 +375,7 @@
 .Bl -tag -width ".Fl j Ar passfile"
 .It Fl d
 If specified, a decrypted provider will be detached automatically on last close.
-This can help with short memory - user does not have to remember to detach the
+This can help with scarce memory so the user does not have to remember to detach the
 provider after unmounting the file system.
 It only works when the provider was opened for writing, so it will not work if
 the file system on the provider is mounted read-only.
@@ -342,7 +385,8 @@
 .Cm detach
 subcommand.
 .It Fl j Ar passfile
-Specifies a file which contains the passphrase or its part.
+Specifies a file which contains the passphrase component of the User Key
+(or part of it).
 For more information see the description of the
 .Fl J
 option for the
@@ -349,7 +393,8 @@
 .Cm init
 subcommand.
 .It Fl k Ar keyfile
-Specifies a file which contains part of the key.
+Specifies a file which contains the keyfile component of the User Key
+(or part of it).
 For more information see the description of the
 .Fl K
 option for the
@@ -356,7 +401,10 @@
 .Cm init
 subcommand.
 .It Fl p
-Do not use passphrase as the key component.
+Do not use a passphrase as a component of the User Key.
+Cannot be combined with the
+.Fl j
+option.
 .It Fl r
 Attach read-only provider.
 It will not be opened for writing.
@@ -363,7 +411,7 @@
 .El
 .It Cm detach
 Detach the given providers, which means remove the devfs entry
-and clear the keys from memory.
+and clear the Master Key and Data Keys from memory.
 .Pp
 Additional options include:
 .Bl -tag -width ".Fl f"
@@ -372,12 +420,11 @@
 .It Fl l
 Mark provider to detach on last close.
 If this option is specified, the provider will not be detached
-until it is open, but when it will be closed last time, it will
-be automatically detached (even
-if it was only opened for reading).
+while it is open, but will be automatically detached when it is closed for the
+last time even if it was only opened for reading.
 .El
 .It Cm onetime
-Attach the given providers with random, one-time keys.
+Attach the given providers with a random, one-time (ephemeral) Master Key.
 The command can be used to encrypt swap partitions or temporary file systems.
 .Pp
 Additional options include:
@@ -394,7 +441,7 @@
 subcommand.
 .It Fl d
 Detach on last close.
-Note, the option is not usable for temporary file systems as the provider will
+Note: this option is not usable for temporary file systems as the provider will
 be detached after creating the file system on it.
 It still can (and should be) used for swap partitions.
 For more information, see the description of the
@@ -401,7 +448,7 @@
 .Cm attach
 subcommand.
 .It Fl l Ar keylen
-Key length to use with the given cryptographic algorithm.
+Data Key length to use with the given cryptographic algorithm.
 For more information, see the description of the
 .Cm init
 subcommand.
@@ -425,15 +472,18 @@
 Remove the BOOT flag from the given providers.
 .El
 .It Cm setkey
-Change or setup (if not yet initialized) selected key.
-There is one master key, which can be encrypted with two independent user keys.
+Install a copy of the Master Key into the selected slot, encrypted with
+a new User Key.
+If the selected slot is populated, replace the existing copy.
+A provider has one Master Key, which can be stored in one or both slots,
+each encrypted with an independent User Key.
 With the
 .Cm init
 subcommand, only key number 0 is initialized.
-The key can always be changed: for an attached provider,
-for a detached provider or on the backup file.
+The User Key can be changed at any time: for an attached provider,
+for a detached provider, or on the backup file.
 When a provider is attached, the user does not have to provide
-an old passphrase/keyfile.
+an existing passphrase/keyfile.
 .Pp
 Additional options include:
 .Bl -tag -width ".Fl J Ar newpassfile"
@@ -440,48 +490,58 @@
 .It Fl i Ar iterations
 Number of iterations to use with PKCS#5v2.
 If 0 is given, PKCS#5v2 will not be used.
-To be able to use this option with
+To be able to use this option with the
 .Cm setkey
-subcommand, only one key have to be defined and this key has to be changed.
+subcommand, only one key has to be defined and this key must be changed.
 .It Fl j Ar passfile
-Specifies a file which contains the old passphrase or its part.
+Specifies a file which contains the passphrase component of a current User Key
+(or part of it).
 .It Fl J Ar newpassfile
-Specifies a file which contains the new passphrase or its part.
+Specifies a file which contains the passphrase component of the new User Key
+(or part of it).
 .It Fl k Ar keyfile
-Specifies a file which contains part of the old key.
+Specifies a file which contains the keyfile component of a current User Key
+(or part of it).
 .It Fl K Ar newkeyfile
-Specifies a file which contains part of the new key.
+Specifies a file which contains the keyfile component of the new User Key
+(or part of it).
 .It Fl n Ar keyno
-Specifies the number of the key to change (could be 0 or 1).
+Specifies the index number of the Master Key copy to change (could be 0 or 1).
 If the provider is attached and no key number is given, the key
 used for attaching the provider will be changed.
 If the provider is detached (or we are operating on a backup file)
-and no key number is given, the key decrypted with the passphrase/keyfile
-will be changed.
+and no key number is given, the first Master Key copy to be successfully
+decrypted with the provided User Key passphrase/keyfile will be changed.
 .It Fl p
-Do not use passphrase as the old key component.
+Do not use a passphrase as a component of the current User Key.
+Cannot be combined with the
+.Fl j
+option.
 .It Fl P
-Do not use passphrase as the new key component.
+Do not use a passphrase as a component of the new User Key.
+Cannot be combined with the
+.Fl J
+option.
 .El
 .It Cm delkey
-Destroy (overwrite with random data) the selected key.
+Destroy (overwrite with random data) the selected Master Key copy.
 If one is destroying keys for an attached provider, the provider
-will not be detached even if all keys will be destroyed.
-It can be even rescued with the
+will not be detached even if all copies of the Master Key are destroyed.
+It can even be rescued with the
 .Cm setkey
-subcommand.
+subcommand because the Master Key is still in memory.
 .Pp
 Additional options include:
 .Bl -tag -width ".Fl a Ar keyno"
 .It Fl a
-Destroy all keys (does not need
+Destroy all copies of the Master Key (does not need
 .Fl f
 option).
 .It Fl f
 Force key destruction.
-This option is needed to destroy the last key.
+This option is needed to destroy the last copy of the Master Key.
 .It Fl n Ar keyno
-Specifies the key number.
+Specifies the index number of the Master Key copy.
 If the provider is attached and no key number is given, the key
 used for attaching the provider will be destroyed.
 If provider is detached (or we are operating on a backup file) the key number
@@ -488,9 +548,9 @@
 has to be given.
 .El
 .It Cm kill
-This command should be used in emergency situations.
-It will destroy all keys on the given provider and will detach it forcibly
-(if it is attached).
+This command should be used only in emergency situations.
+It will destroy all copies of the Master Key on a given provider and will
+detach it forcibly (if it is attached).
 This is absolutely a one-way command - if you do not have a metadata
 backup, your data is gone for good.
 In case the provider was attached with the
@@ -527,22 +587,23 @@
 .Cm restore .
 .El
 .It Cm suspend
-Suspend device by waiting for all inflight request to finish, clearing all
-sensitive informations (like keys) from the kernel memory and blocking all
-further I/O requests until the
+Suspend device by waiting for all inflight requests to finish, clearing all
+sensitive information (like the Master Key and Data Keys) from kernel memory,
+and blocking all further I/O requests until the
 .Cm resume
 subcommand is executed.
-This functionality is useful for eg. laptops - when one wants to suspend a
-laptop, one does not want to leave encrypted device attached.
-Instead of closing all files and directories opened from a file system placed
-on an encrypted device, unmounting the file system and detaching the device,
+This functionality is useful for laptops: when one wants to suspend a
+laptop, one does not want to leave an encrypted device attached.
+Instead of closing all files and directories opened from a file system located
+on an encrypted device, unmounting the file system, and detaching the device,
 the
 .Cm suspend
 subcommand can be used.
-Any access to the encrypted device will be blocked until the keys are
-recovered through
+Any access to the encrypted device will be blocked until the Master Key is
+reloaded through the
 .Cm resume
-subcommand, thus there is no need to close nor unmount anything.
+subcommand.
+Thus there is no need to close nor unmount anything.
 The
 .Cm suspend
 subcommand does not work with devices created with the
@@ -549,7 +610,7 @@
 .Cm onetime
 subcommand.
 Please note that sensitive data might still be present in memory after
-suspending encrypted device, because of file system cache, etc.
+suspending an encrypted device due to the file system cache, etc.
 .Pp
 Additional options include:
 .Bl -tag -width ".Fl a"
@@ -560,9 +621,9 @@
 .El
 .It Cm resume
 Resume previously suspended device.
-The caller must ensure that executing this subcommand won't try to access
-suspended device, which will lead to a deadlock.
-For example suspending device, which contains file system where the
+The caller must ensure that executing this subcommand does not access the
+suspended device, leading to a deadlock.
+For example suspending a device which contains the file system where the
 .Nm
 utility is stored is bad idea.
 .Pp
@@ -569,7 +630,8 @@
 Additional options include:
 .Bl -tag -width ".Fl j Ar passfile"
 .It Fl j Ar passfile
-Specifies a file which contains the passphrase or its part.
+Specifies a file which contains the passphrase component of the User Key
+(or part of it).
 For more information see the description of the
 .Fl J
 option for the
@@ -576,7 +638,8 @@
 .Cm init
 subcommand.
 .It Fl k Ar keyfile
-Specifies a file which contains part of the key.
+Specifies a file which contains the keyfile component of the User Key
+(or part of it).
 For more information see the description of the
 .Fl K
 option for the
@@ -583,7 +646,10 @@
 .Cm init
 subcommand.
 .It Fl p
-Do not use passphrase as the key component.
+Do not use a passphrase as a component of the User Key.
+Cannot be combined with the
+.Fl j
+option.
 .El
 .It Cm resize
 Inform
@@ -597,8 +663,23 @@
 .It Fl s Ar oldsize
 The size of the provider before it was resized.
 .El
+.It Cm version
+If no arguments are given, the
+.Cm version
+subcommand will print the version of
+.Nm
+userland utility as well as the version of the
+.Nm ELI
+GEOM class.
+.Pp
+If GEOM providers are specified, the
+.Cm version
+subcommand will print metadata version used by each of them.
 .It Cm clear
 Clear metadata from the given providers.
+.Em WARNING :
+This will erase with zeros the encrypted Master Key copies stored in the
+metadata.
 .It Cm dump
 Dump metadata stored on the given providers.
 .It Cm list
@@ -620,6 +701,36 @@
 .It Fl v
 Be more verbose.
 .El
+.Sh KEY SUMMARY
+.Ss Master Key
+Upon
+.Cm init ,
+the
+.Nm
+utility generates a random Master Key for the provider.
+The Master Key never changes during the lifetime of the provider.
+Each copy of the provider metadata, active or backed up to a file, can store
+up to two, independently-encrypted copies of the Master Key.
+.Ss User Key
+Each stored copy of the Master Key is encrypted with a User Key, which
+is generated by the
+.Nm
+utility from a passphrase and/or a keyfile.
+The
+.Nm
+utility first reads all parts of the keyfile in the order specified on the
+command line, then reads all parts of the stored passphrase in the order
+specified on the command line.
+If no passphrase parts are specified, the system prompts the user to enter
+the passphrase.
+The passphrase is optionally strengthened by PKCS#5v2.
+The User Key is a digest computed over the concatenated keyfile and passphrase.
+.Ss Data Key
+During operation, one or more Data Keys are deterministically derived by
+the kernel from the Master Key and cached in memory.
+The number of Data Keys used by a given provider, and the way they are
+derived, depend on the GELI version and whether the provider is configured to
+use data authentication.
 .Sh SYSCTL VARIABLES
 The following
 .Xr sysctl 8
@@ -644,19 +755,19 @@
 maximum amount of debug information is printed.
 .It Va kern.geom.eli.tries : No 3
 Number of times a user is asked for the passphrase.
-This is only used for providers which should be attached on boot
+This is only used for providers which are attached on boot
 (before the root file system is mounted).
 If set to 0, attaching providers on boot will be disabled.
 This variable should be set in
 .Pa /boot/loader.conf .
 .It Va kern.geom.eli.overwrites : No 5
-Specifies how many times the Master-Key will be overwritten
+Specifies how many times the Master Key will be overwritten
 with random values when it is destroyed.
 After this operation it is filled with zeros.
 .It Va kern.geom.eli.visible_passphrase : No 0
 If set to 1, the passphrase entered on boot (before the root
 file system is mounted) will be visible.
-This possibility should be used with caution as the entered
+This alternative should be used with caution as the entered
 passphrase can be logged and exposed via
 .Xr dmesg 8 .
 This variable should be set in
@@ -665,27 +776,26 @@
 Specifies how many kernel threads should be used for doing software
 cryptography.
 Its purpose is to increase performance on SMP systems.
-If hardware acceleration is available, only one thread will be started.
-If set to 0, CPU-bound thread will be started for every active CPU.
+If set to 0, a CPU-pinned thread will be started for every active CPU.
 .It Va kern.geom.eli.batch : No 0
 When set to 1, can speed-up crypto operations by using batching.
-Batching allows to reduce number of interrupts by responding on a group of
+Batching reduces the number of interrupts by responding to a group of
 crypto requests with one interrupt.
 The crypto card and the driver has to support this feature.
 .It Va kern.geom.eli.key_cache_limit : No 8192
-Specifies how many encryption keys to cache.
+Specifies how many Data Keys to cache.
 The default limit
-.No ( 8192
-keys) will allow to cache all keys for 4TB provider with 512 bytes sectors and
-will take around 1MB of memory.
+(8192 keys) will allow caching of all keys for a 4TB provider with 512 byte
+sectors and will take around 1MB of memory.
 .It Va kern.geom.eli.key_cache_hits
-Reports how many times we were looking up a key and it was already in cache.
-This sysctl is not updated for providers that need less keys than the limit
-specified in
+Reports how many times we were looking up a Data Key and it was already in
+cache.
+This sysctl is not updated for providers that need fewer Data Keys than
+the limit specified in
 .Va kern.geom.eli.key_cache_limit .
 .It Va kern.geom.eli.key_cache_misses
-Reports how many times we were looking up a key and it was not in cache.
-This sysctl is not updated for providers that need less keys than the limit
+Reports how many times we were looking up a Data Key and it was not in cache.
+This sysctl is not updated for providers that need fewer Data Keys than the limit
 specified in
 .Va kern.geom.eli.key_cache_limit .
 .El
@@ -695,7 +805,7 @@
 Initialize a provider which is going to be encrypted with a
 passphrase and random data from a file on the user's pen drive.
 Use 4kB sector size.
-Attach the provider, create a file system and mount it.
+Attach the provider, create a file system, and mount it.
 Do the work.
 Unmount the provider and detach it:
 .Bd -literal -offset indent
@@ -713,30 +823,30 @@
 # geli detach da2.eli
 .Ed
 .Pp
-Create an encrypted provider, but use two keys:
-one for your employee and one for you as company's security officer
-(so there is no tragedy if the employee
+Create an encrypted provider, but use two User Keys:
+one for your employee and one for you as the company's security officer
+(so it is not a tragedy if the employee
 .Qq accidentally
 forgets his passphrase):
 .Bd -literal -offset indent
 # geli init /dev/da2
-Enter new passphrase:	(enter security officer passphrase)
+Enter new passphrase:	(enter security officer's passphrase)
 Reenter new passphrase:
 # geli setkey -n 1 /dev/da2
-Enter passphrase:	(enter security officer passphrase)
+Enter passphrase:	(enter security officer's passphrase)
 Enter new passphrase:	(let your employee enter his passphrase ...)
 Reenter new passphrase:	(... twice)
 .Ed
 .Pp
-You are the security-person in your company.
+You are the security officer in your company.
 Create an encrypted provider for use by the user, but remember that users
-forget their passphrases, so back Master Key up with your own random key:
+forget their passphrases, so backup the Master Key with your own random key:
 .Bd -literal -offset indent
 # dd if=/dev/random of=/mnt/pendrive/keys/`hostname` bs=64 count=1
-# geli init -P -K /mnt/pendrive/keys/`hostname` /dev/ad0s1e
-# geli backup /dev/ad0s1e /mnt/pendrive/backups/`hostname`
-(use key number 0, so the encrypted Master Key by you will be overwritten)
-# geli setkey -n 0 -k /mnt/pendrive/keys/`hostname` /dev/ad0s1e
+# geli init -P -K /mnt/pendrive/keys/`hostname` /dev/ada0s1e
+# geli backup /dev/ada0s1e /mnt/pendrive/backups/`hostname`
+(use key number 0, so the encrypted Master Key will be re-encrypted by this)
+# geli setkey -n 0 -k /mnt/pendrive/keys/`hostname` /dev/ada0s1e
 (allow the user to enter his passphrase)
 Enter new passphrase:
 Reenter new passphrase:
@@ -744,15 +854,15 @@
 .Pp
 Encrypted swap partition setup:
 .Bd -literal -offset indent
-# dd if=/dev/random of=/dev/ad0s1b bs=1m
-# geli onetime -d -e 3des ad0s1b
-# swapon /dev/ad0s1b.eli
+# dd if=/dev/random of=/dev/ada0s1b bs=1m
+# geli onetime -d -e 3des ada0s1b
+# swapon /dev/ada0s1b.eli
 .Ed
 .Pp
 The example below shows how to configure two providers which will be attached
 on boot (before the root file system is mounted).
-One of them is using passphrase and three keyfiles and the other is using only a
-keyfile:
+One of them is using passphrase and three keyfile parts and the other is
+using only a keyfile in one part:
 .Bd -literal -offset indent
 # dd if=/dev/random of=/dev/da0 bs=1m
 # dd if=/dev/random of=/boot/keys/da0.key0 bs=32k count=1
@@ -766,7 +876,7 @@
 # geli init -b -P -K /boot/keys/da1s3a.key da1s3a
 .Ed
 .Pp
-The providers are initialized, now we have to add those lines to
+The providers are initialized, now we have to add these lines to
 .Pa /boot/loader.conf :
 .Bd -literal -offset indent
 geli_da0_keyfile0_load="YES"
@@ -798,10 +908,10 @@
 .Ed
 .Pp
 .Cm geli
-backups metadata by default to the
+writes the metadata backup by default to the
 .Pa /var/backups/<prov>.eli
 file.
-If metadata is lost in any way (eg. by accidental overwrite), it can be restored.
+If the metadata is lost in any way (e.g., by accidental overwrite), it can be restored.
 Consider the following situation:
 .Bd -literal -offset indent
 # geli init /dev/da0
@@ -821,7 +931,7 @@
 Enter passphrase:
 .Ed
 .Pp
-If an encrypted filesystem is extended, it is necessary to relocate and
+If an encrypted file system is extended, it is necessary to relocate and
 update the metadata:
 .Bd -literal -offset indent
 # gpart create -s GPT ada0
@@ -832,10 +942,10 @@
 # geli attach -k keyfile -p ada0p1
 .Ed
 .Pp
-Initialize provider with passphrase split into two files.
-The provider can be attached by giving those two files or by giving
+Initialize provider with the passphrase split into two files.
+The provider can be attached using those two files or by entering
 .Dq foobar
-passphrase on
+as the passphrase at the
 .Nm
 prompt:
 .Bd -literal -offset indent
@@ -850,8 +960,8 @@
 .Pp
 Suspend all
 .Nm
-devices, suspend a laptop, then resume devices one by one after resuming a
-laptop:
+devices on a laptop, suspend the laptop, then resume devices one by one after
+resuming the laptop:
 .Bd -literal -offset indent
 # geli suspend -a
 # zzz
@@ -865,7 +975,7 @@
 supports two encryption modes:
 .Nm XTS ,
 which was standardized as
-.Nm IEE P1619
+.Nm IEEE P1619
 and
 .Nm CBC
 with unpredictable IV.
@@ -891,12 +1001,12 @@
 .Nm
 should be able to detect such a change.
 If an attacker can remember the encrypted data, he can overwrite any future
-changes with the data he owns without notice.
+changes with the data he owns without it being noticed.
 In other words
 .Nm
 will not protect your data against replay attacks.
 .Pp
-It is recommended to write the whole provider before the first use,
+It is recommended to write to the whole provider before first use,
 in order to make sure that all sectors and their corresponding
 checksums are properly initialized into a consistent state.
 One can safely ignore data authentication errors that occur immediately
@@ -915,9 +1025,37 @@
 .Nm
 utility appeared in
 .Fx 6.0 .
-Support for 
+Support for the
 .Nm Camellia
 block cipher is implemented by Yoshisato Yanagisawa in
 .Fx 7.0 .
+.Pp
+Highest
+.Nm GELI
+metadata version supported by the given FreeBSD version:
+.Bl -column -offset indent ".Sy FreeBSD" ".Sy version"
+.It Sy FreeBSD Ta Sy GELI
+.It Sy version Ta Sy version
+.Pp
+.It Li 6.0 Ta 0
+.It Li 6.1 Ta 0
+.It Li 6.2 Ta 3
+.It Li 6.3 Ta 3
+.It Li 6.4 Ta 3
+.Pp
+.It Li 7.0 Ta 3
+.It Li 7.1 Ta 3
+.It Li 7.2 Ta 3
+.It Li 7.3 Ta 3
+.It Li 7.4 Ta 3
+.Pp
+.It Li 8.0 Ta 3
+.It Li 8.1 Ta 3
+.It Li 8.2 Ta 5
+.Pp
+.It Li 9.0 Ta 6
+.Pp
+.It Li 10.0 Ta 7
+.El
 .Sh AUTHORS
-.An Pawel Jakub Dawidek Aq pjd at FreeBSD.org
+.An Pawel Jakub Dawidek Aq Mt pjd at FreeBSD.org


Property changes on: trunk/sbin/geom/class/eli/geli.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/geom/class/eli/geom_eli.c
===================================================================
--- trunk/sbin/geom/class/eli/geom_eli.c	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/eli/geom_eli.c	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004-2010 Pawel Jakub Dawidek <pjd at FreeBSD.org>
  * All rights reserved.
@@ -25,29 +26,29 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/geom/class/eli/geom_eli.c 284752 2015-06-24 12:21:25Z brueffer $");
 
-#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/mman.h>
 #include <sys/sysctl.h>
+#include <sys/resource.h>
+#include <opencrypto/cryptodev.h>
 
+#include <assert.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <libgeom.h>
+#include <paths.h>
+#include <readpassphrase.h>
 #include <stdbool.h>
+#include <stdint.h>
 #include <stdio.h>
-#include <stdint.h>
 #include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <readpassphrase.h>
 #include <string.h>
 #include <strings.h>
-#include <libgeom.h>
-#include <paths.h>
-#include <errno.h>
-#include <assert.h>
+#include <unistd.h>
 
-#include <sys/param.h>
-#include <sys/mman.h>
-#include <sys/resource.h>
-#include <opencrypto/cryptodev.h>
 #include <geom/eli/g_eli.h>
 #include <geom/eli/pkcs5v2.h>
 
@@ -72,6 +73,7 @@
 static void eli_backup(struct gctl_req *req);
 static void eli_restore(struct gctl_req *req);
 static void eli_resize(struct gctl_req *req);
+static void eli_version(struct gctl_req *req);
 static void eli_clear(struct gctl_req *req);
 static void eli_dump(struct gctl_req *req);
 
@@ -81,7 +83,7 @@
 /*
  * Available commands:
  *
- * init [-bhPv] [-a aalgo] [-B backupfile] [-e ealgo] [-i iterations] [-l keylen] [-J newpassfile] [-K newkeyfile] prov
+ * init [-bhPv] [-a aalgo] [-B backupfile] [-e ealgo] [-i iterations] [-l keylen] [-J newpassfile] [-K newkeyfile] [-V version] prov
  * label - alias for 'init'
  * attach [-dprv] [-j passfile] [-k keyfile] prov
  * detach [-fl] prov ...
@@ -96,6 +98,7 @@
  * backup [-v] prov file
  * restore [-fv] file prov
  * resize [-v] -s oldsize prov
+ * version [prov ...]
  * clear [-v] prov ...
  * dump [-v] prov ...
  */
@@ -105,7 +108,7 @@
 		{ 'a', "aalgo", "", G_TYPE_STRING },
 		{ 'b', "boot", NULL, G_TYPE_BOOL },
 		{ 'B', "backupfile", "", G_TYPE_STRING },
-		{ 'e', "ealgo", GELI_ENC_ALGO, G_TYPE_STRING },
+		{ 'e', "ealgo", "", G_TYPE_STRING },
 		{ 'i', "iterations", "-1", G_TYPE_NUMBER },
 		{ 'J', "newpassfile", G_VAL_OPTIONAL, G_TYPE_STRING | G_TYPE_MULTI },
 		{ 'K', "newkeyfile", G_VAL_OPTIONAL, G_TYPE_STRING | G_TYPE_MULTI },
@@ -112,9 +115,10 @@
 		{ 'l', "keylen", "0", G_TYPE_NUMBER },
 		{ 'P', "nonewpassphrase", NULL, G_TYPE_BOOL },
 		{ 's', "sectorsize", "0", G_TYPE_NUMBER },
+		{ 'V', "mdversion", "-1", G_TYPE_NUMBER },
 		G_OPT_SENTINEL
 	    },
-	    "[-bPv] [-a aalgo] [-B backupfile] [-e ealgo] [-i iterations] [-l keylen] [-J newpassfile] [-K newkeyfile] [-s sectorsize] prov"
+	    "[-bPv] [-a aalgo] [-B backupfile] [-e ealgo] [-i iterations] [-l keylen] [-J newpassfile] [-K newkeyfile] [-s sectorsize] [-V version] prov"
 	},
 	{ "label", G_FLAG_VERBOSE, eli_main,
 	    {
@@ -121,7 +125,7 @@
 		{ 'a', "aalgo", "", G_TYPE_STRING },
 		{ 'b', "boot", NULL, G_TYPE_BOOL },
 		{ 'B', "backupfile", "", G_TYPE_STRING },
-		{ 'e', "ealgo", GELI_ENC_ALGO, G_TYPE_STRING },
+		{ 'e', "ealgo", "", G_TYPE_STRING },
 		{ 'i', "iterations", "-1", G_TYPE_NUMBER },
 		{ 'J', "newpassfile", G_VAL_OPTIONAL, G_TYPE_STRING | G_TYPE_MULTI },
 		{ 'K', "newkeyfile", G_VAL_OPTIONAL, G_TYPE_STRING | G_TYPE_MULTI },
@@ -128,6 +132,7 @@
 		{ 'l', "keylen", "0", G_TYPE_NUMBER },
 		{ 'P', "nonewpassphrase", NULL, G_TYPE_BOOL },
 		{ 's', "sectorsize", "0", G_TYPE_NUMBER },
+		{ 'V', "mdversion", "-1", G_TYPE_NUMBER },
 		G_OPT_SENTINEL
 	    },
 	    "- an alias for 'init'"
@@ -241,6 +246,9 @@
 	    },
 	    "[-v] -s oldsize prov"
 	},
+	{ "version", G_FLAG_LOADKLD, eli_main, G_NULL_OPTS,
+	    "[prov ...]"
+	},
 	{ "clear", G_FLAG_VERBOSE, eli_main, G_NULL_OPTS,
 	    "[-v] prov ..."
 	},
@@ -252,6 +260,8 @@
 
 static int verbose = 0;
 
+#define	BUFSIZE	1024
+
 static int
 eli_protect(struct gctl_req *req)
 {
@@ -309,6 +319,8 @@
 		eli_restore(req);
 	else if (strcmp(name, "resize") == 0)
 		eli_resize(req);
+	else if (strcmp(name, "version") == 0)
+		eli_version(req);
 	else if (strcmp(name, "dump") == 0)
 		eli_dump(req);
 	else if (strcmp(name, "clear") == 0)
@@ -317,27 +329,10 @@
 		gctl_error(req, "Unknown command: %s.", name);
 }
 
-static void
-arc4rand(unsigned char *buf, size_t size)
-{
-	uint32_t *buf4;
-	size_t size4;
-	unsigned int i;
-
-	buf4 = (uint32_t *)buf;
-	size4 = size / 4;
-
-	for (i = 0; i < size4; i++)
-		buf4[i] = arc4random();
-	for (i *= 4; i < size; i++)
-		buf[i] = arc4random() % 0xff;
-}
-
-static int
+static bool
 eli_is_attached(const char *prov)
 {
 	char name[MAXPATHLEN];
-	unsigned secsize;
 
 	/*
 	 * Not the best way to do it, but the easiest.
@@ -345,10 +340,7 @@
 	 * by asking about its sectorsize.
 	 */
 	snprintf(name, sizeof(name), "%s%s", prov, G_ELI_SUFFIX);
-	secsize = g_get_sectorsize(name);
-	if (secsize > 0)
-		return (1);
-	return (0);
+	return (g_get_sectorsize(name) > 0);
 }
 
 static int
@@ -355,7 +347,7 @@
 eli_genkey_files(struct gctl_req *req, bool new, const char *type,
     struct hmac_ctx *ctxp, char *passbuf, size_t passbufsize)
 {
-	char *p, buf[MAXPHYS], argname[16];
+	char *p, buf[BUFSIZE], argname[16];
 	const char *file;
 	int error, fd, i;
 	ssize_t done;
@@ -391,6 +383,8 @@
 			while ((done = read(fd, buf, sizeof(buf))) > 0)
 				g_eli_crypto_hmac_update(ctxp, buf, done);
 		} else /* if (strcmp(type, "passfile") == 0) */ {
+			assert(strcmp(type, "passfile") == 0);
+
 			while ((done = read(fd, buf, sizeof(buf) - 1)) > 0) {
 				buf[done] = '\0';
 				p = strchr(buf, '\n');
@@ -430,7 +424,7 @@
 
 	for (;;) {
 		p = readpassphrase(
-		    new ? "Enter new passphrase:" : "Enter passphrase:",
+		    new ? "Enter new passphrase: " : "Enter passphrase: ",
 		    passbuf, passbufsize, RPP_ECHO_OFF | RPP_REQUIRE_TTY);
 		if (p == NULL) {
 			bzero(passbuf, passbufsize);
@@ -440,7 +434,7 @@
 		}
 
 		if (new) {
-			char tmpbuf[BUFSIZ];
+			char tmpbuf[BUFSIZE];
 
 			p = readpassphrase("Reenter new passphrase: ",
 			    tmpbuf, sizeof(tmpbuf),
@@ -469,7 +463,7 @@
 eli_genkey_passphrase(struct gctl_req *req, struct g_eli_metadata *md, bool new,
     struct hmac_ctx *ctxp)
 {
-	char passbuf[MAXPHYS];
+	char passbuf[BUFSIZE];
 	bool nopassphrase;
 	int nfiles;
 
@@ -598,9 +592,24 @@
 			return (-1);
 		}
 	}
-	if (eli_metadata_decode(sector, md) != 0) {
-		gctl_error(req, "MD5 hash mismatch for %s.", prov);
+	error = eli_metadata_decode(sector, md);
+	switch (error) {
+	case 0:
+		break;
+	case EOPNOTSUPP:
+		gctl_error(req,
+		    "Provider's %s metadata version %u is too new.\n"
+		    "geli: The highest supported version is %u.",
+		    prov, (unsigned int)md->md_version, G_ELI_VERSION);
 		return (-1);
+	case EINVAL:
+		gctl_error(req, "Inconsistent provider's %s metadata.", prov);
+		return (-1);
+	default:
+		gctl_error(req,
+		    "Unexpected error while decoding provider's %s metadata: %s.",
+		    prov, strerror(error));
+		return (-1);
 	}
 	return (0);
 }
@@ -654,7 +663,7 @@
 	unsigned char key[G_ELI_USERKEYLEN];
 	char backfile[MAXPATHLEN];
 	const char *str, *prov;
-	unsigned secsize;
+	unsigned int secsize, version;
 	off_t mediasize;
 	intmax_t val;
 	int error, nargs;
@@ -675,7 +684,18 @@
 
 	bzero(&md, sizeof(md));
 	strlcpy(md.md_magic, G_ELI_MAGIC, sizeof(md.md_magic));
-	md.md_version = G_ELI_VERSION;
+	val = gctl_get_intmax(req, "mdversion");
+	if (val == -1) {
+		version = G_ELI_VERSION;
+	} else if (val < 0 || val > G_ELI_VERSION) {
+		gctl_error(req,
+		    "Invalid version specified should be between %u and %u.",
+		    G_ELI_VERSION_00, G_ELI_VERSION);
+		return;
+	} else {
+		version = val;
+	}
+	md.md_version = version;
 	md.md_flags = 0;
 	if (gctl_get_int(req, "boot"))
 		md.md_flags |= G_ELI_FLAG_BOOT;
@@ -682,6 +702,12 @@
 	md.md_ealgo = CRYPTO_ALGORITHM_MIN - 1;
 	str = gctl_get_ascii(req, "aalgo");
 	if (*str != '\0') {
+		if (version < G_ELI_VERSION_01) {
+			gctl_error(req,
+			    "Data authentication is supported starting from version %u.",
+			    G_ELI_VERSION_01);
+			return;
+		}
 		md.md_aalgo = g_eli_str2aalgo(str);
 		if (md.md_aalgo >= CRYPTO_ALGORITHM_MIN &&
 		    md.md_aalgo <= CRYPTO_ALGORITHM_MAX) {
@@ -707,6 +733,12 @@
 	if (md.md_ealgo < CRYPTO_ALGORITHM_MIN ||
 	    md.md_ealgo > CRYPTO_ALGORITHM_MAX) {
 		str = gctl_get_ascii(req, "ealgo");
+		if (*str == '\0') {
+			if (version < G_ELI_VERSION_05)
+				str = "aes-cbc";
+			else
+				str = GELI_ENC_ALGO;
+		}
 		md.md_ealgo = g_eli_str2ealgo(str);
 		if (md.md_ealgo < CRYPTO_ALGORITHM_MIN ||
 		    md.md_ealgo > CRYPTO_ALGORITHM_MAX) {
@@ -713,6 +745,20 @@
 			gctl_error(req, "Invalid encryption algorithm.");
 			return;
 		}
+		if (md.md_ealgo == CRYPTO_CAMELLIA_CBC &&
+		    version < G_ELI_VERSION_04) {
+			gctl_error(req,
+			    "Camellia-CBC algorithm is supported starting from version %u.",
+			    G_ELI_VERSION_04);
+			return;
+		}
+		if (md.md_ealgo == CRYPTO_AES_XTS &&
+		    version < G_ELI_VERSION_05) {
+			gctl_error(req,
+			    "AES-XTS algorithm is supported starting from version %u.",
+			    G_ELI_VERSION_05);
+			return;
+		}
 	}
 	val = gctl_get_intmax(req, "keylen");
 	md.md_keylen = val;
@@ -756,8 +802,8 @@
 	}
 
 	md.md_keys = 0x01;
-	arc4rand(md.md_salt, sizeof(md.md_salt));
-	arc4rand(md.md_mkeys, sizeof(md.md_mkeys));
+	arc4random_buf(md.md_salt, sizeof(md.md_salt));
+	arc4random_buf(md.md_mkeys, sizeof(md.md_mkeys));
 
 	/* Generate user key. */
 	if (eli_genkey(req, &md, key, true) == NULL) {
@@ -1089,7 +1135,7 @@
 
 	all = gctl_get_int(req, "all");
 	if (all)
-		arc4rand(md.md_mkeys, sizeof(md.md_mkeys));
+		arc4random_buf(md.md_mkeys, sizeof(md.md_mkeys));
 	else {
 		force = gctl_get_int(req, "force");
 		val = gctl_get_intmax(req, "keyno");
@@ -1113,7 +1159,7 @@
 			return;
 		}
 		mkeydst = md.md_mkeys + nkey * G_ELI_MKEYLEN;
-		arc4rand(mkeydst, G_ELI_MKEYLEN);
+		arc4random_buf(mkeydst, G_ELI_MKEYLEN);
 	}
 
 	eli_metadata_store(req, prov, &md);
@@ -1205,7 +1251,7 @@
 
 	error = 0;
 	do {
-		arc4rand(sector, size);
+		arc4random_buf(sector, size);
 		if (pwrite(fd, sector, size, offset) != size) {
 			if (error == 0)
 				error = errno;
@@ -1212,6 +1258,7 @@
 		}
 		(void)g_flush(fd);
 	} while (--overwrites > 0);
+	free(sector);
 	if (error != 0) {
 		gctl_error(req, "Cannot trash metadata on provider %s: %s.",
 		    prov, strerror(error));
@@ -1295,66 +1342,53 @@
 static int
 eli_backup_create(struct gctl_req *req, const char *prov, const char *file)
 {
-	struct g_eli_metadata md;
 	unsigned char *sector;
 	ssize_t secsize;
-	off_t mediasize;
-	int filefd, provfd, ret;
+	int error, filefd, ret;
 
 	ret = -1;
-	provfd = filefd = -1;
+	filefd = -1;
 	sector = NULL;
 	secsize = 0;
 
-	provfd = g_open(prov, 0);
-	if (provfd == -1) {
-		gctl_error(req, "Cannot open %s: %s.", prov, strerror(errno));
-		goto out;
-	}
-	filefd = open(file, O_WRONLY | O_TRUNC | O_CREAT, 0600);
-	if (filefd == -1) {
-		gctl_error(req, "Cannot open %s: %s.", file, strerror(errno));
-		goto out;
-	}
-
-	mediasize = g_mediasize(provfd);
-	secsize = g_sectorsize(provfd);
-	if (mediasize == -1 || secsize == -1) {
+	secsize = g_get_sectorsize(prov);
+	if (secsize == 0) {
 		gctl_error(req, "Cannot get informations about %s: %s.", prov,
 		    strerror(errno));
 		goto out;
 	}
-
 	sector = malloc(secsize);
 	if (sector == NULL) {
 		gctl_error(req, "Cannot allocate memory.");
 		goto out;
 	}
-
 	/* Read metadata from the provider. */
-	if (pread(provfd, sector, secsize, mediasize - secsize) != secsize) {
-		gctl_error(req, "Cannot read metadata: %s.", strerror(errno));
+	error = g_metadata_read(prov, sector, secsize, G_ELI_MAGIC);
+	if (error != 0) {
+		gctl_error(req, "Unable to read metadata from %s: %s.", prov,
+		    strerror(error));
 		goto out;
 	}
-	/* Check if this is geli provider. */
-	if (eli_metadata_decode(sector, &md) != 0) {
-		gctl_error(req, "MD5 hash mismatch: not a geli provider?");
+
+	filefd = open(file, O_WRONLY | O_TRUNC | O_CREAT, 0600);
+	if (filefd == -1) {
+		gctl_error(req, "Unable to open %s: %s.", file,
+		    strerror(errno));
 		goto out;
 	}
 	/* Write metadata to the destination file. */
 	if (write(filefd, sector, secsize) != secsize) {
-		gctl_error(req, "Cannot write to %s: %s.", file,
+		gctl_error(req, "Unable to write to %s: %s.", file,
 		    strerror(errno));
+		(void)close(filefd);
+		(void)unlink(file);
 		goto out;
 	}
 	(void)fsync(filefd);
+	(void)close(filefd);
 	/* Success. */
 	ret = 0;
 out:
-	if (provfd >= 0)
-		(void)g_close(provfd);
-	if (filefd >= 0)
-		(void)close(filefd);
 	if (sector != NULL) {
 		bzero(sector, secsize);
 		free(sector);
@@ -1384,10 +1418,8 @@
 {
 	struct g_eli_metadata md;
 	const char *file, *prov;
-	unsigned char *sector;
-	ssize_t secsize;
 	off_t mediasize;
-	int nargs, filefd, provfd;
+	int nargs;
 
 	nargs = gctl_get_int(req, "nargs");
 	if (nargs != 2) {
@@ -1397,72 +1429,28 @@
 	file = gctl_get_ascii(req, "arg0");
 	prov = gctl_get_ascii(req, "arg1");
 
-	provfd = filefd = -1;
-	sector = NULL;
-	secsize = 0;
-
-	filefd = open(file, O_RDONLY);
-	if (filefd == -1) {
-		gctl_error(req, "Cannot open %s: %s.", file, strerror(errno));
-		goto out;
-	}
-	provfd = g_open(prov, 1);
-	if (provfd == -1) {
-		gctl_error(req, "Cannot open %s: %s.", prov, strerror(errno));
-		goto out;
-	}
-
-	mediasize = g_mediasize(provfd);
-	secsize = g_sectorsize(provfd);
-	if (mediasize == -1 || secsize == -1) {
+	/* Read metadata from the backup file. */
+	if (eli_metadata_read(req, file, &md) == -1)
+		return;
+	/* Obtain provider's mediasize. */
+	mediasize = g_get_mediasize(prov);
+	if (mediasize == 0) {
 		gctl_error(req, "Cannot get informations about %s: %s.", prov,
 		    strerror(errno));
-		goto out;
+		return;
 	}
-
-	sector = malloc(secsize);
-	if (sector == NULL) {
-		gctl_error(req, "Cannot allocate memory.");
-		goto out;
-	}
-
-	/* Read metadata from the backup file. */
-	if (read(filefd, sector, secsize) != secsize) {
-		gctl_error(req, "Cannot read from %s: %s.", file,
-		    strerror(errno));
-		goto out;
-	}
-	/* Check if this file contains geli metadata. */
-	if (eli_metadata_decode(sector, &md) != 0) {
-		gctl_error(req, "MD5 hash mismatch: not a geli backup file?");
-		goto out;
-	}
 	/* Check if the provider size has changed since we did the backup. */
 	if (md.md_provsize != (uint64_t)mediasize) {
 		if (gctl_get_int(req, "force")) {
 			md.md_provsize = mediasize;
-			eli_metadata_encode(&md, sector);
 		} else {
 			gctl_error(req, "Provider size mismatch: "
 			    "wrong backup file?");
-			goto out;
+			return;
 		}
 	}
-	/* Write metadata from the provider. */
-	if (pwrite(provfd, sector, secsize, mediasize - secsize) != secsize) {
-		gctl_error(req, "Cannot write metadata: %s.", strerror(errno));
-		goto out;
-	}
-	(void)g_flush(provfd);
-out:
-	if (provfd >= 0)
-		(void)g_close(provfd);
-	if (filefd >= 0)
-		(void)close(filefd);
-	if (sector != NULL) {
-		bzero(sector, secsize);
-		free(sector);
-	}
+	/* Write metadata to the provider. */
+	(void)eli_metadata_store(req, prov, &md);
 }
 
 static void
@@ -1473,7 +1461,7 @@
 	unsigned char *sector;
 	ssize_t secsize;
 	off_t mediasize, oldsize;
-	int nargs, provfd;
+	int error, nargs, provfd;
 
 	nargs = gctl_get_int(req, "nargs");
 	if (nargs != 1) {
@@ -1524,9 +1512,24 @@
 	}
 
 	/* Check if this sector contains geli metadata. */
-	if (eli_metadata_decode(sector, &md) != 0) {
-		gctl_error(req, "MD5 hash mismatch: no metadata for oldsize.");
+	error = eli_metadata_decode(sector, &md);
+	switch (error) {
+	case 0:
+		break;
+	case EOPNOTSUPP:
+		gctl_error(req,
+		    "Provider's %s metadata version %u is too new.\n"
+		    "geli: The highest supported version is %u.",
+		    prov, (unsigned int)md.md_version, G_ELI_VERSION);
 		goto out;
+	case EINVAL:
+		gctl_error(req, "Inconsistent provider's %s metadata.", prov);
+		goto out;
+	default:
+		gctl_error(req,
+		    "Unexpected error while decoding provider's %s metadata: %s.",
+		    prov, strerror(error));
+		goto out;
 	}
 
 	/*
@@ -1543,18 +1546,12 @@
 	 * it back to the correct place on the provider.
 	 */
 	md.md_provsize = mediasize;
-	eli_metadata_encode(&md, sector);
-	if (pwrite(provfd, sector, secsize, mediasize - secsize) != secsize) {
-		gctl_error(req, "Cannot write metadata: %s.", strerror(errno));
-		goto out;
-	}
-	(void)g_flush(provfd);
-
+	/* Write metadata to the provider. */
+	(void)eli_metadata_store(req, prov, &md);
 	/* Now trash the old metadata. */
-	if (eli_trash_metadata(req, prov, provfd, oldsize - secsize) == -1)
-		goto out;
+	(void)eli_trash_metadata(req, prov, provfd, oldsize - secsize);
 out:
-	if (provfd >= 0)
+	if (provfd != -1)
 		(void)g_close(provfd);
 	if (sector != NULL) {
 		bzero(sector, secsize);
@@ -1563,6 +1560,46 @@
 }
 
 static void
+eli_version(struct gctl_req *req)
+{
+	struct g_eli_metadata md;
+	const char *name;
+	unsigned int version;
+	int error, i, nargs;
+
+	nargs = gctl_get_int(req, "nargs");
+
+	if (nargs == 0) {
+		unsigned int kernver;
+		ssize_t size;
+
+		size = sizeof(kernver);
+		if (sysctlbyname("kern.geom.eli.version", &kernver, &size,
+		    NULL, 0) == -1) {
+			warn("Unable to obtain GELI kernel version");
+		} else {
+			printf("kernel: %u\n", kernver);
+		}
+		printf("userland: %u\n", G_ELI_VERSION);
+		return;
+	}
+
+	for (i = 0; i < nargs; i++) {
+		name = gctl_get_ascii(req, "arg%d", i);
+		error = g_metadata_read(name, (unsigned char *)&md,
+		    sizeof(md), G_ELI_MAGIC);
+		if (error != 0) {
+			warn("%s: Unable to read metadata: %s.", name,
+			    strerror(error));
+			gctl_error(req, "Not fully done.");
+			continue;
+		}
+		version = le32dec(&md.md_version);
+		printf("%s: %u\n", name, version);
+	}
+}
+
+static void
 eli_clear(struct gctl_req *req)
 {
 	const char *name;
@@ -1591,9 +1628,9 @@
 static void
 eli_dump(struct gctl_req *req)
 {
-	struct g_eli_metadata md, tmpmd;
+	struct g_eli_metadata md;
 	const char *name;
-	int error, i, nargs;
+	int i, nargs;
 
 	nargs = gctl_get_int(req, "nargs");
 	if (nargs < 1) {
@@ -1603,20 +1640,10 @@
 
 	for (i = 0; i < nargs; i++) {
 		name = gctl_get_ascii(req, "arg%d", i);
-		error = g_metadata_read(name, (unsigned char *)&tmpmd,
-		    sizeof(tmpmd), G_ELI_MAGIC);
-		if (error != 0) {
-			fprintf(stderr, "Cannot read metadata from %s: %s.\n",
-			    name, strerror(error));
+		if (eli_metadata_read(NULL, name, &md) == -1) {
 			gctl_error(req, "Not fully done.");
 			continue;
 		}
-		if (eli_metadata_decode((unsigned char *)&tmpmd, &md) != 0) {
-			fprintf(stderr, "MD5 hash mismatch for %s, skipping.\n",
-			    name);
-			gctl_error(req, "Not fully done.");
-			continue;
-		}
 		printf("Metadata on %s:\n", name);
 		eli_metadata_dump(&md);
 		printf("\n");

Modified: trunk/sbin/geom/class/journal/Makefile
===================================================================
--- trunk/sbin/geom/class/journal/Makefile	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/journal/Makefile	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sbin/geom/class/journal/Makefile 216468 2010-12-15 23:24:34Z obrien $
 
 .PATH: ${.CURDIR}/../../misc
 

Modified: trunk/sbin/geom/class/journal/geom_journal.c
===================================================================
--- trunk/sbin/geom/class/journal/geom_journal.c	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/journal/geom_journal.c	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2006 Pawel Jakub Dawidek <pjd at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/geom/class/journal/geom_journal.c 330737 2018-03-10 04:17:01Z asomers $");
 
 #include <sys/types.h>
 #include <errno.h>
@@ -142,6 +143,7 @@
 	intmax_t jsize, msize, ssize;
 	int error, force, i, nargs, checksum, hardcode;
 
+	bzero(sector, sizeof(sector));
 	nargs = gctl_get_int(req, "nargs");
 	str = NULL;	/* gcc */
 

Modified: trunk/sbin/geom/class/journal/geom_journal.h
===================================================================
--- trunk/sbin/geom/class/journal/geom_journal.h	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/journal/geom_journal.h	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 Pawel Jakub Dawidek <pjd at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sbin/geom/class/journal/geom_journal.h 163838 2006-10-31 21:32:54Z pjd $
  */
 
 #ifndef	_GEOM_JOURNAL_H_

Modified: trunk/sbin/geom/class/journal/geom_journal_ufs.c
===================================================================
--- trunk/sbin/geom/class/journal/geom_journal_ufs.c	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/journal/geom_journal_ufs.c	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 Pawel Jakub Dawidek <pjd at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/geom/class/journal/geom_journal_ufs.c 245074 2013-01-05 21:52:38Z kib $");
 
 #include <sys/param.h>
 #include <sys/disklabel.h>

Modified: trunk/sbin/geom/class/journal/gjournal.8
===================================================================
--- trunk/sbin/geom/class/journal/gjournal.8	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/journal/gjournal.8	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2006-2009 Pawel Jakub Dawidek <pjd at FreeBSD.org>
 .\" All rights reserved.
 .\"
@@ -22,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/geom/class/journal/gjournal.8 307403 2016-10-16 22:02:50Z sevan $
 .\"
 .Dd February 17, 2009
 .Dt GJOURNAL 8
@@ -343,4 +344,4 @@
 utility appeared in
 .Fx 7.0 .
 .Sh AUTHORS
-.An Pawel Jakub Dawidek Aq pjd at FreeBSD.org
+.An Pawel Jakub Dawidek Aq Mt pjd at FreeBSD.org


Property changes on: trunk/sbin/geom/class/journal/gjournal.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/geom/class/label/Makefile
===================================================================
--- trunk/sbin/geom/class/label/Makefile	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/label/Makefile	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sbin/geom/class/label/Makefile 216468 2010-12-15 23:24:34Z obrien $
 
 .PATH: ${.CURDIR}/../../misc
 

Modified: trunk/sbin/geom/class/label/geom_label.c
===================================================================
--- trunk/sbin/geom/class/label/geom_label.c	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/label/geom_label.c	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/geom/class/label/geom_label.c 330737 2018-03-10 04:17:01Z asomers $");
 
 #include <sys/param.h>
 #include <errno.h>
@@ -117,6 +118,7 @@
 	u_char sector[512];
 	int error, nargs;
 
+	bzero(sector, sizeof(sector));
 	nargs = gctl_get_int(req, "nargs");
 	if (nargs != 2) {
 		gctl_error(req, "Invalid number of arguments.");
@@ -137,6 +139,7 @@
 	strlcpy(md.md_magic, G_LABEL_MAGIC, sizeof(md.md_magic));
 	md.md_version = G_LABEL_VERSION;
 	label = gctl_get_ascii(req, "arg0");
+	bzero(md.md_label, sizeof(md.md_label));
 	strlcpy(md.md_label, label, sizeof(md.md_label));
 	md.md_provsize = g_get_mediasize(name);
 	if (md.md_provsize == 0) {

Modified: trunk/sbin/geom/class/label/glabel.8
===================================================================
--- trunk/sbin/geom/class/label/glabel.8	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/label/glabel.8	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd at FreeBSD.org>
 .\" All rights reserved.
 .\"
@@ -22,9 +23,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/geom/class/label/glabel.8 307403 2016-10-16 22:02:50Z sevan $
 .\"
-.Dd June 13, 2009
+.Dd April 22, 2013
 .Dt GLABEL 8
 .Os
 .Sh NAME
@@ -81,7 +82,7 @@
 method uses on-disk metadata to store the label and detect it automatically in
 the future.
 .Pp
-This class also provides volume label detection for file systems.
+This GEOM class also provides volume label detection for file systems.
 Those labels cannot be set with
 .Nm ,
 but must be set with the appropriate file system utility, e.g.\& for UFS
@@ -241,4 +242,4 @@
 utility appeared in
 .Fx 5.3 .
 .Sh AUTHORS
-.An Pawel Jakub Dawidek Aq pjd at FreeBSD.org
+.An Pawel Jakub Dawidek Aq Mt pjd at FreeBSD.org


Property changes on: trunk/sbin/geom/class/label/glabel.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/geom/class/mirror/Makefile
===================================================================
--- trunk/sbin/geom/class/mirror/Makefile	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/mirror/Makefile	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sbin/geom/class/mirror/Makefile 216468 2010-12-15 23:24:34Z obrien $
 
 .PATH: ${.CURDIR}/../../misc
 

Modified: trunk/sbin/geom/class/mirror/geom_mirror.c
===================================================================
--- trunk/sbin/geom/class/mirror/geom_mirror.c	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/mirror/geom_mirror.c	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004-2009 Pawel Jakub Dawidek <pjd at FreeBSD.org>
  * All rights reserved.
@@ -25,9 +26,10 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/geom/class/mirror/geom_mirror.c 330737 2018-03-10 04:17:01Z asomers $");
 
 #include <sys/param.h>
+#include <err.h>
 #include <errno.h>
 #include <paths.h>
 #include <stdio.h>
@@ -53,6 +55,7 @@
 static void mirror_clear(struct gctl_req *req);
 static void mirror_dump(struct gctl_req *req);
 static void mirror_label(struct gctl_req *req);
+static void mirror_resize(struct gctl_req *req, unsigned flags);
 
 struct g_command class_commands[] = {
 	{ "activate", G_FLAG_VERBOSE, mirror_main, G_NULL_OPTS,
@@ -80,6 +83,13 @@
 	{ "deactivate", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
 	    "[-v] name prov ..."
 	},
+	{ "destroy", G_FLAG_VERBOSE, NULL,
+	    {
+		{ 'f', "force", NULL, G_TYPE_BOOL },
+		G_OPT_SENTINEL
+	    },
+	    "[-fv] name ..."
+	},
 	{ "dump", 0, mirror_main, G_NULL_OPTS,
 	    "prov ..."
 	},
@@ -112,6 +122,13 @@
 	{ "remove", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
 	    "[-v] name prov ..."
 	},
+	{ "resize", G_FLAG_VERBOSE, mirror_resize,
+	    {
+		{ 's', "size", "*", G_TYPE_STRING },
+		G_OPT_SENTINEL
+	    },
+	    "[-s size] [-v] name"
+	},
 	{ "stop", G_FLAG_VERBOSE, NULL,
 	    {
 		{ 'f', "force", NULL, G_TYPE_BOOL },
@@ -160,6 +177,7 @@
 	intmax_t val;
 	int error, i, nargs, bal, hardcode;
 
+	bzero(sector, sizeof(sector));
 	nargs = gctl_get_int(req, "nargs");
 	if (nargs < 2) {
 		gctl_error(req, "Too few arguments.");
@@ -376,3 +394,96 @@
 			printf("Provider %s activated.\n", path);
 	}
 }
+
+static struct gclass *
+find_class(struct gmesh *mesh, const char *name)
+{
+	struct gclass *classp;
+
+	LIST_FOREACH(classp, &mesh->lg_class, lg_class) {
+		if (strcmp(classp->lg_name, name) == 0)
+			return (classp);
+	}
+	return (NULL);
+}
+
+static struct ggeom *
+find_geom(struct gclass *classp, const char *name)
+{
+	struct ggeom *gp;
+
+	LIST_FOREACH(gp, &classp->lg_geom, lg_geom) {
+		if (strcmp(gp->lg_name, name) == 0)
+			return (gp);
+	}
+	return (NULL);
+}
+
+static void
+mirror_resize(struct gctl_req *req, unsigned flags __unused)
+{
+	struct gmesh mesh;
+	struct gclass *classp;
+	struct ggeom *gp;
+	struct gprovider *pp;
+	struct gconsumer *cp;
+	off_t size;
+	int error, nargs;
+	const char *name;
+	char ssize[30];
+
+	nargs = gctl_get_int(req, "nargs");
+	if (nargs < 1) {
+		gctl_error(req, "Too few arguments.");
+		return;
+	}
+	error = geom_gettree(&mesh);
+	if (error)
+		errc(EXIT_FAILURE, error, "Cannot get GEOM tree");
+	name = gctl_get_ascii(req, "class");
+	if (name == NULL)
+		abort();
+	classp = find_class(&mesh, name);
+	if (classp == NULL)
+		errx(EXIT_FAILURE, "Class %s not found.", name);
+	name = gctl_get_ascii(req, "arg0");
+	if (name == NULL)
+		abort();
+	gp = find_geom(classp, name);
+	if (gp == NULL)
+		errx(EXIT_FAILURE, "No such geom: %s.", name);
+	pp = LIST_FIRST(&gp->lg_provider);
+	if (pp == NULL)
+		errx(EXIT_FAILURE, "Provider of geom %s not found.", name);
+	size = pp->lg_mediasize;
+	name = gctl_get_ascii(req, "size");
+	if (name == NULL)
+		errx(EXIT_FAILURE, "The size is not specified.");
+	if (*name == '*') {
+#define	CSZ(c)	((c)->lg_provider->lg_mediasize - \
+    (c)->lg_provider->lg_sectorsize)
+		/* Find the maximum possible size */
+		LIST_FOREACH(cp, &gp->lg_consumer, lg_consumer) {
+			if (CSZ(cp) > size)
+				size = CSZ(cp);
+		}
+		LIST_FOREACH(cp, &gp->lg_consumer, lg_consumer) {
+			if (CSZ(cp) < size)
+				size = CSZ(cp);
+		}
+#undef CSZ
+		if (size == pp->lg_mediasize)
+			errx(EXIT_FAILURE,
+			    "Cannot expand provider %s\n",
+			    pp->lg_name);
+	} else {
+		error = g_parse_lba(name, pp->lg_sectorsize, &size);
+		if (error)
+			errc(EXIT_FAILURE, error, "Invalid size param");
+		size *= pp->lg_sectorsize;
+	}
+	snprintf(ssize, sizeof(ssize), "%ju", (uintmax_t)size);
+	gctl_change_param(req, "size", -1, ssize);
+	geom_deletetree(&mesh);
+	gctl_issue(req);
+}

Modified: trunk/sbin/geom/class/mirror/gmirror.8
===================================================================
--- trunk/sbin/geom/class/mirror/gmirror.8	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/mirror/gmirror.8	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2004-2009 Pawel Jakub Dawidek <pjd at FreeBSD.org>
 .\" All rights reserved.
 .\"
@@ -22,9 +23,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/geom/class/mirror/gmirror.8 307403 2016-10-16 22:02:50Z sevan $
 .\"
-.Dd December 8, 2009
+.Dd December 27, 2013
 .Dt GMIRROR 8
 .Os
 .Sh NAME
@@ -60,6 +61,11 @@
 .Ar name
 .Ar prov ...
 .Nm
+.Cm resize
+.Op Fl v
+.Op Fl s Ar size
+.Ar name
+.Nm
 .Cm insert
 .Op Fl hiv
 .Op Fl p Ar priority
@@ -81,6 +87,10 @@
 .Ar name
 .Ar prov ...
 .Nm
+.Cm destroy
+.Op Fl fv
+.Ar name ...
+.Nm
 .Cm forget
 .Op Fl v
 .Ar name ...
@@ -193,6 +203,16 @@
 Rebuild the given mirror components forcibly.
 If autosynchronization was not turned off for the given device, this command
 should be unnecessary.
+.It Cm resize
+Change the size of the given mirror.
+.Pp
+Additional options include:
+.Bl -tag -width ".Fl s Ar size"
+.It Fl s Ar size
+New size of the mirror is expressed in logical block numbers.
+This option can be omitted, then it will be automatically calculated to
+maximum available size.
+.El
 .It Cm insert
 Add the given component(s) to the existing mirror.
 .Pp
@@ -212,6 +232,14 @@
 .It Cm deactivate
 Mark the given component(s) as inactive, so it will not be automatically
 connected to the mirror.
+.It Cm destroy
+Stop the given mirror and clear metadata on all its components.
+.Pp
+Additional options include:
+.Bl -tag -width ".Fl f"
+.It Fl f
+Stop the given mirror even if it is opened.
+.El
 .It Cm forget
 Forget about components which are not connected.
 This command is useful when a disk has failed and cannot be reconnected, preventing the
@@ -340,11 +368,11 @@
 .Xr geom 4 ,
 .Xr dumpon 8 ,
 .Xr geom 8 ,
+.Xr gvinum 8 ,
 .Xr mount 8 ,
 .Xr newfs 8 ,
 .Xr savecore 8 ,
-.Xr umount 8 ,
-.Xr vinum 8
+.Xr umount 8
 .Sh HISTORY
 The
 .Nm
@@ -351,7 +379,7 @@
 utility appeared in
 .Fx 5.3 .
 .Sh AUTHORS
-.An Pawel Jakub Dawidek Aq pjd at FreeBSD.org
+.An Pawel Jakub Dawidek Aq Mt pjd at FreeBSD.org
 .Sh BUGS
 There should be a way to change a component's priority inside a running mirror.
 .Pp


Property changes on: trunk/sbin/geom/class/mirror/gmirror.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/geom/class/mountver/Makefile
===================================================================
--- trunk/sbin/geom/class/mountver/Makefile	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/mountver/Makefile	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sbin/geom/class/mountver/Makefile 216468 2010-12-15 23:24:34Z obrien $
 
 .PATH: ${.CURDIR}/../../misc
 

Modified: trunk/sbin/geom/class/mountver/geom_mountver.c
===================================================================
--- trunk/sbin/geom/class/mountver/geom_mountver.c	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/mountver/geom_mountver.c	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Edward Tomasz Napierala <trasz at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/geom/class/mountver/geom_mountver.c 212554 2010-09-13 13:48:18Z pjd $");
 
 #include <stdio.h>
 #include <stdint.h>

Modified: trunk/sbin/geom/class/mountver/gmountver.8
===================================================================
--- trunk/sbin/geom/class/mountver/gmountver.8	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/mountver/gmountver.8	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\"-
 .\" Copyright (c) 2010 Edward Tomasz Napierala
 .\" All rights reserved.
@@ -23,9 +24,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/geom/class/mountver/gmountver.8 307403 2016-10-16 22:02:50Z sevan $
 .\"
-.Dd January 14, 2010
+.Dd January 27, 2015
 .Dt GMOUNTVER 8
 .Os
 .Sh NAME
@@ -110,7 +111,7 @@
 This can be set to a number between 0 and 3 inclusive.
 If set to 0 minimal debug information is printed, and if set to 3 the
 maximum amount of debug information is printed.
-.It Va kern.geom.mountver.check.check_ident : No 1
+.It Va kern.geom.mountver.check_ident : No 1
 This can be set to 0 or 1.
 If set to 0,
 .Nm
@@ -127,4 +128,4 @@
 utility appeared in
 .Fx 9.0 .
 .Sh AUTHORS
-.An Edward Tomasz Napierala Aq trasz at FreeBSD.org
+.An Edward Tomasz Napierala Aq Mt trasz at FreeBSD.org


Property changes on: trunk/sbin/geom/class/mountver/gmountver.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/geom/class/multipath/Makefile
===================================================================
--- trunk/sbin/geom/class/multipath/Makefile	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/multipath/Makefile	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sbin/geom/class/multipath/Makefile 216468 2010-12-15 23:24:34Z obrien $
 
 .PATH: ${.CURDIR}/../../misc
 

Modified: trunk/sbin/geom/class/multipath/geom_multipath.c
===================================================================
--- trunk/sbin/geom/class/multipath/geom_multipath.c	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/multipath/geom_multipath.c	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 Mathew Jacob <mjacob at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/geom/class/multipath/geom_multipath.c 292395 2015-12-17 06:31:55Z ngie $");
 #include <sys/param.h>
 #include <errno.h>
 #include <paths.h>
@@ -151,7 +152,8 @@
 	uint8_t *sector, *rsector;
 	char *ptr;
 	uuid_t uuid;
-	uint32_t secsize = 0, ssize, status;
+	ssize_t secsize = 0, ssize;
+	uint32_t status;
 	const char *name, *name2, *mpname;
 	int error, i, nargs, fd;
 
@@ -179,8 +181,8 @@
 			disksize = msize;
 		} else {
 			if (secsize != ssize) {
-				gctl_error(req, "%s sector size %u different.",
-				    name, ssize);
+				gctl_error(req, "%s sector size %ju different.",
+				    name, (intmax_t)ssize);
 				return;
 			}
 			if (disksize != msize) {
@@ -220,17 +222,15 @@
 	/*
 	 * Allocate a sector to write as metadata.
 	 */
-	sector = malloc(secsize);
+	sector = calloc(1, secsize);
 	if (sector == NULL) {
 		gctl_error(req, "unable to allocate metadata buffer");
 		return;
 	}
-	memset(sector, 0, secsize);
 	rsector = malloc(secsize);
 	if (rsector == NULL) {
-		free(sector);
 		gctl_error(req, "unable to allocate metadata buffer");
-		return;
+		goto done;
 	}
 
 	/*
@@ -245,7 +245,7 @@
 	error = g_metadata_store(name, sector, secsize);
 	if (error != 0) {
 		gctl_error(req, "cannot store metadata on %s: %s.", name, strerror(error));
-		return;
+		goto done;
 	}
 
 	/*
@@ -273,6 +273,9 @@
 			    name2, name);
 		}
 	}
+done:
+	free(rsector);
+	free(sector);
 }
 
 

Modified: trunk/sbin/geom/class/multipath/gmultipath.8
===================================================================
--- trunk/sbin/geom/class/multipath/gmultipath.8	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/multipath/gmultipath.8	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2007 Matthew Jacob
 .\" All rights reserved.
 .\"
@@ -22,9 +23,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/geom/class/multipath/gmultipath.8 307403 2016-10-16 22:02:50Z sevan $
 .\"
-.Dd April 18, 2012
+.Dd June 11, 2015
 .Dt GMULTIPATH 8
 .Os
 .Sh NAME
@@ -200,7 +201,6 @@
 See
 .Xr geom 8 .
 .El
-.Pp
 .Sh SYSCTL VARIABLES
 The following
 .Xr sysctl 8
@@ -220,7 +220,6 @@
 .Sh EXIT STATUS
 Exit status is 0 on success, and 1 if the command fails.
 .Sh MULTIPATH ARCHITECTURE
-.Pp
 This is a multiple path architecture with no device knowledge or
 presumptions other than size matching built in.
 Therefore the user must exercise some care
@@ -255,13 +254,13 @@
 a generic I/O error or a "Nonexistent Device" error.
 When this occurs, that path is marked FAIL, the next path
 in a list is selected as active and the failed I/O reissued.
-In Active/Active mode all paths not marked FAIL may handle I/O same time.
+In Active/Active mode all paths not marked FAIL may handle I/O at the same time.
 Requests are distributed between paths to equalize load.
-For capable devices it allows to utilize bandwidth of all paths.
-In Active/Read mode all paths not marked FAIL may handle reads same time,
-but unlike Active/Active only one path handles write requests at any
+For capable devices it allows to utilize the bandwidth of all paths.
+In Active/Read mode all paths not marked FAIL may handle reads at the same time,
+but unlike in Active/Active mode only one path handles write requests at any
 point in time.
-It allows to closer follow original write request order if above layer
+It allows to closer follow the original write request order if the layer above
 needs it for data consistency (not waiting for requisite write completion
 before sending dependent write).
 .Pp
@@ -271,9 +270,9 @@
 If a new
 device has a
 .Nm MULTIPATH
-on-disk metadata label, the device is used to either create a new
+on-disk metadata label, the device is either used to create a new
 .Nm MULTIPATH
-GEOM, or been added the list of paths for an existing
+GEOM, or added to the list of paths for an existing
 .Nm MULTIPATH
 GEOM.
 .Pp
@@ -283,7 +282,7 @@
 .Xr mpt 4
 based Fibre Channel disk devices.
 For these devices, when a device disappears
-(due e.g., to a cable pull or power failure to a switch), the device is
+(due to e.g., a cable pull or power failure to a switch), the device is
 proactively marked as gone and I/O to it failed.
 This causes the
 .Nm MULTIPATH
@@ -362,6 +361,6 @@
 .Xr mount 8 ,
 .Xr newfs 8 ,
 .Xr sysctl 8
-.Sh AUTHOR
-.An Matthew Jacob Aq mjacob at FreeBSD.org
-.An Alexander Motin Aq mav at FreeBSD.org
+.Sh AUTHORS
+.An Matthew Jacob Aq Mt mjacob at FreeBSD.org
+.An Alexander Motin Aq Mt mav at FreeBSD.org


Property changes on: trunk/sbin/geom/class/multipath/gmultipath.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/geom/class/nop/Makefile
===================================================================
--- trunk/sbin/geom/class/nop/Makefile	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/nop/Makefile	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sbin/geom/class/nop/Makefile 216468 2010-12-15 23:24:34Z obrien $
 
 .PATH: ${.CURDIR}/../../misc
 

Modified: trunk/sbin/geom/class/nop/geom_nop.c
===================================================================
--- trunk/sbin/geom/class/nop/geom_nop.c	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/nop/geom_nop.c	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004-2006 Pawel Jakub Dawidek <pjd at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/geom/class/nop/geom_nop.c 289520 2015-10-18 15:02:07Z trasz $");
 
 #include <stdio.h>
 #include <stdint.h>
@@ -43,6 +44,8 @@
 	    {
 		{ 'e', "error", "-1", G_TYPE_NUMBER },
 		{ 'o', "offset", "0", G_TYPE_NUMBER },
+		{ 'p', "stripesize", "0", G_TYPE_NUMBER },
+		{ 'P', "stripeoffset", "0", G_TYPE_NUMBER },
 		{ 'r', "rfailprob", "-1", G_TYPE_NUMBER },
 		{ 's', "size", "0", G_TYPE_NUMBER },
 		{ 'S', "secsize", "0", G_TYPE_NUMBER },
@@ -49,8 +52,8 @@
 		{ 'w', "wfailprob", "-1", G_TYPE_NUMBER },
 		G_OPT_SENTINEL
 	    },
-	    "[-v] [-e error] [-o offset] [-r rfailprob] [-s size] "
-	    "[-S secsize] [-w wfailprob] dev ..."
+	    "[-v] [-e error] [-o offset] [-p stripesize] [-P stripeoffset] "
+	    "[-r rfailprob] [-s size] [-S secsize] [-w wfailprob] dev ..."
 	},
 	{ "configure", G_FLAG_VERBOSE, NULL,
 	    {

Modified: trunk/sbin/geom/class/nop/gnop.8
===================================================================
--- trunk/sbin/geom/class/nop/gnop.8	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/nop/gnop.8	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2004-2006 Pawel Jakub Dawidek <pjd at FreeBSD.org>
 .\" All rights reserved.
 .\"
@@ -22,9 +23,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/geom/class/nop/gnop.8 307403 2016-10-16 22:02:50Z sevan $
 .\"
-.Dd September 17, 2009
+.Dd October 10, 2015
 .Dt GNOP 8
 .Os
 .Sh NAME
@@ -36,6 +37,8 @@
 .Op Fl v
 .Op Fl e Ar error
 .Op Fl o Ar offset
+.Op Fl p Ar stripesize
+.Op Fl P Ar stripeoffset
 .Op Fl r Ar rfailprob
 .Op Fl s Ar size
 .Op Fl S Ar secsize
@@ -70,9 +73,10 @@
 utility is used for setting up transparent providers on existing ones.
 Its main purpose is testing other GEOM classes, as it allows forced provider
 removal and I/O error simulation with a given probability.
-It also gathers the following statistics: number of read requests, number of
-write requests, number of bytes read and number of bytes written.
-In addition, it can be used as a good starting point for implementing new GEOM
+It also gathers statistics on the number of read, write, delete,
+getattr, flush, and other requests, and the number of bytes read and written.
+.Nm
+can also be used as a good starting point for implementing new GEOM
 classes.
 .Pp
 The first argument to
@@ -115,6 +119,10 @@
 Force the removal of the specified provider.
 .It Fl o Ar offset
 Where to begin on the original provider.
+.It Fl p Ar stripesize
+Value of the stripesize property of the transparent provider.
+.It Fl P Ar stripeoffset
+Value of the stripeoffset property of the transparent provider.
 .It Fl r Ar rfailprob
 Specifies read failure probability in percent.
 .It Fl s Ar size
@@ -139,8 +147,11 @@
 .Nm NOP
 GEOM class.
 This can be set to a number between 0 and 2 inclusive.
-If set to 0 minimal debug information is printed, and if set to 2 the
-maximum amount of debug information is printed.
+If set to 0, minimal debug information is printed.
+If set to 1, basic debug information is logged along with the I/O requests
+that were returned as errors.
+If set to 2, the maximum amount of debug information is printed including
+all I/O requests.
 .El
 .Sh EXIT STATUS
 Exit status is 0 on success, and 1 if the command fails.
@@ -173,4 +184,4 @@
 utility appeared in
 .Fx 5.3 .
 .Sh AUTHORS
-.An Pawel Jakub Dawidek Aq pjd at FreeBSD.org
+.An Pawel Jakub Dawidek Aq Mt pjd at FreeBSD.org


Property changes on: trunk/sbin/geom/class/nop/gnop.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/geom/class/part/Makefile
===================================================================
--- trunk/sbin/geom/class/part/Makefile	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/part/Makefile	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sbin/geom/class/part/Makefile 216468 2010-12-15 23:24:34Z obrien $
 
 .PATH: ${.CURDIR}/../../misc
 

Modified: trunk/sbin/geom/class/part/geom_part.c
===================================================================
--- trunk/sbin/geom/class/part/geom_part.c	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/part/geom_part.c	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007, 2008 Marcel Moolenaar
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/geom/class/part/geom_part.c 319258 2017-05-30 22:33:24Z asomers $");
 
 #include <sys/stat.h>
 #include <sys/vtoc.h>
@@ -81,7 +82,7 @@
 static int gpart_autofill_resize(struct gctl_req *);
 static void gpart_bootcode(struct gctl_req *, unsigned int);
 static void *gpart_bootfile_read(const char *, ssize_t *);
-static void gpart_issue(struct gctl_req *, unsigned int);
+static _Noreturn void gpart_issue(struct gctl_req *, unsigned int);
 static void gpart_show(struct gctl_req *, unsigned int);
 static void gpart_show_geom(struct ggeom *, const char *, int);
 static int gpart_show_hasopt(struct gctl_req *, const char *, const char *);
@@ -147,10 +148,10 @@
 	},
 	{ "set", 0, gpart_issue, {
 		{ 'a', "attrib", NULL, G_TYPE_STRING },
-		{ 'i', GPART_PARAM_INDEX, NULL, G_TYPE_NUMBER },
+		{ 'i', GPART_PARAM_INDEX, G_VAL_OPTIONAL, G_TYPE_NUMBER },
 		{ 'f', "flags", GPART_FLAGS, G_TYPE_STRING },
 		G_OPT_SENTINEL },
-	    "-a attrib -i index [-f flags] geom"
+	    "-a attrib [-i index] [-f flags] geom"
 	},
 	{ "show", 0, gpart_show, {
 		{ 'l', "show_label", NULL, G_TYPE_BOOL },
@@ -164,10 +165,10 @@
 	},
 	{ "unset", 0, gpart_issue, {
 		{ 'a', "attrib", NULL, G_TYPE_STRING },
-		{ 'i', GPART_PARAM_INDEX, NULL, G_TYPE_NUMBER },
+		{ 'i', GPART_PARAM_INDEX, G_VAL_OPTIONAL, G_TYPE_NUMBER },
 		{ 'f', "flags", GPART_FLAGS, G_TYPE_STRING },
 		G_OPT_SENTINEL },
-	    "-a attrib -i index [-f flags] geom"
+	    "-a attrib [-i index] [-f flags] geom"
 	},
 	{ "resize", 0, gpart_issue, {
 		{ 'a', "alignment", GPART_AUTOFILL, G_TYPE_STRING },
@@ -207,15 +208,20 @@
 static struct ggeom *
 find_geom(struct gclass *classp, const char *name)
 {
-	struct ggeom *gp;
+	struct ggeom *gp, *wgp;
 
 	if (strncmp(name, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
 		name += sizeof(_PATH_DEV) - 1;
+	wgp = NULL;
 	LIST_FOREACH(gp, &classp->lg_geom, lg_geom) {
-		if (strcmp(gp->lg_name, name) == 0)
+		if (strcmp(gp->lg_name, name) != 0)
+			continue;
+		if (find_geomcfg(gp, "wither") == NULL)
 			return (gp);
+		else
+			wgp = gp;
 	}
-	return (NULL);
+	return (wgp);
 }
 
 static const char *
@@ -364,7 +370,11 @@
 	}
 
 	offset = (pp->lg_stripeoffset / pp->lg_sectorsize) % alignment;
-	last = (off_t)strtoimax(find_geomcfg(gp, "last"), NULL, 0);
+	s = find_geomcfg(gp, "last");
+	if (s == NULL)
+		errx(EXIT_FAILURE, "Final block not found for geom %s",
+		    gp->lg_name);
+	last = (off_t)strtoimax(s, NULL, 0);
 	LIST_FOREACH(pp, &gp->lg_provider, lg_provider) {
 		s = find_provcfg(pp, "index");
 		if (s == NULL)
@@ -502,8 +512,16 @@
 	if (size > alignment)
 		size = ALIGNDOWN(size, alignment);
 
-	first = (off_t)strtoimax(find_geomcfg(gp, "first"), NULL, 0);
-	last = (off_t)strtoimax(find_geomcfg(gp, "last"), NULL, 0);
+	s = find_geomcfg(gp, "first");
+	if (s == NULL)
+		errx(EXIT_FAILURE, "Starting block not found for geom %s",
+		    gp->lg_name);
+	first = (off_t)strtoimax(s, NULL, 0);
+	s = find_geomcfg(gp, "last");
+	if (s == NULL)
+		errx(EXIT_FAILURE, "Final block not found for geom %s",
+		    gp->lg_name);
+	last = (off_t)strtoimax(s, NULL, 0);
 	grade = ~0ULL;
 	a_first = ALIGNUP(first + offset, alignment);
 	last = ALIGNDOWN(last + offset, alignment);
@@ -538,7 +556,7 @@
 
 		s = find_provcfg(pp, "end");
 		first = (off_t)strtoimax(s, NULL, 0) + 1;
-		if (first > a_first)
+		if (first + offset > a_first)
 			a_first = ALIGNUP(first + offset, alignment);
 	}
 	if (a_first <= last) {
@@ -586,13 +604,25 @@
 	off_t length, secsz;
 	int idx, wblocks, wname, wmax;
 
+	if (find_geomcfg(gp, "wither"))
+		return;
 	scheme = find_geomcfg(gp, "scheme");
+	if (scheme == NULL)
+		errx(EXIT_FAILURE, "Scheme not found for geom %s", gp->lg_name);
 	s = find_geomcfg(gp, "first");
+	if (s == NULL)
+		errx(EXIT_FAILURE, "Starting block not found for geom %s",
+		    gp->lg_name);
 	first = (off_t)strtoimax(s, NULL, 0);
 	s = find_geomcfg(gp, "last");
+	if (s == NULL)
+		errx(EXIT_FAILURE, "Final block not found for geom %s",
+		    gp->lg_name);
 	last = (off_t)strtoimax(s, NULL, 0);
 	wblocks = strlen(s);
 	s = find_geomcfg(gp, "state");
+	if (s == NULL)
+		errx(EXIT_FAILURE, "State not found for geom %s", gp->lg_name);
 	if (s != NULL && *s != 'C')
 		s = NULL;
 	wmax = strlen(gp->lg_name);
@@ -748,6 +778,8 @@
 		abort();
 	pp = LIST_FIRST(&gp->lg_consumer)->lg_provider;
 	s = find_geomcfg(gp, "last");
+	if (s == NULL)
+		abort();
 	wblocks = strlen(s);
 	wtype = 0;
 	LIST_FOREACH(pp, &gp->lg_provider, lg_provider) {
@@ -757,6 +789,8 @@
 			wtype = i;
 	}
 	s = find_geomcfg(gp, "entries");
+	if (s == NULL)
+		abort();
 	windex = strlen(s);
 	printf("%s %s\n", scheme, s);
 	LIST_FOREACH(pp, &gp->lg_provider, lg_provider) {
@@ -1062,14 +1096,11 @@
 
 	if (pp != NULL) {
 		snprintf(dsf, sizeof(dsf), "/dev/%s", pp->lg_name);
+		if (pp->lg_mediasize < size)
+			errx(EXIT_FAILURE, "%s: not enough space", dsf);
 		fd = open(dsf, O_WRONLY);
 		if (fd == -1)
 			err(EXIT_FAILURE, "%s", dsf);
-		if (lseek(fd, size, SEEK_SET) != size)
-			errx(EXIT_FAILURE, "%s: not enough space", dsf);
-		if (lseek(fd, 0, SEEK_SET) != 0)
-			err(EXIT_FAILURE, "%s", dsf);
-
 		/*
 		 * When writing to a disk device, the write must be
 		 * sector aligned and not write to any partial sectors,
@@ -1085,6 +1116,7 @@
 			err(EXIT_FAILURE, "%s", dsf);
 		free(buf);
 		close(fd);
+		printf("partcode written to %s\n", pp->lg_name);
 	} else
 		errx(EXIT_FAILURE, "invalid partition index");
 }
@@ -1108,11 +1140,11 @@
 		if (pp->lg_sectorsize != sizeof(struct vtoc8))
 			errx(EXIT_FAILURE, "%s: unexpected sector "
 			    "size (%d)\n", dsf, pp->lg_sectorsize);
+		if (pp->lg_mediasize < VTOC_BOOTSIZE)
+			continue;
 		fd = open(dsf, O_WRONLY);
 		if (fd == -1)
 			err(EXIT_FAILURE, "%s", dsf);
-		if (lseek(fd, VTOC_BOOTSIZE, SEEK_SET) != VTOC_BOOTSIZE)
-			continue;
 		/*
 		 * We ignore the first VTOC_BOOTSIZE bytes of boot code in
 		 * order to avoid overwriting the label.
@@ -1131,6 +1163,9 @@
 	}
 	if (installed == 0)
 		errx(EXIT_FAILURE, "%s: no partitions", gp->lg_name);
+	else
+		printf("partcode written to %s\n",
+		    idx != 0 ? pp->lg_name: gp->lg_name);
 }
 
 static void
@@ -1152,10 +1187,8 @@
 		    bootcode);
 		if (error)
 			errc(EXIT_FAILURE, error, "internal error");
-	} else {
+	} else
 		bootcode = NULL;
-		bootsize = 0;
-	}
 
 	s = gctl_get_ascii(req, "class");
 	if (s == NULL)
@@ -1177,21 +1210,25 @@
 	if (gp == NULL)
 		errx(EXIT_FAILURE, "No such geom: %s.", s);
 	s = find_geomcfg(gp, "scheme");
-	vtoc8 = 0;
+	if (s == NULL)
+		errx(EXIT_FAILURE, "Scheme not found for geom %s", gp->lg_name);
 	if (strcmp(s, "VTOC8") == 0)
 		vtoc8 = 1;
+	else
+		vtoc8 = 0;
 
 	if (gctl_has_param(req, GPART_PARAM_PARTCODE)) {
 		s = gctl_get_ascii(req, GPART_PARAM_PARTCODE);
-		partsize = vtoc8 != 0 ? VTOC_BOOTSIZE : bootsize * 1024;
+		if (vtoc8 != 0)
+			partsize = VTOC_BOOTSIZE;
+		else
+			partsize = 1024 * 1024;		/* Arbitrary limit. */
 		partcode = gpart_bootfile_read(s, &partsize);
 		error = gctl_delete_param(req, GPART_PARAM_PARTCODE);
 		if (error)
 			errc(EXIT_FAILURE, error, "internal error");
-	} else {
+	} else
 		partcode = NULL;
-		partsize = 0;
-	}
 
 	if (gctl_has_param(req, GPART_PARAM_INDEX)) {
 		if (partcode == NULL)
@@ -1223,6 +1260,7 @@
 		gpart_issue(req, fl);
 
 	geom_deletetree(&mesh);
+	free(partcode);
 }
 
 static void
@@ -1243,7 +1281,7 @@
 		warnx("%s", errmsg);
 }
 
-static void
+static _Noreturn void
 gpart_issue(struct gctl_req *req, unsigned int fl __unused)
 {
 	char buf[4096];

Modified: trunk/sbin/geom/class/part/gpart.8
===================================================================
--- trunk/sbin/geom/class/part/gpart.8	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/part/gpart.8	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2007, 2008 Marcel Moolenaar
 .\" All rights reserved.
 .\"
@@ -22,9 +23,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD: src/sbin/geom/class/part/gpart.8,v 1.4 2012/11/04 01:55:18 laffer1 Exp $
+.\" $FreeBSD: stable/10/sbin/geom/class/part/gpart.8 315154 2017-03-12 13:42:40Z des $
 .\"
-.Dd January 3, 2013
+.Dd July 25, 2016
 .Dt GPART 8
 .Os
 .Sh NAME
@@ -31,31 +32,6 @@
 .Nm gpart
 .Nd "control utility for the disk partitioning GEOM class"
 .Sh SYNOPSIS
-To add support for the disk partitioning GEOM class,
-place one or more of the following
-lines in the kernel configuration file:
-.Bd -ragged -offset indent
-.Cd "options GEOM_PART_BSD"
-.Cd "options GEOM_PART_GPT"
-.Cd "options GEOM_PART_LDM"
-.Cd "options GEOM_PART_MBR"
-.Cd "options GEOM_PART_EBR"
-.Cd "options GEOM_PART_EBR_COMPAT"
-.Cd "options GEOM_PART_VTOC8"
-.Ed
-.Pp
-These options provide support for the various types of partitioning
-schemes supported by the
-.Ns Nm
-utility.
-See
-.Sx "PARTITIONING SCHEMES"
-below for more details.
-.Pp
-Usage of the
-.Ns Nm
-utility:
-.Pp
 .\" ==== ADD ====
 .Nm
 .Cm add
@@ -154,6 +130,14 @@
 .Op Fl f Ar flags
 .Ar geom
 .\"
+.Nm
+.Cm list
+.Nm
+.Cm status
+.Nm
+.Cm load
+.Nm
+.Cm unload
 .Sh DESCRIPTION
 The
 .Nm
@@ -492,6 +476,18 @@
 below for a discussion
 about its use.
 .El
+.It Cm list
+See
+.Xr geom 8 .
+.It Cm status
+See
+.Xr geom 8 .
+.It Cm load
+See
+.Xr geom 8 .
+.It Cm unload
+See
+.Xr geom 8 .
 .El
 .Sh PARTITIONING SCHEMES
 Several partitioning schemes are supported by the
@@ -516,6 +512,12 @@
 Requires the
 .Cm GEOM_PART_BSD
 kernel option.
+.It Cm BSD64
+64-bit implementation of BSD disklabel used in DragonFlyBSD to subdivide MBR
+or GPT partitions.
+Requires the
+.Cm GEOM_PART_BSD64
+kernel option.
 .It Cm LDM
 The Logical Disk Manager is an implementation of volume manager for
 Microsoft Windows NT.
@@ -569,8 +571,20 @@
 .Nm
 utility also allows the user to specify scheme-specific partition types
 for partition types that do not have symbolic names.
-Symbolic names currently understood are:
-.Bl -tag -width ".Cm ms-ldm-metadata"
+Symbolic names currently understood and used by
+.Fx
+are:
+.Bl -tag -width ".Cm dragonfly-disklabel64"
+.It Cm apple-boot
+The system partition dedicated to storing boot loaders on some Apple
+systems.
+The scheme-specific types are
+.Qq Li "!171"
+for MBR,
+.Qq Li "!Apple_Bootstrap"
+for APM, and
+.Qq Li "!426f6f74-0000-11aa-aa11-00306543ecac"
+for GPT.
 .It Cm bios-boot
 The system partition dedicated to second stage of the boot loader program.
 Usually it is used by the GRUB 2 loader for GPT partitioning schemes.
@@ -581,10 +595,10 @@
 Interface (EFI).
 In such cases, the GPT partitioning scheme is used and the
 actual partition type for the system partition can also be specified as
-.Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93ab" .
+.Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93b" .
 .It Cm freebsd
 A
-.Mx
+.Fx
 partition subdivided into filesystems with a
 .Bx
 disklabel.
@@ -597,14 +611,14 @@
 for APM, and
 .Qq Li "!516e7cb4-6ecf-11d6-8ff8-00022d09712b"
 for GPT.
-.It Cm midnightbsd-boot
+.It Cm freebsd-boot
 A
-.Mx
+.Fx
 partition dedicated to bootstrap code.
 The scheme-specific type is
 .Qq Li "!83bd6b9d-7f41-11dc-be0b-001560b84f0f"
 for GPT.
-.It Cm mnbsd-swap
+.It Cm freebsd-swap
 A
 .Fx
 partition dedicated to swap space.
@@ -613,7 +627,7 @@
 for APM,
 .Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b"
 for GPT, and tag 0x0901 for VTOC8.
-.It Cm midnightbsd-ufs
+.It Cm freebsd-ufs
 A
 .Fx
 partition that contains a UFS or UFS2 filesystem.
@@ -622,7 +636,7 @@
 for APM,
 .Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b"
 for GPT, and tag 0x0902 for VTOC8.
-.It Cm mnbsd-vinum
+.It Cm freebsd-vinum
 A
 .Fx
 partition that contains a Vinum volume.
@@ -631,7 +645,7 @@
 for APM,
 .Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b"
 for GPT, and tag 0x0903 for VTOC8.
-.It Cm mnbsd-zfs
+.It Cm freebsd-zfs
 A
 .Fx
 partition that contains a ZFS volume.
@@ -640,11 +654,163 @@
 for APM,
 .Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b"
 for GPT, and 0x0904 for VTOC8.
+.El
+.Pp
+Another symbolic names that can be used with
+.Cm gpart
+utility are:
+.Bl -tag -width ".Cm dragonfly-disklabel64"
+.It Cm apple-core-storage
+An Apple Mac OS X partition used by logical volume manager known as
+Core Storage.
+The scheme-specific type is
+.Qq Li "!53746f72-6167-11aa-aa11-00306543ecac"
+for GPT.
+.It Cm apple-hfs
+An Apple Mac OS X partition that contains a HFS or HFS+ filesystem.
+The scheme-specific types are
+.Qq Li "!175"
+for MBR,
+.Qq Li "!Apple_HFS"
+for APM and
+.Qq Li "!48465300-0000-11aa-aa11-00306543ecac"
+for GPT.
+.It Cm apple-label
+An Apple Mac OS X partition dedicated to partition metadata that descibes
+disk device.
+The scheme-specific type is
+.Qq Li "!4c616265-6c00-11aa-aa11-00306543ecac"
+for GPT.
+.It Cm apple-raid
+An Apple Mac OS X partition used in a software RAID configuration.
+The scheme-specific type is
+.Qq Li "!52414944-0000-11aa-aa11-00306543ecac"
+for GPT.
+.It Cm apple-raid-offline
+An Apple Mac OS X partition used in a software RAID configuration.
+The scheme-specific type is
+.Qq Li "!52414944-5f4f-11aa-aa11-00306543ecac"
+for GPT.
+.It Cm apple-tv-recovery
+An Apple Mac OS X partition used by Apple TV.
+The scheme-specific type is
+.Qq Li "!5265636f-7665-11aa-aa11-00306543ecac"
+for GPT.
+.It Cm apple-ufs
+An Apple Mac OS X partition that contains a UFS filesystem.
+The scheme-specific types are
+.Qq Li "!168"
+for MBR,
+.Qq Li "!Apple_UNIX_SVR2"
+for APM and
+.Qq Li "!55465300-0000-11aa-aa11-00306543ecac"
+for GPT.
+.It Cm dragonfly-label32
+A DragonFlyBSD partition subdivided into filesystems with a
+.Bx
+disklabel.
+The scheme-specific type is
+.Qq Li "!9d087404-1ca5-11dc-8817-01301bb8a9f5"
+for GPT.
+.It Cm dragonfly-label64
+A DragonFlyBSD partition subdivided into filesystems with a
+disklabel64.
+The scheme-specific type is
+.Qq Li "!3d48ce54-1d16-11dc-8696-01301bb8a9f5"
+for GPT.
+.It Cm dragonfly-legacy
+A legacy partition type used in DragonFlyBSD.
+The scheme-specific type is
+.Qq Li "!bd215ab2-1d16-11dc-8696-01301bb8a9f5"
+for GPT.
+.It Cm dragonfly-ccd
+A DragonFlyBSD partition used with Concatenated Disk driver.
+The scheme-specific type is
+.Qq Li "!dbd5211b-1ca5-11dc-8817-01301bb8a9f5"
+for GPT.
+.It Cm dragonfly-hammer
+A DragonFlyBSD partition that contains a Hammer filesystem.
+The scheme-specific type is
+.Qq Li "!61dc63ac-6e38-11dc-8513-01301bb8a9f5"
+for GPT.
+.It Cm dragonfly-hammer2
+A DragonFlyBSD partition that contains a Hammer2 filesystem.
+The scheme-specific type is
+.Qq Li "!5cbb9ad1-862d-11dc-a94d-01301bb8a9f5"
+for GPT.
+.It Cm dragonfly-swap
+A DragonFlyBSD partition dedicated to swap space.
+The scheme-specific type is
+.Qq Li "!9d58fdbd-1ca5-11dc-8817-01301bb8a9f5"
+for GPT.
+.It Cm dragonfly-ufs
+A DragonFlyBSD partition that contains an UFS1 filesystem.
+The scheme-specific type is
+.Qq Li "!9d94ce7c-1ca5-11dc-8817-01301bb8a9f5"
+for GPT.
+.It Cm dragonfly-vinum
+A DragonFlyBSD partition used with Logical Volume Manager.
+The scheme-specific type is
+.Qq Li "!9dd4478f-1ca5-11dc-8817-01301bb8a9f5"
+for GPT.
+.It Cm ebr
+A partition subdivided into filesystems with a EBR.
+The scheme-specific type is
+.Qq Li "!5"
+for MBR.
+.It Cm fat16
+A partition that contains a FAT16 filesystem.
+The scheme-specific type is
+.Qq Li "!6"
+for MBR.
+.It Cm fat32
+A partition that contains a FAT32 filesystem.
+The scheme-specific type is
+.Qq Li "!11"
+for MBR.
+.It Cm linux-data
+A Linux partition that contains some filesystem with data.
+The scheme-specific types are
+.Qq Li "!131"
+for MBR and
+.Qq Li "!0fc63daf-8483-4772-8e79-3d69d8477de4"
+for GPT.
+.It Cm linux-lvm
+A Linux partition dedicated to Logical Volume Manager.
+The scheme-specific types are
+.Qq Li "!142"
+for MBR and
+.Qq Li "!e6d6d379-f507-44c2-a23c-238f2a3df928"
+for GPT.
+.It Cm linux-raid
+A Linux partition used in a software RAID configuration.
+The scheme-specific types are
+.Qq Li "!253"
+for MBR and
+.Qq Li "!a19d880f-05fc-4d3b-a006-743f0f84911e"
+for GPT.
+.It Cm linux-swap
+A Linux partition dedicated to swap space.
+The scheme-specific types are
+.Qq Li "!130"
+for MBR and
+.Qq Li "!0657fd6d-a4ab-43c4-84e5-0933c84b4f4f"
+for GPT.
 .It Cm mbr
 A partition that is sub-partitioned by a Master Boot Record (MBR).
 This type is known as
 .Qq Li "!024dee41-33e7-11d3-9d69-0008c781f39f"
 by GPT.
+.It Cm ms-basic-data
+A basic data partition (BDP) for Microsoft operating systems.
+In the GPT this type is the equivalent to partition types
+.Cm fat16 , fat32
+and
+.Cm ntfs
+in MBR.
+The scheme-specific type is
+.Qq Li "!ebd0a0a2-b9e5-4433-87c0-68b6b72699c7"
+for GPT.
 .It Cm ms-ldm-data
 A partition that contains Logical Disk Manager (LDM) volumes.
 The scheme-specific types are
@@ -657,6 +823,73 @@
 The scheme-specific type is
 .Qq Li "!5808c8aa-7e8f-42e0-85d2-e1e90434cfb3"
 for GPT.
+.It Cm netbsd-ccd
+A NetBSD partition used with Concatenated Disk driver.
+The scheme-specific type is
+.Qq Li "!2db519c4-b10f-11dc-b99b-0019d1879648"
+for GPT.
+.It Cm netbsd-cgd
+An encrypted NetBSD partition.
+The scheme-specific type is
+.Qq Li "!2db519ec-b10f-11dc-b99b-0019d1879648"
+for GPT.
+.It Cm netbsd-ffs
+A NetBSD partition that contains an UFS filesystem.
+The scheme-specific type is
+.Qq Li "!49f48d5a-b10e-11dc-b99b-0019d1879648"
+for GPT.
+.It Cm netbsd-lfs
+A NetBSD partition that contains an LFS filesystem.
+The scheme-specific type is
+.Qq Li "!49f48d82-b10e-11dc-b99b-0019d1879648"
+for GPT.
+.It Cm netbsd-raid
+A NetBSD partition used in a software RAID configuration.
+The scheme-specific type is
+.Qq Li "!49f48daa-b10e-11dc-b99b-0019d1879648"
+for GPT.
+.It Cm netbsd-swap
+A NetBSD partition dedicated to swap space.
+The scheme-specific type is
+.Qq Li "!49f48d32-b10e-11dc-b99b-0019d1879648"
+for GPT.
+.It Cm ntfs
+A partition that contains a NTFS or exFAT filesystem.
+The scheme-specific type is
+.Qq Li "!7"
+for MBR.
+.It Cm prep-boot
+The system partition dedicated to storing boot loaders on some PowerPC systems,
+notably those made by IBM.
+The scheme-specific types are
+.Qq Li "!65"
+for MBR and
+.Qq Li "!0x9e1a2d38-c612-4316-aa26-8b49521e5a8b"
+for GPT.
+.It Cm vmware-vmfs
+A partition that contains a VMware File System (VMFS).
+The scheme-specific types are
+.Qq Li "!251"
+for MBR and
+.Qq Li "!aa31e02a-400f-11db-9590-000c2911d1b8"
+for GPT.
+.It Cm vmware-vmkdiag
+A partition that contains a VMware diagostic filesystem.
+The scheme-specific types are
+.Qq Li "!252"
+for MBR and
+.Qq Li "!9d275380-40ad-11db-bf97-000c2911d1b8"
+for GPT.
+.It Cm vmware-reserved
+A VMware reserved partition.
+The scheme-specific type is
+.Qq Li "!9198effc-31c0-11db-8f-78-000c2911d1b8"
+for GPT.
+.It Cm vmware-vsanhdr
+A partition claimed by VMware VSAN.
+The scheme-specific type is
+.Qq Li "!381cfccc-7288-11e0-92ee-000c2911d0b2"
+for GPT.
 .El
 .Sh ATTRIBUTES
 The scheme-specific attributes for EBR:
@@ -670,14 +903,12 @@
 When set, the
 .Nm gptboot
 stage 1 boot loader will try to boot the system from this partition.
-Multiple partitions might be marked with the
+Multiple partitions can be marked with the
 .Cm bootme
 attribute.
-In such scenario the
-.Nm gptboot
-will try all
-.Cm bootme
-partitions one by one, until the next boot stage is successfully entered.
+See
+.Xr gptboot 8
+for more details.
 .It Cm bootonce
 Setting this attribute automatically sets the
 .Cm bootme
@@ -685,49 +916,14 @@
 When set, the
 .Nm gptboot
 stage 1 boot loader will try to boot the system from this partition only once.
-Partitions with both
+Multiple partitions can be marked with the
 .Cm bootonce
 and
 .Cm bootme
-attributes are tried before partitions with only the
-.Cm bootme
-attribute.
-Before
-.Cm bootonce
-partition is tried, the
-.Nm gptboot
-removes the
-.Cm bootme
-attribute and tries to execute the next boot stage.
-If it fails, the
-.Cm bootonce
-attribute that is now alone is replaced with the
-.Cm bootfailed
-attribute.
-If the execution of the next boot stage succeeds, but the system is not fully
-booted, the
-.Nm gptboot
-will look for
-.Cm bootonce
-attributes alone (without the
-.Cm bootme
-attribute) on the next system boot and will replace those with the
-.Cm bootfailed
-attribute.
-If the system is fully booted, the
-.Pa /etc/rc.d/gptboot
-start-up script will look for partition with the
-.Cm bootonce
-attribute alone, will remove the attribute and log that the system was
-successfully booted from this partition.
-There should be at most one
-.Cm bootonce
-partition when system is successfully booted.
-Multiple partitions might be marked with the
-.Cm bootonce
-and
-.Cm bootme
 attribute pairs.
+See
+.Xr gptboot 8
+for more details.
 .It Cm bootfailed
 This attribute should not be manually managed.
 It is managed by the
@@ -735,14 +931,15 @@
 stage 1 boot loader and the
 .Pa /etc/rc.d/gptboot
 start-up script.
-This attribute is used to mark partitions that had the
-.Cm bootonce
-attribute set, but we failed to boot from them.
-Once we successfully boot, the
-.Pa /etc/rc.d/gptboot
-script will log all the partitions we failed to boot from and will remove the
-.Cm bootfailed
-attributes.
+See
+.Xr gptboot 8
+for more details.
+.It Cm lenovofix
+Setting this attribute overwrites the Protective MBR with a new one where
+the 0xee partition is the second, rather than the first record.
+This resolves a BIOS compatibility issue with some Lenovo models including the
+X220, T420, and T520, allowing them to boot from GPT partitioned disks
+without using EFI.
 .El
 .Pp
 The scheme-specific attributes for MBR:
@@ -805,34 +1002,52 @@
 First, a protective MBR is embedded into the first disk sector from the
 .Pa /boot/pmbr
 image.
-It searches the GPT
-.Cm mnbsd-boot
+It searches through the GPT for a
+.Cm freebsd-boot
 partition (see the
 .Sx "PARTITION TYPES"
-section) in the GPT and runs the next bootstrap stage from it.
+section) and runs the next bootstrap stage from it.
 The
-.Cm mnbsd-boot
+.Cm freebsd-boot
 partition should be smaller than 545 KB.
+It can be located either before or after other
+.Fx
+partitions on the disk.
 There are two variants of bootstrap code to write to this partition:
 .Pa /boot/gptboot
 and
 .Pa /boot/gptzfsboot .
+.Pp
 .Pa /boot/gptboot
-is used to boot from UFS.
-It searches
-.Cm mnbsd-ufs
-GPT partitions and starts
+is used to boot from UFS partitions.
+.Cm gptboot
+searches through
+.Cm freebsd-ufs
+partitions in the GPT and selects one to boot based on the
+.Cm bootonce
+and
+.Cm bootme
+attributes.
+If neither attribute is found,
+.Pa /boot/gptboot
+boots from the first
+.Cm freebsd-ufs
+partition.
 .Pa /boot/loader
 .Pq the third bootstrap stage
-if found.
-The
+is loaded from the first partition that matches these conditions.
+See
+.Xr gptboot 8
+for more information.
+.Pp
 .Pa /boot/gptzfsboot
 is used to boot from ZFS.
-It searches
-.Cm mnbsd-zfs
-GPT partitions and starts
+It searches through the GPT for
+.Cm freebsd-zfs
+partitions, trying to detect ZFS pools.
+After all pools are detected,
 .Pa /boot/zfsloader
-if found.
+is started from the first one found.
 .Pp
 The VTOC8 scheme does not support embedding bootstrap code.
 Instead, the 8 KBytes bootstrap code image
@@ -852,7 +1067,7 @@
 should be written with the
 .Cm gpart bootcode
 command to a partition of type
-.Cm mnbsd-boot ,
+.Cm apple-boot ,
 which should also be 800 KB in size.
 .Sh OPERATIONAL FLAGS
 Actions other than the
@@ -893,15 +1108,6 @@
 .Cm recover
 are the only operations allowed on corrupt tables.
 .Pp
-If the first sector of a provider is corrupt, the kernel can not detect GPT
-even if the partition table itself is not corrupt.
-The protective MBR can be rewritten using the
-.Xr dd 1
-command, to restore the ability to detect the GPT.
-The copy of the protective MBR is usually located in the
-.Pa /boot/pmbr
-file.
-.Pp
 If one GPT header appears to be corrupt but the other copy remains intact,
 the kernel will log the following:
 .Bd -literal -offset indent
@@ -943,7 +1149,7 @@
 different GEOM providers, and some of them will be marked as corrupt.
 Be careful when choosing a provider for recovery.
 If you choose incorrectly you can destroy the metadata of another GEOM class,
-e.g.\& GEOM MIRROR or GEOM LABEL.
+e.g.,\& GEOM MIRROR or GEOM LABEL.
 .Sh SYSCTL VARIABLES
 The following
 .Xr sysctl 8
@@ -978,90 +1184,122 @@
 present as independent partition.
 .Em NOTE :
 This may break a mirrored volume and lead to data damage.
+.It Va kern.geom.part.mbr.enforce_chs : No 1
+Specify how the Master Boot Record (MBR) module does alignment.
+If this variable is set to a non-zero value, the module will automatically
+recalculate the user-specified offset and size for alignment with the CHS
+geometry.
+Otherwise the values will be left unchanged.
 .El
 .Sh EXIT STATUS
 Exit status is 0 on success, and 1 if the command fails.
 .Sh EXAMPLES
-Create a GPT scheme on
-.Pa ada0 :
+The examples below assume that the disk's logical block size is 512
+bytes, regardless of its physical block size.
+.Ss GPT
+In this example, we will format
+.Pa ada0
+with the GPT scheme and create boot, swap and root partitions.
+First, we need to create the partition table:
 .Bd -literal -offset indent
 /sbin/gpart create -s GPT ada0
 .Ed
 .Pp
-Embed GPT bootstrap code into a protective MBR:
+Next, we install a protective MBR with the first-stage bootstrap code.
+The protective MBR lists a single, bootable partition spanning the
+entire disk, thus allowing non-GPT-aware BIOSes to boot from the disk
+and preventing tools which do not understand the GPT scheme from
+considering the disk to be unformatted.
 .Bd -literal -offset indent
 /sbin/gpart bootcode -b /boot/pmbr ada0
 .Ed
 .Pp
-Create a dedicated
-.Cm mnbsd-boot
-partition that can boot
+We then create a dedicated
+.Cm freebsd-boot
+partition to hold the second-stage boot loader, which will load the
 .Fx
-from a
-.Cm mnbsd-ufs
-partition, and install bootstrap code into it.
+kernel and modules from a UFS or ZFS filesystem.
 This partition must be larger than the bootstrap code
 .Po
-usually either
+either
 .Pa /boot/gptboot
-or
+for UFS or
 .Pa /boot/gptzfsboot
+for ZFS
 .Pc ,
 but smaller than 545 kB since the first-stage loader will load the
 entire partition into memory during boot, regardless of how much data
 it actually contains.
-This example uses 88 blocks (44 kB) so the next partition will be
-aligned on a 64 kB boundary without the need to specify an explicit
-offset or alignment.
-The boot partition itself is aligned on a 4 kB boundary.
+We create a 472-block (236 kB) boot partition at offset 40, which is
+the size of the partition table (34 blocks or 17 kB) rounded up to the
+nearest 4 kB boundary.
 .Bd -literal -offset indent
-/sbin/gpart add -b 40 -s 88 -t midnightbsd-boot ada0
+/sbin/gpart add -b 40 -s 472 -t freebsd-boot ada0
 /sbin/gpart bootcode -p /boot/gptboot -i 1 ada0
 .Ed
 .Pp
-Create a 512MB-sized
-.Cm mnbsd-ufs
-partition to contain a UFS filesystem from which the system can boot.
+We now create a 4 GB swap partition at the first available offset,
+which is 40 + 472 = 512 blocks (256 kB).
 .Bd -literal -offset indent
-/sbin/gpart add -s 512M -t mnbsd-ufs ada0
+/sbin/gpart add -s 4G -t freebsd-swap ada0
 .Ed
 .Pp
-Create an MBR scheme on
-.Pa ada0 ,
-then create a 30GB-sized
-.Fx
-slice, mark it active and
-install the
-.Nm boot0
-boot manager:
+Aligning the swap partition and all subsequent partitions on a 256 kB
+boundary ensures optimal performance on a wide range of media, from
+plain old disks with 512-byte blocks, through modern
+.Dq advanced format
+disks with 4096-byte physical blocks, to RAID volumes with stripe
+sizes of up to 256 kB.
+.Pp
+Finally, we create and format an 8 GB
+.Cm freebsd-ufs
+partition for the root filesystem, leaving the rest of the slice free
+for additional filesystems:
 .Bd -literal -offset indent
+/sbin/gpart add -s 8G -t freebsd-ufs ada0
+/sbin/newfs -Uj /dev/ada0p3
+.Ed
+.Ss MBR
+In this example, we will format
+.Pa ada0
+with the MBR scheme and create a single partition which we subdivide
+using a traditional
+.Bx
+disklabel.
+.Pp
+First, we create the partition table and a single 64 GB partition,
+then we mark that partition active (bootable) and install the
+first-stage boot loader:
+.Bd -literal -offset indent
 /sbin/gpart create -s MBR ada0
-/sbin/gpart add -t freebsd -s 30G ada0
+/sbin/gpart add -t freebsd -s 64G ada0
 /sbin/gpart set -a active -i 1 ada0
 /sbin/gpart bootcode -b /boot/boot0 ada0
 .Ed
 .Pp
-Now create a
-.Bx
-scheme
-.Pf ( Bx
-label) with space for up to 20 partitions:
+Next, we create a disklabel in that partition
+.Po
+.Dq slice
+in disklabel terminology
+.Pc
+with room for up to 20 partitions:
 .Bd -literal -offset indent
 /sbin/gpart create -s BSD -n 20 ada0s1
 .Ed
 .Pp
-Create a 1GB-sized UFS partition and a 4GB-sized swap partition:
+We then create an 8 GB root partition and a 4 GB swap partition:
 .Bd -literal -offset indent
-/sbin/gpart add -t mnbsd-ufs -s 1G ada0s1
-/sbin/gpart add -t mnbsd-swap -s 4G ada0s1
+/sbin/gpart add -t freebsd-ufs -s 8G ada0s1
+/sbin/gpart add -t freebsd-swap -s 4G ada0s1
 .Ed
 .Pp
-Install bootstrap code for the
+Finally, we install the appropriate boot loader for the
 .Bx
 label:
 .Bd -literal -offset indent
 /sbin/gpart bootcode -b /boot/boot ada0s1
 .Ed
+.Ss VTOC8
 .Pp
 Create a VTOC8 scheme on
 .Pa da0 :
@@ -1070,17 +1308,17 @@
 .Ed
 .Pp
 Create a 512MB-sized
-.Cm mnbsd-ufs
+.Cm freebsd-ufs
 partition to contain a UFS filesystem from which the system can boot.
 .Bd -literal -offset indent
-/sbin/gpart add -s 512M -t mnbsd-ufs da0
+/sbin/gpart add -s 512M -t freebsd-ufs da0
 .Ed
 .Pp
 Create a 15GB-sized
-.Cm mnbsd-ufs
+.Cm freebsd-ufs
 partition to contain a UFS filesystem and aligned on 4KB boundaries:
 .Bd -literal -offset indent
-/sbin/gpart add -s 15G -t mnbsd-ufs -a 4k da0
+/sbin/gpart add -s 15G -t freebsd-ufs -a 4k da0
 .Ed
 .Pp
 After creating all required partitions, embed bootstrap code into them:
@@ -1087,6 +1325,7 @@
 .Bd -literal -offset indent
 /sbin/gpart bootcode -p /boot/boot1 da0
 .Ed
+.Ss Backup and Restore
 .Pp
 Create a backup of the partition table from
 .Pa da0 :
@@ -1110,10 +1349,10 @@
 /sbin/gpart backup ada0 | /sbin/gpart restore -F ada1 ada2
 .Ed
 .Sh SEE ALSO
-.Xr dd 1 ,
 .Xr geom 4 ,
 .Xr boot0cfg 8 ,
-.Xr geom 8
+.Xr geom 8 ,
+.Xr gptboot 8
 .Sh HISTORY
 The
 .Nm
@@ -1120,4 +1359,4 @@
 utility appeared in
 .Fx 7.0 .
 .Sh AUTHORS
-.An Marcel Moolenaar Aq marcel at FreeBSD.org
+.An Marcel Moolenaar Aq Mt marcel at FreeBSD.org


Property changes on: trunk/sbin/geom/class/part/gpart.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/geom/class/raid3/Makefile
===================================================================
--- trunk/sbin/geom/class/raid3/Makefile	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/raid3/Makefile	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sbin/geom/class/raid3/Makefile 216468 2010-12-15 23:24:34Z obrien $
 
 .PATH:	${.CURDIR}/../../misc
 

Modified: trunk/sbin/geom/class/raid3/geom_raid3.c
===================================================================
--- trunk/sbin/geom/class/raid3/geom_raid3.c	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/raid3/geom_raid3.c	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/geom/class/raid3/geom_raid3.c 330737 2018-03-10 04:17:01Z asomers $");
 
 #include <sys/param.h>
 #include <errno.h>
@@ -149,6 +150,7 @@
 	int hardcode, round_robin, verify;
 	int error, i, nargs;
 
+	bzero(sector, sizeof(sector));
 	nargs = gctl_get_int(req, "nargs");
 	if (nargs < 4) {
 		gctl_error(req, "Too few arguments.");

Modified: trunk/sbin/geom/class/raid3/graid3.8
===================================================================
--- trunk/sbin/geom/class/raid3/graid3.8	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/raid3/graid3.8	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd at FreeBSD.org>
 .\" All rights reserved.
 .\"
@@ -22,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/geom/class/raid3/graid3.8 307403 2016-10-16 22:02:50Z sevan $
 .\"
 .Dd January 15, 2012
 .Dt GRAID3 8
@@ -248,7 +249,7 @@
 utility appeared in
 .Fx 5.3 .
 .Sh AUTHORS
-.An Pawel Jakub Dawidek Aq pjd at FreeBSD.org
+.An Pawel Jakub Dawidek Aq Mt pjd at FreeBSD.org
 .Sh BUGS
 There should be a section with an implementation description.
 .Pp


Property changes on: trunk/sbin/geom/class/raid3/graid3.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/geom/class/sched/Makefile
===================================================================
--- trunk/sbin/geom/class/sched/Makefile	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/sched/Makefile	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,5 +1,6 @@
+# $MidnightBSD$
 # GEOM_LIBRARY_PATH
-# $MidnightBSD$
+# $FreeBSD: stable/10/sbin/geom/class/sched/Makefile 222772 2011-06-06 20:24:17Z ed $
 
 .PATH: ${.CURDIR}/../../misc
 

Modified: trunk/sbin/geom/class/sched/geom_sched.c
===================================================================
--- trunk/sbin/geom/class/sched/geom_sched.c	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/sched/geom_sched.c	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2009 Fabio Checconi
  * Copyright (c) 2010 Luigi Rizzo, Universita` di Pisa
@@ -26,8 +27,8 @@
  */
 
 /*
- * $Id: geom_sched.c,v 1.1 2012-11-04 01:55:18 laffer1 Exp $
- * $MidnightBSD$
+ * $Id$
+ * $FreeBSD: stable/10/sbin/geom/class/sched/geom_sched.c 212554 2010-09-13 13:48:18Z pjd $
  *
  * This file implements the userspace library used by the 'geom'
  * command to load and manipulate disk schedulers.

Modified: trunk/sbin/geom/class/sched/gsched.8
===================================================================
--- trunk/sbin/geom/class/sched/gsched.8	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/sched/gsched.8	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2009-2010 Fabio Checconi
 .\" Copyright (c) 2009-2010 Luigi Rizzo, Universita` di Pisa
 .\" All rights reserved.
@@ -23,9 +24,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/geom/class/sched/gsched.8 307403 2016-10-16 22:02:50Z sevan $
 .\"
-.Dd July 26, 2012 
+.Dd July 26, 2012
 .Dt GSCHED 8
 .Os
 .Sh NAME
@@ -149,7 +150,6 @@
 # Remove the scheduler on the device:
 geom sched destroy -v ada0.sched.
 .Ed
-.Pp
 .Sh SEE ALSO
 .Xr geom 4 ,
 .Xr geom 8
@@ -159,5 +159,5 @@
 utility first appeared in
 .Fx 8.1 .
 .Sh AUTHORS
-.An Fabio Checconi Aq fabio at FreeBSD.org
-.An Luigi Rizzo Aq luigi at FreeBSD.org
+.An Fabio Checconi Aq Mt fabio at FreeBSD.org
+.An Luigi Rizzo Aq Mt luigi at FreeBSD.org


Property changes on: trunk/sbin/geom/class/sched/gsched.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/geom/class/shsec/Makefile
===================================================================
--- trunk/sbin/geom/class/shsec/Makefile	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/shsec/Makefile	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sbin/geom/class/shsec/Makefile 216468 2010-12-15 23:24:34Z obrien $
 
 .PATH: ${.CURDIR}/../../misc
 

Modified: trunk/sbin/geom/class/shsec/geom_shsec.c
===================================================================
--- trunk/sbin/geom/class/shsec/geom_shsec.c	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/shsec/geom_shsec.c	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/geom/class/shsec/geom_shsec.c 330737 2018-03-10 04:17:01Z asomers $");
 
 #include <sys/param.h>
 #include <errno.h>
@@ -110,6 +111,7 @@
 	const char *name;
 	int error, i, nargs, hardcode;
 
+	bzero(sector, sizeof(sector));
 	nargs = gctl_get_int(req, "nargs");
 	if (nargs <= 2) {
 		gctl_error(req, "Too few arguments.");

Modified: trunk/sbin/geom/class/shsec/gshsec.8
===================================================================
--- trunk/sbin/geom/class/shsec/gshsec.8	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/shsec/gshsec.8	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2005 Pawel Jakub Dawidek <pjd at FreeBSD.org>
 .\" All rights reserved.
 .\"
@@ -22,9 +23,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/geom/class/shsec/gshsec.8 307403 2016-10-16 22:02:50Z sevan $
 .\"
-.Dd January 8, 2005
+.Dd October 1, 2013
 .Dt GSHSEC 8
 .Os
 .Sh NAME
@@ -108,7 +109,7 @@
 The following example shows how to create a shared secret device.
 The secret will be split between a slice on a local disk and a USB Pen drive.
 .Bd -literal -offset indent
-gshsec label -v secret /dev/ad0s1 /dev/da0
+gshsec label -v secret /dev/ada0s1 /dev/da0
 newfs /dev/shsec/secret
 .Ed
 .Pp
@@ -127,4 +128,4 @@
 utility appeared in
 .Fx 5.4 .
 .Sh AUTHORS
-.An Pawel Jakub Dawidek Aq pjd at FreeBSD.org
+.An Pawel Jakub Dawidek Aq Mt pjd at FreeBSD.org


Property changes on: trunk/sbin/geom/class/shsec/gshsec.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/geom/class/stripe/Makefile
===================================================================
--- trunk/sbin/geom/class/stripe/Makefile	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/stripe/Makefile	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sbin/geom/class/stripe/Makefile 216468 2010-12-15 23:24:34Z obrien $
 
 .PATH: ${.CURDIR}/../../misc
 

Modified: trunk/sbin/geom/class/stripe/geom_stripe.c
===================================================================
--- trunk/sbin/geom/class/stripe/geom_stripe.c	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/stripe/geom_stripe.c	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/geom/class/stripe/geom_stripe.c 330737 2018-03-10 04:17:01Z asomers $");
 
 #include <sys/param.h>
 #include <errno.h>
@@ -128,6 +129,7 @@
 	const char *name;
 	int error, i, nargs, hardcode;
 
+	bzero(sector, sizeof(sector));
 	nargs = gctl_get_int(req, "nargs");
 	if (nargs < 3) {
 		gctl_error(req, "Too few arguments.");

Modified: trunk/sbin/geom/class/stripe/gstripe.8
===================================================================
--- trunk/sbin/geom/class/stripe/gstripe.8	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/stripe/gstripe.8	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd at FreeBSD.org>
 .\" All rights reserved.
 .\"
@@ -22,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/geom/class/stripe/gstripe.8 307403 2016-10-16 22:02:50Z sevan $
 .\"
 .Dd May 21, 2004
 .Dt GSTRIPE 8
@@ -213,8 +214,6 @@
 interleave is in number of bytes,
 unlike
 .Xr ccdconfig 8
-and
-.Xr atacontrol 8
 which use the number of sectors.
 A
 .Xr ccdconfig 8
@@ -229,14 +228,13 @@
 .Sh SEE ALSO
 .Xr geom 4 ,
 .Xr loader.conf 5 ,
-.Xr atacontrol 8 ,
 .Xr ccdconfig 8 ,
 .Xr geom 8 ,
+.Xr gvinum 8 ,
 .Xr mount 8 ,
 .Xr newfs 8 ,
 .Xr sysctl 8 ,
-.Xr umount 8 ,
-.Xr vinum 8
+.Xr umount 8
 .Sh HISTORY
 The
 .Nm
@@ -243,4 +241,4 @@
 utility appeared in
 .Fx 5.3 .
 .Sh AUTHORS
-.An Pawel Jakub Dawidek Aq pjd at FreeBSD.org
+.An Pawel Jakub Dawidek Aq Mt pjd at FreeBSD.org


Property changes on: trunk/sbin/geom/class/stripe/gstripe.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/geom/class/virstor/Makefile
===================================================================
--- trunk/sbin/geom/class/virstor/Makefile	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/virstor/Makefile	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sbin/geom/class/virstor/Makefile 216472 2010-12-16 00:00:28Z obrien $
 
 .PATH: ${.CURDIR}/../../misc ${.CURDIR}/../../../../sys/geom/virstor
 

Modified: trunk/sbin/geom/class/virstor/geom_virstor.c
===================================================================
--- trunk/sbin/geom/class/virstor/geom_virstor.c	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/virstor/geom_virstor.c	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Ivan Voras <ivoras at freebsd.org>
  *
@@ -24,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/geom/class/virstor/geom_virstor.c 330737 2018-03-10 04:17:01Z asomers $");
 
 #include <sys/param.h>
 #include <errno.h>
@@ -183,6 +184,7 @@
 		goto out;
 	}
 	bcopy(md, sector, size);
+	bzero(sector + size, sectorsize - size);
 	if (pwrite(fd, sector, sectorsize, mediasize - sectorsize) !=
 	    (ssize_t)sectorsize) {
 		error = errno;

Modified: trunk/sbin/geom/class/virstor/gvirstor.8
===================================================================
--- trunk/sbin/geom/class/virstor/gvirstor.8	2018-07-01 20:41:03 UTC (rev 11205)
+++ trunk/sbin/geom/class/virstor/gvirstor.8	2018-07-01 20:41:49 UTC (rev 11206)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2006-2011 Ivan Voras <ivoras at FreeBSD.org>
 .\" All rights reserved.
 .\"
@@ -22,9 +23,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/geom/class/virstor/gvirstor.8 307403 2016-10-16 22:02:50Z sevan $
 .\"
-.Dd January 24, 2011
+.Dd October 1, 2013
 .Dt GVIRSTOR 8
 .Os
 .Sh NAME
@@ -43,6 +44,10 @@
 .Op Fl fv
 .Ar name ...
 .Nm
+.Cm destroy
+.Op Fl fv
+.Ar name ...
+.Nm
 .Cm add
 .Op Fl vh
 .Ar name prov ...
@@ -107,6 +112,9 @@
 .Ar name .
 This command does not touch on-disk metadata.
 As with other GEOM classes, stopped geoms cannot be started manually.
+.It Cm destroy
+Same as
+.Cm stop.
 .It Cm add
 Adds new components to existing virtual device with the given
 .Ar name .
@@ -154,7 +162,7 @@
 .Pq 4 MiB ,
 with two physical devices for backing storage.
 .Bd -literal -offset indent
-.No gvirstor label -v Ar mydata Ar /dev/ad4 Ar /dev/ad6
+.No gvirstor label -v Ar mydata Ar /dev/ada4 Ar /dev/ada6
 .No newfs Ar /dev/virstor/mydata
 .Ed
 .Pp
@@ -163,11 +171,11 @@
 device entry.
 To add a new physical device / component to an active virstor device:
 .Bd -literal -offset indent
-.No gvirstor add Ar mydata Ar ad8
+.No gvirstor add Ar mydata Ar ada8
 .Ed
 .Pp
 This will add physical storage of
-.Ar ad8
+.Ar ada8
 to
 .Pa /dev/virstor/mydata
 device.
@@ -286,7 +294,7 @@
 of the first virstor component.
 This could have a significant impact on file system performance
 .Pq which can in some rare cases be even positive .
-.Sh AUTHOR
-.An Ivan Voras Aq ivoras at FreeBSD.org
+.Sh AUTHORS
+.An Ivan Voras Aq Mt ivoras at FreeBSD.org
 .Pp
 Sponsored by Google Summer of Code 2006.


Property changes on: trunk/sbin/geom/class/virstor/gvirstor.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property


More information about the Midnightbsd-cvs mailing list