View | Details | Raw Unified | Return to bug 162690 | Differences between
and this patch

Collapse All | Expand All

(-)sbin/geom/class/label/geom_label.c (+32 lines)
Lines 53-58 Link Here
53
static void label_clear(struct gctl_req *req);
53
static void label_clear(struct gctl_req *req);
54
static void label_dump(struct gctl_req *req);
54
static void label_dump(struct gctl_req *req);
55
static void label_label(struct gctl_req *req);
55
static void label_label(struct gctl_req *req);
56
static void label_refresh(struct gctl_req *req);
56
57
57
struct g_command PUBSYM(class_commands)[] = {
58
struct g_command PUBSYM(class_commands)[] = {
58
	{ "clear", G_FLAG_VERBOSE, label_main, G_NULL_OPTS,
59
	{ "clear", G_FLAG_VERBOSE, label_main, G_NULL_OPTS,
Lines 74-79 Link Here
74
	{ "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, label_main, G_NULL_OPTS,
75
	{ "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, label_main, G_NULL_OPTS,
75
	    "[-v] name dev"
76
	    "[-v] name dev"
76
	},
77
	},
78
	{ "refresh", 0, label_main, G_NULL_OPTS,
79
	    "dev ..."
80
	},
77
	{ "stop", G_FLAG_VERBOSE, NULL,
81
	{ "stop", G_FLAG_VERBOSE, NULL,
78
	    {
82
	    {
79
		{ 'f', "force", NULL, G_TYPE_BOOL },
83
		{ 'f', "force", NULL, G_TYPE_BOOL },
Lines 105-110 Link Here
105
		label_clear(req);
109
		label_clear(req);
106
	else if (strcmp(name, "dump") == 0)
110
	else if (strcmp(name, "dump") == 0)
107
		label_dump(req);
111
		label_dump(req);
112
	else if (strcmp(name, "refresh") == 0)
113
		label_refresh(req);
108
	else
114
	else
109
		gctl_error(req, "Unknown command: %s.", name);
115
		gctl_error(req, "Unknown command: %s.", name);
110
}
116
}
Lines 223-225 Link Here
223
		printf("\n");
229
		printf("\n");
224
	}
230
	}
225
}
231
}
232
233
static void
234
label_refresh(struct gctl_req *req)
235
{
236
	const char *name;
237
	int i, nargs;
238
239
	nargs = gctl_get_int(req, "nargs");
240
	if (nargs < 1) {
241
		gctl_error(req, "Too few arguments.");
242
		return;
243
	}
244
245
	for (i = 0; i < nargs; i++) {
246
		name = gctl_get_ascii(req, "arg%d", i);
247
		int fd = g_open(name, 1);
248
		if (fd == -1) {
249
			printf("Can't refresh metadata from %s: %s.\n",
250
			    name, strerror(errno));
251
		}
252
		else {
253
			printf("Metadata from %s refreshed.\n", name);
254
			(void)g_close(fd);
255
		}
256
	}
257
}

Return to bug 162690