summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2005-03-17 12:07:00 +0000
committerphk <phk@FreeBSD.org>2005-03-17 12:07:00 +0000
commitcfa6bb09ea1f02e2fd37547ab40b7676048c034b (patch)
treea2144fe4b33bba27b94f9bbef8160b79a6789a7d /sys
parent92d24b8044e535eb473c6698795051f9ce495496 (diff)
downloadFreeBSD-src-cfa6bb09ea1f02e2fd37547ab40b7676048c034b.zip
FreeBSD-src-cfa6bb09ea1f02e2fd37547ab40b7676048c034b.tar.gz
Prepare for the final onslaught on devices:
Move uid/gid/mode from cdev to cdevsw. Add kind field to use for devd(8) later. Bump both D_VERSION and __FreeBSD_version
Diffstat (limited to 'sys')
-rw-r--r--sys/fs/devfs/devfs_devs.c6
-rw-r--r--sys/kern/kern_conf.c14
-rw-r--r--sys/sys/conf.h10
-rw-r--r--sys/sys/param.h2
4 files changed, 19 insertions, 13 deletions
diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c
index 761caa5..7a1647b 100644
--- a/sys/fs/devfs/devfs_devs.c
+++ b/sys/fs/devfs/devfs_devs.c
@@ -318,9 +318,9 @@ devfs_populate(struct devfs_mount *dm)
bcopy(pdev->si_name, de->de_symlink, j);
} else {
de->de_inode = i;
- de->de_uid = dev->si_uid;
- de->de_gid = dev->si_gid;
- de->de_mode = dev->si_mode;
+ de->de_uid = dev->si_devsw->d_uid;
+ de->de_gid = dev->si_devsw->d_gid;
+ de->de_mode = dev->si_devsw->d_mode;
de->de_dirent->d_type = DT_CHR;
}
#ifdef MAC
diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c
index d29e319..884872c 100644
--- a/sys/kern/kern_conf.c
+++ b/sys/kern/kern_conf.c
@@ -365,7 +365,7 @@ prep_cdevsw(struct cdevsw *devsw)
dev_lock();
- if (devsw->d_version != D_VERSION_00) {
+ if (devsw->d_version != D_VERSION_01) {
printf(
"WARNING: Device driver \"%s\" has wrong version %s\n",
devsw->d_name, "and is disabled. Recompile KLD module.");
@@ -419,8 +419,15 @@ make_dev(struct cdevsw *devsw, int minornr, uid_t uid, gid_t gid, int perms, con
KASSERT((minornr & ~MAXMINOR) == 0,
("Invalid minor (0x%x) in make_dev", minornr));
- if (!(devsw->d_flags & D_INIT))
+ if (!(devsw->d_flags & D_INIT)) {
prep_cdevsw(devsw);
+ if (devsw->d_uid == 0)
+ devsw->d_uid = uid;
+ if (devsw->d_gid == 0)
+ devsw->d_gid = gid;
+ if (devsw->d_mode == 0)
+ devsw->d_mode = perms;
+ }
dev = allocdev();
dev_lock();
dev = newdev(devsw->d_maj, minornr, dev);
@@ -448,9 +455,6 @@ make_dev(struct cdevsw *devsw, int minornr, uid_t uid, gid_t gid, int perms, con
va_end(ap);
dev->si_devsw = devsw;
- dev->si_uid = uid;
- dev->si_gid = gid;
- dev->si_mode = perms;
dev->si_flags |= SI_NAMED;
LIST_INSERT_HEAD(&devsw->d_devs, dev, si_list);
diff --git a/sys/sys/conf.h b/sys/sys/conf.h
index f743dde..6dc2561 100644
--- a/sys/sys/conf.h
+++ b/sys/sys/conf.h
@@ -79,9 +79,6 @@ struct cdev {
void *si_drv1, *si_drv2;
struct cdevsw *si_devsw;
int si_iosize_max; /* maximum I/O size (for physio &al) */
- uid_t si_uid;
- gid_t si_gid;
- mode_t si_mode;
u_long si_usecount;
u_long si_threadcount;
union {
@@ -176,7 +173,8 @@ typedef int dumper_t(
* Version numbers.
*/
#define D_VERSION_00 0x20011966
-#define D_VERSION D_VERSION_00
+#define D_VERSION_01 0x17032005 /* Add d_uid,gid,mode & kind */
+#define D_VERSION D_VERSION_01
/*
* Flags used for internal housekeeping
@@ -205,6 +203,10 @@ struct cdevsw {
d_kqfilter_t *d_kqfilter;
d_purge_t *d_purge;
d_spare2_t *d_spare2;
+ uid_t d_uid;
+ gid_t d_gid;
+ mode_t d_mode;
+ const char *d_kind;
/* These fields should not be messed with by drivers */
LIST_ENTRY(cdevsw) d_list;
diff --git a/sys/sys/param.h b/sys/sys/param.h
index f6b6382..05c15b6 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -57,7 +57,7 @@
* is created, otherwise 1.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 600020 /* Master, propagated to newvers */
+#define __FreeBSD_version 600021 /* Master, propagated to newvers */
#ifndef LOCORE
#include <sys/types.h>
OpenPOWER on IntegriCloud