Simplify eli_dump() function and allow to dump metadata stored in backup file.

MFC after:	3 days
This commit is contained in:
Pawel Jakub Dawidek 2011-10-25 07:37:02 +00:00
parent 275ae453d6
commit f1a465000f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=226719

View File

@ -1528,9 +1528,9 @@ eli_clear(struct gctl_req *req)
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) {
@ -1540,17 +1540,7 @@ eli_dump(struct gctl_req *req)
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));
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);
if (eli_metadata_read(NULL, name, &md) == -1) {
gctl_error(req, "Not fully done.");
continue;
}