Add 'geli version' subcommand, which will print GELI metadata version of each
given GEOM provider or if not providers are given it will print versions supported by userland geli(8) utility and by ELI GEOM class. MFC after: 3 days
This commit is contained in:
parent
3bddbd0f3b
commit
ef055009c2
@ -134,6 +134,9 @@ utility:
|
|||||||
.Fl s Ar oldsize
|
.Fl s Ar oldsize
|
||||||
.Ar prov
|
.Ar prov
|
||||||
.Nm
|
.Nm
|
||||||
|
.Cm version
|
||||||
|
.Op Ar prov ...
|
||||||
|
.Nm
|
||||||
.Cm clear
|
.Cm clear
|
||||||
.Op Fl v
|
.Op Fl v
|
||||||
.Ar prov ...
|
.Ar prov ...
|
||||||
@ -597,6 +600,18 @@ Additional options include:
|
|||||||
.It Fl s Ar oldsize
|
.It Fl s Ar oldsize
|
||||||
The size of the provider before it was resized.
|
The size of the provider before it was resized.
|
||||||
.El
|
.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
|
.It Cm clear
|
||||||
Clear metadata from the given providers.
|
Clear metadata from the given providers.
|
||||||
.It Cm dump
|
.It Cm dump
|
||||||
|
@ -72,6 +72,7 @@ static void eli_kill(struct gctl_req *req);
|
|||||||
static void eli_backup(struct gctl_req *req);
|
static void eli_backup(struct gctl_req *req);
|
||||||
static void eli_restore(struct gctl_req *req);
|
static void eli_restore(struct gctl_req *req);
|
||||||
static void eli_resize(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_clear(struct gctl_req *req);
|
||||||
static void eli_dump(struct gctl_req *req);
|
static void eli_dump(struct gctl_req *req);
|
||||||
|
|
||||||
@ -96,6 +97,7 @@ static int eli_backup_create(struct gctl_req *req, const char *prov,
|
|||||||
* backup [-v] prov file
|
* backup [-v] prov file
|
||||||
* restore [-fv] file prov
|
* restore [-fv] file prov
|
||||||
* resize [-v] -s oldsize prov
|
* resize [-v] -s oldsize prov
|
||||||
|
* version [prov ...]
|
||||||
* clear [-v] prov ...
|
* clear [-v] prov ...
|
||||||
* dump [-v] prov ...
|
* dump [-v] prov ...
|
||||||
*/
|
*/
|
||||||
@ -241,6 +243,9 @@ struct g_command class_commands[] = {
|
|||||||
},
|
},
|
||||||
"[-v] -s oldsize prov"
|
"[-v] -s oldsize prov"
|
||||||
},
|
},
|
||||||
|
{ "version", G_FLAG_LOADKLD, eli_main, G_NULL_OPTS,
|
||||||
|
"[prov ...]"
|
||||||
|
},
|
||||||
{ "clear", G_FLAG_VERBOSE, eli_main, G_NULL_OPTS,
|
{ "clear", G_FLAG_VERBOSE, eli_main, G_NULL_OPTS,
|
||||||
"[-v] prov ..."
|
"[-v] prov ..."
|
||||||
},
|
},
|
||||||
@ -309,6 +314,8 @@ eli_main(struct gctl_req *req, unsigned int flags)
|
|||||||
eli_restore(req);
|
eli_restore(req);
|
||||||
else if (strcmp(name, "resize") == 0)
|
else if (strcmp(name, "resize") == 0)
|
||||||
eli_resize(req);
|
eli_resize(req);
|
||||||
|
else if (strcmp(name, "version") == 0)
|
||||||
|
eli_version(req);
|
||||||
else if (strcmp(name, "dump") == 0)
|
else if (strcmp(name, "dump") == 0)
|
||||||
eli_dump(req);
|
eli_dump(req);
|
||||||
else if (strcmp(name, "clear") == 0)
|
else if (strcmp(name, "clear") == 0)
|
||||||
@ -1523,6 +1530,46 @@ eli_resize(struct gctl_req *req)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
eli_clear(struct gctl_req *req)
|
eli_clear(struct gctl_req *req)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user