From 800b42bde016039d7b409b759e52baaed5996d33 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Thu, 17 Mar 2005 12:07:00 +0000 Subject: [PATCH] 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 --- sys/fs/devfs/devfs_devs.c | 6 +++--- sys/kern/kern_conf.c | 14 +++++++++----- sys/sys/conf.h | 10 ++++++---- sys/sys/param.h | 2 +- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c index 761caa5e8cbf..7a1647ba2df0 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 d29e31982e46..884872cfd3e6 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 f743ddef6a3b..6dc2561cbd54 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 f6b6382acc6e..05c15b6e6767 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