aboutsummaryrefslogtreecommitdiff
path: root/sbin/geom/core
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/geom/core')
-rw-r--r--sbin/geom/core/Makefile.depend1
-rw-r--r--sbin/geom/core/geom.822
-rw-r--r--sbin/geom/core/geom.c33
-rw-r--r--sbin/geom/core/geom.h6
4 files changed, 37 insertions, 25 deletions
diff --git a/sbin/geom/core/Makefile.depend b/sbin/geom/core/Makefile.depend
index 3f477bc3f8b0..de2127d53ae8 100644
--- a/sbin/geom/core/Makefile.depend
+++ b/sbin/geom/core/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/sbin/geom/core/geom.8 b/sbin/geom/core/geom.8
index 298fc2b1d4fd..124ea0f2be11 100644
--- a/sbin/geom/core/geom.8
+++ b/sbin/geom/core/geom.8
@@ -22,9 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd September 14, 2018
+.Dd May 9, 2023
.Dt GEOM 8
.Os
.Sh NAME
@@ -62,10 +60,10 @@ The
.Nm
utility is used to control various GEOM classes.
A class has to be aware of
-.Xr geom 8
+.Nm
communication methods, but there are also some standard commands
which can be used for existing
-.Xr geom 8
+.Nm
unaware classes.
Here is the list of standard commands:
.Bl -tag -width ".Cm status"
@@ -127,8 +125,9 @@ When a class-specific shared library exists, a direct utility should also be
available under the name of
.Nm g Ns Ar class .
.Pp
-Currently available classes which are aware of
-.Xr geom 8 :
+Currently, classes aware of
+.Nm
+are:
.Pp
.Bl -bullet -offset indent -compact
.It
@@ -162,6 +161,10 @@ SHSEC
.It
STRIPE
.It
+UNION
+.It
+VINUM (deprecated)
+.It
VIRSTOR
.El
.Sh ENVIRONMENT
@@ -180,7 +183,10 @@ The following example shows how to set up a stripe on three disks for automatic
configuration:
.Bd -literal -offset indent
geom stripe label -v -s 65536 data /dev/da0 /dev/da1 /dev/da2
+.Ed
+.Pp
or:
+.Bd -literal -offset indent
gstripe label -v -s 65536 data /dev/da0 /dev/da1 /dev/da2
.Ed
.Pp
@@ -210,6 +216,8 @@ geom md unload
.Xr gsched 8 ,
.Xr gshsec 8 ,
.Xr gstripe 8 ,
+.Xr gunion 8 ,
+.Xr gvinum 8 ,
.Xr gvirstor 8
.Sh HISTORY
The
diff --git a/sbin/geom/core/geom.c b/sbin/geom/core/geom.c
index 0202be9a063e..950f6790b1a8 100644
--- a/sbin/geom/core/geom.c
+++ b/sbin/geom/core/geom.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004-2009 Pawel Jakub Dawidek <pjd@FreeBSD.org>
* All rights reserved.
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/linker.h>
#include <sys/module.h>
@@ -75,6 +72,8 @@ static struct g_command *class_commands = NULL;
static struct g_command *find_command(const char *cmdstr, int flags);
static void list_one_geom_by_provider(const char *provider_name);
static int std_available(const char *name);
+static int std_list_available(void);
+static int std_load_available(void);
static void std_help(struct gctl_req *req, unsigned flags);
static void std_list(struct gctl_req *req, unsigned flags);
@@ -487,7 +486,7 @@ run_command(int argc, char *argv[])
gctl_ro_param(req, "version", sizeof(*version), version);
parse_arguments(cmd, req, &argc, &argv);
- bzero(buf, sizeof(buf));
+ buf[0] = '\0';
if (cmd->gc_func != NULL) {
unsigned flags;
@@ -495,12 +494,16 @@ run_command(int argc, char *argv[])
cmd->gc_func(req, flags);
errstr = req->error;
} else {
- gctl_rw_param(req, "output", sizeof(buf), buf);
+ gctl_add_param(req, "output", sizeof(buf), buf,
+ GCTL_PARAM_WR | GCTL_PARAM_ASCII);
errstr = gctl_issue(req);
}
if (errstr != NULL && errstr[0] != '\0') {
warnx("%s", errstr);
- if (strncmp(errstr, "warning: ", strlen("warning: ")) != 0) {
+ /* Suppress EXIT_FAILURE for warnings */
+ if (strncmp(errstr, "warning: ", strlen("warning: ")) == 0)
+ req->nerror = 0;
+ if (req->nerror != 0) {
gctl_free(req);
exit(EXIT_FAILURE);
}
@@ -656,7 +659,7 @@ get_class(int *argc, char ***argv)
set_class_name();
/* If we can't load or list, it's not a class. */
- if (!std_available("load") && !std_available("list"))
+ if (!std_load_available() && !std_list_available())
errx(EXIT_FAILURE, "Invalid class name '%s'.", class_name);
if (*argc < 1)
@@ -993,7 +996,7 @@ std_list_available(void)
struct gclass *classp;
int error;
- error = geom_gettree(&mesh);
+ error = geom_gettree_geom(&mesh, gclass_name, "", 0);
if (error != 0)
errc(EXIT_FAILURE, error, "Cannot get GEOM tree");
classp = find_class(&mesh, gclass_name);
@@ -1012,7 +1015,12 @@ std_list(struct gctl_req *req, unsigned flags __unused)
const char *name;
int all, error, i, nargs;
- error = geom_gettree(&mesh);
+ nargs = gctl_get_int(req, "nargs");
+ if (nargs == 1) {
+ error = geom_gettree_geom(&mesh, gclass_name,
+ gctl_get_ascii(req, "arg0"), 1);
+ } else
+ error = geom_gettree(&mesh);
if (error != 0)
errc(EXIT_FAILURE, error, "Cannot get GEOM tree");
classp = find_class(&mesh, gclass_name);
@@ -1020,7 +1028,6 @@ std_list(struct gctl_req *req, unsigned flags __unused)
geom_deletetree(&mesh);
errx(EXIT_FAILURE, "Class '%s' not found.", gclass_name);
}
- nargs = gctl_get_int(req, "nargs");
all = gctl_get_int(req, "all");
if (nargs > 0) {
for (i = 0; i < nargs; i++) {
@@ -1318,10 +1325,10 @@ std_load_available(void)
snprintf(name, sizeof(name), "g_%s", class_name);
/*
- * If already in kernel, "load" command is not available.
+ * If already in kernel, "load" command is NOP.
*/
if (modfind(name) >= 0)
- return (0);
+ return (1);
bzero(paths, sizeof(paths));
len = sizeof(paths);
if (sysctlbyname("kern.module_path", paths, &len, NULL, 0) < 0)
diff --git a/sbin/geom/core/geom.h b/sbin/geom/core/geom.h
index 38a99032f692..93a5ee72d9ad 100644
--- a/sbin/geom/core/geom.h
+++ b/sbin/geom/core/geom.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>
* All rights reserved.
@@ -24,8 +24,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef _GEOM_H_
@@ -34,7 +32,7 @@
/*
* The G_FLAG_VERBOSE flag on a command specification means that the
- * comand will accept a -v option and the GEOM framework will print
+ * command will accept a -v option and the GEOM framework will print
* out status information after the command when it is run with -v.
* Additionally a GEOM command can explicitly specify a -v option and
* handle it as it would any other option. If both a -v option and