aboutsummaryrefslogtreecommitdiff
path: root/sys/geom/geom_bsd.c
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2004-12-12 10:09:05 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2004-12-12 10:09:05 +0000
commit2221dbebceb2dfb9e1c0248e4e748f8a61ab5e55 (patch)
treec331a8f51b025987771bf29e5baf7455e29185d9 /sys/geom/geom_bsd.c
parenta09345e6cd09061644815da64acee54791c7071d (diff)
downloadsrc-2221dbebceb2dfb9e1c0248e4e748f8a61ab5e55.tar.gz
src-2221dbebceb2dfb9e1c0248e4e748f8a61ab5e55.zip
Pass the file->flags down to geom ioctl handlers.
Reject certain ioctls if write permission is not indicated. Bump geom API version. Reported by: Ruben de Groot <mail25@bzerk.org>
Notes
Notes: svn path=/head/; revision=138732
Diffstat (limited to 'sys/geom/geom_bsd.c')
-rw-r--r--sys/geom/geom_bsd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/geom/geom_bsd.c b/sys/geom/geom_bsd.c
index 0f880a37c5f1..eaddb98c3a89 100644
--- a/sys/geom/geom_bsd.c
+++ b/sys/geom/geom_bsd.c
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
#include <sys/endian.h>
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/fcntl.h>
#include <sys/conf.h>
#include <sys/bio.h>
#include <sys/malloc.h>
@@ -315,7 +316,7 @@ g_bsd_hotwrite(void *arg, int flag)
* * Don't call biowait, g_getattr(), g_setattr() or g_read_data()
*/
static int
-g_bsd_ioctl(struct g_provider *pp, u_long cmd, void * data, struct thread *td)
+g_bsd_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread *td)
{
struct g_geom *gp;
struct g_bsd_softc *ms;
@@ -339,6 +340,8 @@ g_bsd_ioctl(struct g_provider *pp, u_long cmd, void * data, struct thread *td)
int error, i;
uint64_t sum;
+ if (!(fflag & FWRITE))
+ return (EPERM);
/* The disklabel to set is the ioctl argument. */
buf = g_malloc(BBSIZE, M_WAITOK);
p = *(void **)data;
@@ -369,6 +372,8 @@ g_bsd_ioctl(struct g_provider *pp, u_long cmd, void * data, struct thread *td)
case DIOCWDINFO: {
label = g_malloc(LABELSIZE, M_WAITOK);
+ if (!(fflag & FWRITE))
+ return (EPERM);
/* The disklabel to set is the ioctl argument. */
bsd_disklabel_le_enc(label, data);