Be consistent about flag values passed to device drivers read/write
methods: Read can see O_NONBLOCK and O_DIRECT. Write can see O_NONBLOCK, O_DIRECT and O_FSYNC. In addition O_DIRECT is shadowed as IO_DIRECT for now for backwards compatibility.
This commit is contained in:
parent
10eee285f7
commit
50a36c111f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=139189
@ -919,10 +919,8 @@ devfs_read_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, st
|
||||
if (error)
|
||||
return (error);
|
||||
resid = uio->uio_resid;
|
||||
ioflag = 0;
|
||||
if (fp->f_flag & O_NONBLOCK)
|
||||
ioflag |= IO_NDELAY;
|
||||
if (fp->f_flag & O_DIRECT)
|
||||
ioflag = fp->f_flag & (O_NONBLOCK | O_DIRECT);
|
||||
if (ioflag & O_DIRECT)
|
||||
ioflag |= IO_DIRECT;
|
||||
|
||||
if ((flags & FOF_OFFSET) == 0)
|
||||
@ -1351,14 +1349,9 @@ devfs_write_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, s
|
||||
return (error);
|
||||
KASSERT(uio->uio_td == td, ("uio_td %p is not td %p", uio->uio_td, td));
|
||||
vp = fp->f_vnode;
|
||||
ioflag = 0;
|
||||
if (fp->f_flag & O_NONBLOCK)
|
||||
ioflag |= IO_NDELAY;
|
||||
if (fp->f_flag & O_DIRECT)
|
||||
ioflag = fp->f_flag & (O_NONBLOCK | O_DIRECT | O_FSYNC);
|
||||
if (ioflag & O_DIRECT)
|
||||
ioflag |= IO_DIRECT;
|
||||
if ((fp->f_flag & O_FSYNC) ||
|
||||
(vp->v_mount && (vp->v_mount->mnt_flag & MNT_SYNCHRONOUS)))
|
||||
ioflag |= IO_SYNC;
|
||||
if ((flags & FOF_OFFSET) == 0)
|
||||
uio->uio_offset = fp->f_offset;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user