summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/geom/part/g_part.c33
-rw-r--r--sys/geom/part/g_part.h17
-rw-r--r--sys/geom/part/g_part_if.m13
3 files changed, 43 insertions, 20 deletions
diff --git a/sys/geom/part/g_part.c b/sys/geom/part/g_part.c
index 9a345bb..7982945 100644
--- a/sys/geom/part/g_part.c
+++ b/sys/geom/part/g_part.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2002, 2005-2008 Marcel Moolenaar
+ * Copyright (c) 2002, 2005-2009 Marcel Moolenaar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -110,23 +110,6 @@ static struct g_class g_part_class = {
DECLARE_GEOM_CLASS(g_part_class, g_part);
-enum g_part_ctl {
- G_PART_CTL_NONE,
- G_PART_CTL_ADD,
- G_PART_CTL_BOOTCODE,
- G_PART_CTL_COMMIT,
- G_PART_CTL_CREATE,
- G_PART_CTL_DELETE,
- G_PART_CTL_DESTROY,
- G_PART_CTL_MODIFY,
- G_PART_CTL_MOVE,
- G_PART_CTL_RECOVER,
- G_PART_CTL_RESIZE,
- G_PART_CTL_SET,
- G_PART_CTL_UNDO,
- G_PART_CTL_UNSET
-};
-
/*
* Support functions.
*/
@@ -1349,7 +1332,7 @@ g_part_ctlreq(struct gctl_req *req, struct g_class *mp, const char *verb)
/* Obtain permissions if possible/necessary. */
close_on_error = 0;
- table = NULL; /* Suppress uninit. warning. */
+ table = NULL;
if (modifies && (gpp.gpp_parms & G_PART_PARM_GEOM)) {
table = gpp.gpp_geom->softc;
if (table != NULL && !table->gpt_opened) {
@@ -1365,7 +1348,16 @@ g_part_ctlreq(struct gctl_req *req, struct g_class *mp, const char *verb)
}
}
- error = EDOOFUS; /* Prevent bogus uninit. warning. */
+ /* Allow the scheme to check or modify the parameters. */
+ if (table != NULL) {
+ error = G_PART_PRECHECK(table, ctlreq, &gpp);
+ if (error) {
+ gctl_error(req, "%d pre-check failed", error);
+ goto out;
+ }
+ } else
+ error = EDOOFUS; /* Prevent bogus uninit. warning. */
+
switch (ctlreq) {
case G_PART_CTL_NONE:
panic("%s", __func__);
@@ -1421,6 +1413,7 @@ g_part_ctlreq(struct gctl_req *req, struct g_class *mp, const char *verb)
}
}
+ out:
if (error && close_on_error) {
g_access(LIST_FIRST(&gpp.gpp_geom->consumer), -1, -1, -1);
table->gpt_opened = 0;
diff --git a/sys/geom/part/g_part.h b/sys/geom/part/g_part.h
index cfc048d..353063b6 100644
--- a/sys/geom/part/g_part.h
+++ b/sys/geom/part/g_part.h
@@ -123,6 +123,23 @@ struct g_part_table {
struct g_part_entry *g_part_new_entry(struct g_part_table *, int, quad_t,
quad_t);
+enum g_part_ctl {
+ G_PART_CTL_NONE,
+ G_PART_CTL_ADD,
+ G_PART_CTL_BOOTCODE,
+ G_PART_CTL_COMMIT,
+ G_PART_CTL_CREATE,
+ G_PART_CTL_DELETE,
+ G_PART_CTL_DESTROY,
+ G_PART_CTL_MODIFY,
+ G_PART_CTL_MOVE,
+ G_PART_CTL_RECOVER,
+ G_PART_CTL_RESIZE,
+ G_PART_CTL_SET,
+ G_PART_CTL_UNDO,
+ G_PART_CTL_UNSET
+};
+
/* G_PART ctlreq parameters. */
#define G_PART_PARM_ENTRIES 0x0001
#define G_PART_PARM_FLAGS 0x0002
diff --git a/sys/geom/part/g_part_if.m b/sys/geom/part/g_part_if.m
index 2a0a182..4993db1 100644
--- a/sys/geom/part/g_part_if.m
+++ b/sys/geom/part/g_part_if.m
@@ -95,6 +95,19 @@ METHOD const char * name {
size_t bufsz;
};
+# precheck() - method to allow schemes to check the parameters given
+# to the mentioned ctl request. This only applies to the requests that
+# operate on a GEOM. In other words, it does not apply to the create
+# request.
+# It is allowed (intended actually) to change the parameters according
+# to the schemes needs before they are used. Returning an error will
+# terminate the request immediately.
+METHOD int precheck {
+ struct g_part_table *table;
+ enum g_part_ctl req;
+ struct g_part_parms *gpp;
+};
+
# probe() - probe the provider attached to the given consumer for the
# existence of the scheme implemented by the G_PART interface handler.
METHOD int probe {
OpenPOWER on IntegriCloud