aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/devfs/devfs.h
diff options
context:
space:
mode:
authorDima Dorfman <dd@FreeBSD.org>2002-07-17 01:46:48 +0000
committerDima Dorfman <dd@FreeBSD.org>2002-07-17 01:46:48 +0000
commita1dc2096387101165d53fe98677d3e4e1d0557ad (patch)
tree403633d67f5bcbe849c414892c2fea74d94f0b09 /sys/fs/devfs/devfs.h
parenta96f7d1a1b4761572fa35e54c781a61bec25a808 (diff)
Notes
Diffstat (limited to 'sys/fs/devfs/devfs.h')
-rw-r--r--sys/fs/devfs/devfs.h88
1 files changed, 87 insertions, 1 deletions
diff --git a/sys/fs/devfs/devfs.h b/sys/fs/devfs/devfs.h
index 137797f4c8dbf..2f0dc762018b2 100644
--- a/sys/fs/devfs/devfs.h
+++ b/sys/fs/devfs/devfs.h
@@ -3,6 +3,8 @@
* The Regents of the University of California. All rights reserved.
* Copyright (c) 2000
* Poul-Henning Kamp. All rights reserved.
+ * Copyright (c) 2002
+ * Dima Dorfman. All rights reserved.
*
* This code is derived from software donated to Berkeley by
* Jan-Simon Pendry.
@@ -37,7 +39,86 @@
#ifndef _FS_DEVFS_DEVFS_H_
#define _FS_DEVFS_DEVFS_H_
-#ifdef _KERNEL /* No userland stuff in here... */
+#define DEVFS_MAGIC 0xdb0a087a
+
+/*
+ * Identifiers. The ruleset and rule numbers are 16-bit values. The
+ * "rule ID" is a combination of the ruleset and rule number; it
+ * should be able to univocally describe a rule in the system. In
+ * this implementation, the upper 16 bits of the rule ID is the
+ * ruleset number; the lower 16 bits, the rule number within the
+ * aforementioned ruleset.
+ */
+typedef uint16_t devfs_rnum;
+typedef uint16_t devfs_rsnum;
+typedef uint32_t devfs_rid;
+
+/*
+ * Identifier manipulators.
+ */
+#define rid2rsn(rid) ((rid) >> 16)
+#define rid2rn(rid) ((rid) & 0xffff)
+#define mkrid(rsn, rn) ((rn) | ((rsn) << 16))
+
+/*
+ * Plain DEVFS rule. This gets shared between kernel and userland
+ * verbatim, so it shouldn't contain any pointers or other kernel- or
+ * userland-specific values.
+ */
+struct devfs_rule {
+ uint32_t dr_magic; /* Magic number. */
+ devfs_rid dr_id; /* Identifier. */
+
+ /*
+ * Conditions under which this rule should be applied. These
+ * are ANDed together since OR can be simulated by using
+ * multiple rules. dr_icond determines which of the other
+ * variables we should process.
+ */
+ int dr_icond;
+#define DRC_DSWFLAGS 0x001
+#define DRC_PATHPTRN 0x002
+#define DRC_MAJOR 0x004
+ int dr_dswflags; /* cdevsw flags to match. */
+#define DEVFS_MAXPTRNLEN 200
+ char dr_pathptrn[DEVFS_MAXPTRNLEN]; /* Pattern to match path. */
+ int dr_major; /* Device major number. */
+
+ /*
+ * Things to change. dr_iacts determines which of the other
+ * variables we should process.
+ */
+ int dr_iacts;
+#define DRA_BACTS 0x001
+#define DRA_UID 0x002
+#define DRA_GID 0x004
+#define DRA_MODE 0x008
+#define DRA_INCSET 0x010
+ int dr_bacts; /* Boolean (on/off) action. */
+#define DRB_HIDE 0x001 /* Hide entry (DE_WHITEOUT). */
+#define DRB_UNHIDE 0x002 /* Unhide entry. */
+ uid_t dr_uid;
+ gid_t dr_gid;
+ mode_t dr_mode;
+ devfs_rsnum dr_incset; /* Included ruleset. */
+};
+
+/*
+ * Rule-related ioctls.
+ */
+#define DEVFSIO_RADD _IOWR('D', 0, struct devfs_rule)
+#define DEVFSIO_RDEL _IOW('D', 1, devfs_rid)
+#define DEVFSIO_RAPPLY _IOW('D', 2, struct devfs_rule)
+#define DEVFSIO_RAPPLYID _IOW('D', 3, devfs_rid)
+#define DEVFSIO_RGETNEXT _IOWR('D', 4, struct devfs_rule)
+
+#define DEVFSIO_SUSE _IOW('D', 10, devfs_rsnum)
+#define DEVFSIO_SAPPLY _IOW('D', 11, devfs_rsnum)
+#define DEVFSIO_SGETNEXT _IOWR('D', 12, devfs_rsnum)
+
+/* XXX: DEVFSIO_RS_GET_INFO for refcount, active if any, etc. */
+
+#ifdef _KERNEL
/*
* These are default sizes for the DEVFS inode table and the overflow
@@ -94,6 +175,7 @@ struct devfs_mount {
struct devfs_dirent **dm_overflow;
int dm_inode;
struct lock dm_lock;
+ devfs_rsnum dm_ruleset;
};
/*
@@ -106,6 +188,10 @@ struct devfs_mount {
extern vop_t **devfs_vnodeop_p;
extern vop_t **devfs_specop_p;
+void devfs_rules_apply(struct devfs_mount *dm, struct devfs_dirent *de);
+void devfs_rules_init(void);
+int devfs_rules_ioctl(struct mount *mp, int cmd, caddr_t data, struct thread *td);
+void devfs_rules_newmount(struct devfs_mount *dm, struct thread *td);
int devfs_allocv (struct devfs_dirent *de, struct mount *mp, struct vnode **vpp, struct thread *td);
dev_t *devfs_itod (int inode);
struct devfs_dirent **devfs_itode (struct devfs_mount *dm, int inode);