Deleted Added
full compact
geom_virstor.c (210058) geom_virstor.c (212554)
1/*-
2 * Copyright (c) 2005 Ivan Voras <ivoras@freebsd.org>
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 10 unchanged lines hidden (view full) ---

19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2005 Ivan Voras <ivoras@freebsd.org>
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 10 unchanged lines hidden (view full) ---

19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
27__FBSDID("$FreeBSD: head/sbin/geom/class/virstor/geom_virstor.c 210058 2010-07-14 15:14:00Z mav $");
27__FBSDID("$FreeBSD: head/sbin/geom/class/virstor/geom_virstor.c 212554 2010-09-13 13:48:18Z pjd $");
28
29#include <sys/param.h>
30#include <errno.h>
31#include <paths.h>
32#include <stdio.h>
33#include <stdlib.h>
34#include <stdint.h>
35#include <string.h>

--- 7 unchanged lines hidden (view full) ---

43#include <core/geom.h>
44#include <misc/subr.h>
45
46#include <geom/virstor/g_virstor_md.h>
47#include <geom/virstor/g_virstor.h>
48
49uint32_t lib_version = G_LIB_VERSION;
50uint32_t version = G_VIRSTOR_VERSION;
28
29#include <sys/param.h>
30#include <errno.h>
31#include <paths.h>
32#include <stdio.h>
33#include <stdlib.h>
34#include <stdint.h>
35#include <string.h>

--- 7 unchanged lines hidden (view full) ---

43#include <core/geom.h>
44#include <misc/subr.h>
45
46#include <geom/virstor/g_virstor_md.h>
47#include <geom/virstor/g_virstor.h>
48
49uint32_t lib_version = G_LIB_VERSION;
50uint32_t version = G_VIRSTOR_VERSION;
51static intmax_t chunk_size = 4 * 1024 * 1024; /* in kB (default: 4 MB) */
52static intmax_t vir_size = 2ULL << 40; /* in MB (default: 2 TB) */
53
51
52#define GVIRSTOR_CHUNK_SIZE "4M"
53#define GVIRSTOR_VIR_SIZE "2T"
54
54#if G_LIB_VERSION == 1
55/* Support RELENG_6 */
56#define G_TYPE_BOOL G_TYPE_NONE
57#endif
58
59/*
60 * virstor_main gets called by the geom(8) utility
61 */
62static void virstor_main(struct gctl_req *req, unsigned flags);
63
64struct g_command class_commands[] = {
55#if G_LIB_VERSION == 1
56/* Support RELENG_6 */
57#define G_TYPE_BOOL G_TYPE_NONE
58#endif
59
60/*
61 * virstor_main gets called by the geom(8) utility
62 */
63static void virstor_main(struct gctl_req *req, unsigned flags);
64
65struct g_command class_commands[] = {
65 {"clear", G_FLAG_VERBOSE, virstor_main, G_NULL_OPTS, NULL,
66 "[-v] prov ..."
66 { "clear", G_FLAG_VERBOSE, virstor_main, G_NULL_OPTS,
67 "[-v] prov ..."
67 },
68 },
68 {"dump", 0, virstor_main, G_NULL_OPTS, NULL,
69 "prov ..."
69 { "dump", 0, virstor_main, G_NULL_OPTS,
70 "prov ..."
70 },
71 },
71 {"label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, virstor_main,
72 {
73 {'h', "hardcode", NULL, G_TYPE_BOOL},
74 {'m', "chunk_size", &chunk_size, G_TYPE_NUMBER},
75 {'s', "vir_size", &vir_size, G_TYPE_NUMBER},
76 G_OPT_SENTINEL
77 },
78 NULL, "[-h] [-v] [-m chunk_size] [-s vir_size] name provider0 [provider1 ...]"
72 { "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, virstor_main,
73 {
74 { 'h', "hardcode", NULL, G_TYPE_BOOL},
75 { 'm', "chunk_size", GVIRSTOR_CHUNK_SIZE, G_TYPE_NUMBER},
76 { 's', "vir_size", GVIRSTOR_VIR_SIZE, G_TYPE_NUMBER},
77 G_OPT_SENTINEL
78 },
79 "[-h] [-v] [-m chunk_size] [-s vir_size] name provider0 [provider1 ...]"
79 },
80 },
80 {"destroy", G_FLAG_VERBOSE, NULL,
81 {
82 {'f', "force", NULL, G_TYPE_BOOL},
83 G_OPT_SENTINEL
84 },
85 NULL, "[-fv] name ..."
81 { "destroy", G_FLAG_VERBOSE, NULL,
82 {
83 { 'f', "force", NULL, G_TYPE_BOOL},
84 G_OPT_SENTINEL
85 },
86 "[-fv] name ..."
86 },
87 },
87 {"stop", G_FLAG_VERBOSE, NULL,
88 {
89 {'f', "force", NULL, G_TYPE_BOOL},
90 G_OPT_SENTINEL
91 },
92 NULL, "[-fv] name ... (alias for \"destroy\")"
88 { "stop", G_FLAG_VERBOSE, NULL,
89 {
90 { 'f', "force", NULL, G_TYPE_BOOL},
91 G_OPT_SENTINEL
92 },
93 "[-fv] name ... (alias for \"destroy\")"
93 },
94 },
94 {"add", G_FLAG_VERBOSE, NULL,
95 {
96 {'h', "hardcode", NULL, G_TYPE_BOOL},
97 G_OPT_SENTINEL
98 },
99 NULL, "[-vh] name prov [prov ...]"
95 { "add", G_FLAG_VERBOSE, NULL,
96 {
97 { 'h', "hardcode", NULL, G_TYPE_BOOL},
98 G_OPT_SENTINEL
99 },
100 "[-vh] name prov [prov ...]"
100 },
101 },
101 {"remove", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, NULL,
102 "[-v] name ..."
102 { "remove", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
103 "[-v] name ..."
103 },
104 G_CMD_SENTINEL
105};
106
107static int verbose = 0;
108
109/* Helper functions' declarations */
110static void virstor_clear(struct gctl_req *req);

--- 472 unchanged lines hidden ---
104 },
105 G_CMD_SENTINEL
106};
107
108static int verbose = 0;
109
110/* Helper functions' declarations */
111static void virstor_clear(struct gctl_req *req);

--- 472 unchanged lines hidden ---