summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2010-01-17 06:20:30 +0000
committerdelphij <delphij@FreeBSD.org>2010-01-17 06:20:30 +0000
commit16c4a5ec2099b564a3372fead91070ad8816723a (patch)
treeeddbf7d4c94dd7c16658d16b0e3f9612ebc27ff9 /lib
parent7cef302ab8816e0aac85ec3070022921b840af26 (diff)
downloadFreeBSD-src-16c4a5ec2099b564a3372fead91070ad8816723a.zip
FreeBSD-src-16c4a5ec2099b564a3372fead91070ad8816723a.tar.gz
Expose stripe offset and stripe size through libgeom and geom(8) userland
utilities. Reviewed by: pjd, mav (earlier version)
Diffstat (limited to 'lib')
-rw-r--r--lib/libgeom/geom_util.c26
-rw-r--r--lib/libgeom/geom_xml2tree.c10
-rw-r--r--lib/libgeom/libgeom.316
-rw-r--r--lib/libgeom/libgeom.h4
4 files changed, 55 insertions, 1 deletions
diff --git a/lib/libgeom/geom_util.c b/lib/libgeom/geom_util.c
index 539b6c6..54844c6 100644
--- a/lib/libgeom/geom_util.c
+++ b/lib/libgeom/geom_util.c
@@ -114,6 +114,32 @@ g_sectorsize(int fd)
}
/*
+ * Return stripe size of the given provider.
+ */
+off_t
+g_stripesize(int fd)
+{
+ off_t stripesize;
+
+ if (g_ioctl_arg(fd, DIOCGSTRIPESIZE, &stripesize) == -1)
+ return (-1);
+ return (stripesize);
+}
+
+/*
+ * Return stripe size of the given provider.
+ */
+off_t
+g_stripeoffset(int fd)
+{
+ off_t stripeoffset;
+
+ if (g_ioctl_arg(fd, DIOCGSTRIPEOFFSET, &stripeoffset) == -1)
+ return (-1);
+ return (stripeoffset);
+}
+
+/*
* Return the correct provider name.
*/
char *
diff --git a/lib/libgeom/geom_xml2tree.c b/lib/libgeom/geom_xml2tree.c
index 1c7e22b..821449b 100644
--- a/lib/libgeom/geom_xml2tree.c
+++ b/lib/libgeom/geom_xml2tree.c
@@ -230,6 +230,16 @@ EndElement(void *userData, const char *name)
free(p);
return;
}
+ if (!strcmp(name, "stripesize") && mt->provider != NULL) {
+ mt->provider->lg_stripesize = strtoumax(p, NULL, 0);
+ free(p);
+ return;
+ }
+ if (!strcmp(name, "stripeoffset") && mt->provider != NULL) {
+ mt->provider->lg_stripeoffset = strtoumax(p, NULL, 0);
+ free(p);
+ return;
+ }
if (!strcmp(name, "config")) {
mt->config = NULL;
diff --git a/lib/libgeom/libgeom.3 b/lib/libgeom/libgeom.3
index 9272d3b..3c15805 100644
--- a/lib/libgeom/libgeom.3
+++ b/lib/libgeom/libgeom.3
@@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 8, 2008
+.Dd January 16, 2010
.Dt LIBGEOM 3
.Os
.Sh NAME
@@ -50,6 +50,8 @@
.Nm g_close ,
.Nm g_mediasize ,
.Nm g_sectorsize ,
+.Nm g_stripeoffset ,
+.Nm g_stripesize ,
.Nm g_flush ,
.Nm g_delete ,
.Nm g_device_path ,
@@ -101,6 +103,10 @@
.Fn g_mediasize "int fd"
.Ft ssize_t
.Fn g_sectorsize "int fd"
+.Ft ssize_t
+.Fn g_stripeoffset "int fd"
+.Ft ssize_t
+.Fn g_stripesize "int fd"
.Ft int
.Fn g_flush "int fd"
.Ft int
@@ -297,6 +303,14 @@ The
function returns sector size of the given provider.
.Pp
The
+.Fn g_stripeoffset
+function returns stripe size of the given provider.
+.Pp
+The
+.Fn g_stripesize
+function returns stripe size of the given provider.
+.Pp
+The
.Fn g_flush
function sends
.Dv BIO_FLUSH
diff --git a/lib/libgeom/libgeom.h b/lib/libgeom/libgeom.h
index 7255bd4..c951f25 100644
--- a/lib/libgeom/libgeom.h
+++ b/lib/libgeom/libgeom.h
@@ -123,6 +123,8 @@ struct gprovider {
char *lg_mode;
off_t lg_mediasize;
u_int lg_sectorsize;
+ off_t lg_stripeoffset;
+ off_t lg_stripesize;
struct gconf lg_config;
};
@@ -149,6 +151,8 @@ int g_open(const char *, int);
int g_close(int);
off_t g_mediasize(int);
ssize_t g_sectorsize(int);
+off_t g_stripeoffset(int);
+off_t g_stripesize(int);
int g_flush(int);
int g_delete(int, off_t, off_t);
int g_get_ident(int, char *, size_t);
OpenPOWER on IntegriCloud