mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
cdevsw: add D_NONPASSABLE flag
to make the opened device files non-passable. Reviewed by: markj Tested by: pho (previous version) Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D60285
This commit is contained in:
1 parent
481447ad9b
commit
850d456292
2 files changed
+27
-2
No files matched your search
@@ -67,6 +67,7 @@
|
||||
static struct vop_vector devfs_vnodeops;
|
||||
static struct vop_vector devfs_specops;
|
||||
static const struct fileops devfs_ops_f;
|
||||
static const struct fileops devfs_ops_nonpassable_f;
|
||||
|
||||
#include <fs/devfs/devfs.h>
|
||||
#include <fs/devfs/devfs_int.h>
|
||||
@@ -1344,8 +1345,11 @@ devfs_open(struct vop_open_args *ap)
|
||||
if (fp == NULL)
|
||||
return (error);
|
||||
#endif
|
||||
if (fp->f_ops == &badfileops)
|
||||
finit(fp, fp->f_flag, DTYPE_VNODE, dev, &devfs_ops_f);
|
||||
if (fp->f_ops == &badfileops) {
|
||||
finit(fp, fp->f_flag, DTYPE_VNODE, dev,
|
||||
(dsw->d_flags & D_NONPASSABLE) == 0 ? &devfs_ops_f :
|
||||
&devfs_ops_nonpassable_f);
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
||||
@@ -2096,6 +2100,25 @@ static const struct fileops devfs_ops_f = {
|
||||
.fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE
|
||||
};
|
||||
|
||||
static const struct fileops devfs_ops_nonpassable_f = {
|
||||
.fo_read = devfs_read_f,
|
||||
.fo_write = devfs_write_f,
|
||||
.fo_truncate = devfs_truncate_f,
|
||||
.fo_ioctl = devfs_ioctl_f,
|
||||
.fo_poll = devfs_poll_f,
|
||||
.fo_kqfilter = devfs_kqfilter_f,
|
||||
.fo_stat = devfs_stat_f,
|
||||
.fo_close = devfs_close_f,
|
||||
.fo_chmod = vn_chmod,
|
||||
.fo_chown = vn_chown,
|
||||
.fo_sendfile = vn_sendfile,
|
||||
.fo_seek = vn_seek,
|
||||
.fo_fill_kinfo = vn_fill_kinfo,
|
||||
.fo_mmap = devfs_mmap_f,
|
||||
.fo_cmp = devfs_cmp_f,
|
||||
.fo_flags = DFLAG_SEEKABLE
|
||||
};
|
||||
|
||||
/* Vops for non-CHR vnodes in /dev. */
|
||||
static struct vop_vector devfs_vnodeops = {
|
||||
.vop_default = &default_vnodeops,
|
||||
|
||||
@@ -177,6 +177,8 @@ typedef int dumper_hdr_t(struct dumperinfo *di, struct kerneldumpheader *kdh);
|
||||
#define D_GIANTOK 0x00200000 /* suppress warning about using Giant */
|
||||
#define D_NEEDGIANT 0x00400000 /* driver want Giant */
|
||||
#define D_NEEDMINOR 0x00800000 /* driver uses clone_create() */
|
||||
#define D_NONPASSABLE 0x01000000 /* file is not passable with
|
||||
SCM_RIGHTS or fork(2) */
|
||||
|
||||
/*
|
||||
* Version numbers.
|
||||
|
||||
Reference in new issue
Block a user