cdev (still) needs per instance uid/gid/mode
Add unlocked version of dev_ref() Clean up various stuff in sys/conf.h
This commit is contained in:
parent
eb151cb989
commit
9477d73e32
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=144385
@ -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_devsw->d_uid;
|
||||
de->de_gid = dev->si_devsw->d_gid;
|
||||
de->de_mode = dev->si_devsw->d_mode;
|
||||
de->de_uid = dev->si_uid;
|
||||
de->de_gid = dev->si_gid;
|
||||
de->de_mode = dev->si_mode;
|
||||
de->de_dirent->d_type = DT_CHR;
|
||||
}
|
||||
#ifdef MAC
|
||||
|
@ -67,6 +67,16 @@ dev_unlock(void)
|
||||
mtx_unlock(&devmtx);
|
||||
}
|
||||
|
||||
void
|
||||
dev_ref(struct cdev *dev)
|
||||
{
|
||||
|
||||
mtx_assert(&devmtx, MA_NOTOWNED);
|
||||
mtx_lock(&devmtx);
|
||||
dev->si_refcount++;
|
||||
mtx_unlock(&devmtx);
|
||||
}
|
||||
|
||||
void
|
||||
dev_refl(struct cdev *dev)
|
||||
{
|
||||
@ -361,7 +371,7 @@ prep_cdevsw(struct cdevsw *devsw)
|
||||
}
|
||||
|
||||
struct cdev *
|
||||
make_dev(struct cdevsw *devsw, int minornr, uid_t uid, gid_t gid, int perms, const char *fmt, ...)
|
||||
make_dev(struct cdevsw *devsw, int minornr, uid_t uid, gid_t gid, int mode, const char *fmt, ...)
|
||||
{
|
||||
struct cdev *dev;
|
||||
va_list ap;
|
||||
@ -370,15 +380,8 @@ 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, minornr, dev);
|
||||
@ -407,6 +410,9 @@ make_dev(struct cdevsw *devsw, int minornr, uid_t uid, gid_t gid, int perms, con
|
||||
|
||||
dev->si_devsw = devsw;
|
||||
dev->si_flags |= SI_NAMED;
|
||||
dev->si_uid = uid;
|
||||
dev->si_gid = gid;
|
||||
dev->si_mode = mode;
|
||||
|
||||
devfs_create(dev);
|
||||
dev_unlock();
|
||||
|
@ -65,11 +65,13 @@ struct cdev {
|
||||
struct timespec si_atime;
|
||||
struct timespec si_ctime;
|
||||
struct timespec si_mtime;
|
||||
uid_t si_uid;
|
||||
gid_t si_gid;
|
||||
mode_t si_mode;
|
||||
u_int si_drv0;
|
||||
int si_refcount;
|
||||
LIST_ENTRY(cdev) si_list;
|
||||
LIST_ENTRY(cdev) si_clone;
|
||||
LIST_ENTRY(cdev) si_hash; /* UNUSED */
|
||||
LIST_HEAD(,devfs_dirent)si_alist;
|
||||
LIST_HEAD(, cdev) si_children;
|
||||
LIST_ENTRY(cdev) si_siblings;
|
||||
@ -180,14 +182,12 @@ typedef int dumper_t(
|
||||
* Flags used for internal housekeeping
|
||||
*/
|
||||
#define D_INIT 0x80000000 /* cdevsw initialized */
|
||||
#define D_ALLOCMAJ 0x40000000 /* major# is allocated */
|
||||
|
||||
/*
|
||||
* Character device switch table
|
||||
*/
|
||||
struct cdevsw {
|
||||
int d_version;
|
||||
int d_maj;
|
||||
u_int d_flags;
|
||||
const char *d_name;
|
||||
d_open_t *d_open;
|
||||
@ -247,6 +247,7 @@ struct cdevsw *dev_refthread(struct cdev *_dev);
|
||||
void dev_relthread(struct cdev *_dev);
|
||||
int dev_named(struct cdev *_pdev, const char *_name);
|
||||
void dev_depends(struct cdev *_pdev, struct cdev *_cdev);
|
||||
void dev_ref(struct cdev *dev);
|
||||
void dev_refl(struct cdev *dev);
|
||||
void dev_rel(struct cdev *dev);
|
||||
void dev_strategy(struct cdev *dev, struct buf *bp);
|
||||
|
Loading…
Reference in New Issue
Block a user