Deleted Added
full compact
devfs_vnops.c (279685) devfs_vnops.c (281255)
1/*-
2 * Copyright (c) 2000-2004
3 * Poul-Henning Kamp. All rights reserved.
4 * Copyright (c) 1989, 1992-1993, 1995
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software donated to Berkeley by
8 * Jan-Simon Pendry.

--- 17 unchanged lines hidden (view full) ---

26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * @(#)kernfs_vnops.c 8.15 (Berkeley) 5/21/95
32 * From: FreeBSD: src/sys/miscfs/kernfs/kernfs_vnops.c 1.43
33 *
1/*-
2 * Copyright (c) 2000-2004
3 * Poul-Henning Kamp. All rights reserved.
4 * Copyright (c) 1989, 1992-1993, 1995
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software donated to Berkeley by
8 * Jan-Simon Pendry.

--- 17 unchanged lines hidden (view full) ---

26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * @(#)kernfs_vnops.c 8.15 (Berkeley) 5/21/95
32 * From: FreeBSD: src/sys/miscfs/kernfs/kernfs_vnops.c 1.43
33 *
34 * $FreeBSD: stable/10/sys/fs/devfs/devfs_vnops.c 279685 2015-03-06 09:22:05Z kib $
34 * $FreeBSD: stable/10/sys/fs/devfs/devfs_vnops.c 281255 2015-04-08 02:15:13Z kib $
35 */
36
37/*
38 * TODO:
39 * mkdir: want it ?
40 */
41
42#include <sys/param.h>

--- 9 unchanged lines hidden (view full) ---

52#include <sys/lock.h>
53#include <sys/malloc.h>
54#include <sys/mount.h>
55#include <sys/namei.h>
56#include <sys/priv.h>
57#include <sys/proc.h>
58#include <sys/stat.h>
59#include <sys/sx.h>
35 */
36
37/*
38 * TODO:
39 * mkdir: want it ?
40 */
41
42#include <sys/param.h>

--- 9 unchanged lines hidden (view full) ---

52#include <sys/lock.h>
53#include <sys/malloc.h>
54#include <sys/mount.h>
55#include <sys/namei.h>
56#include <sys/priv.h>
57#include <sys/proc.h>
58#include <sys/stat.h>
59#include <sys/sx.h>
60#include <sys/sysctl.h>
60#include <sys/time.h>
61#include <sys/ttycom.h>
62#include <sys/unistd.h>
63#include <sys/vnode.h>
64
65static struct vop_vector devfs_vnodeops;
66static struct fileops devfs_ops_f;
67

--- 6 unchanged lines hidden (view full) ---

74
75struct mtx devfs_de_interlock;
76MTX_SYSINIT(devfs_de_interlock, &devfs_de_interlock, "devfs interlock", MTX_DEF);
77struct sx clone_drain_lock;
78SX_SYSINIT(clone_drain_lock, &clone_drain_lock, "clone events drain lock");
79struct mtx cdevpriv_mtx;
80MTX_SYSINIT(cdevpriv_mtx, &cdevpriv_mtx, "cdevpriv lock", MTX_DEF);
81
61#include <sys/time.h>
62#include <sys/ttycom.h>
63#include <sys/unistd.h>
64#include <sys/vnode.h>
65
66static struct vop_vector devfs_vnodeops;
67static struct fileops devfs_ops_f;
68

--- 6 unchanged lines hidden (view full) ---

75
76struct mtx devfs_de_interlock;
77MTX_SYSINIT(devfs_de_interlock, &devfs_de_interlock, "devfs interlock", MTX_DEF);
78struct sx clone_drain_lock;
79SX_SYSINIT(clone_drain_lock, &clone_drain_lock, "clone events drain lock");
80struct mtx cdevpriv_mtx;
81MTX_SYSINIT(cdevpriv_mtx, &cdevpriv_mtx, "cdevpriv lock", MTX_DEF);
82
83SYSCTL_DECL(_vfs_devfs);
84
85static int devfs_dotimes;
86SYSCTL_INT(_vfs_devfs, OID_AUTO, dotimes, CTLFLAG_RW,
87 &devfs_dotimes, 0, "Update timestamps on DEVFS with default precision");
88
89/*
90 * Update devfs node timestamp. Note that updates are unlocked and
91 * stat(2) could see partially updated times.
92 */
93static void
94devfs_timestamp(struct timespec *tsp)
95{
96 time_t ts;
97
98 if (devfs_dotimes) {
99 vfs_timestamp(tsp);
100 } else {
101 ts = time_second;
102 if (tsp->tv_sec != ts) {
103 tsp->tv_sec = ts;
104 tsp->tv_nsec = 0;
105 }
106 }
107}
108
82static int
83devfs_fp_check(struct file *fp, struct cdev **devp, struct cdevsw **dswp,
84 int *ref)
85{
86
87 *dswp = devvn_refthread(fp->f_vnode, devp, ref);
88 if (*devp != fp->f_data) {
89 if (*dswp != NULL)

--- 1105 unchanged lines hidden (view full) ---

1195 resid = uio->uio_resid;
1196 ioflag = fp->f_flag & (O_NONBLOCK | O_DIRECT);
1197 if (ioflag & O_DIRECT)
1198 ioflag |= IO_DIRECT;
1199
1200 foffset_lock_uio(fp, uio, flags | FOF_NOLOCK);
1201 error = dsw->d_read(dev, uio, ioflag);
1202 if (uio->uio_resid != resid || (error == 0 && resid != 0))
109static int
110devfs_fp_check(struct file *fp, struct cdev **devp, struct cdevsw **dswp,
111 int *ref)
112{
113
114 *dswp = devvn_refthread(fp->f_vnode, devp, ref);
115 if (*devp != fp->f_data) {
116 if (*dswp != NULL)

--- 1105 unchanged lines hidden (view full) ---

1222 resid = uio->uio_resid;
1223 ioflag = fp->f_flag & (O_NONBLOCK | O_DIRECT);
1224 if (ioflag & O_DIRECT)
1225 ioflag |= IO_DIRECT;
1226
1227 foffset_lock_uio(fp, uio, flags | FOF_NOLOCK);
1228 error = dsw->d_read(dev, uio, ioflag);
1229 if (uio->uio_resid != resid || (error == 0 && resid != 0))
1203 vfs_timestamp(&dev->si_atime);
1230 devfs_timestamp(&dev->si_atime);
1204 td->td_fpop = fpop;
1205 dev_relthread(dev, ref);
1206
1207 foffset_unlock_uio(fp, uio, flags | FOF_NOLOCK | FOF_NEXTOFF);
1208 return (error);
1209}
1210
1211static int

--- 462 unchanged lines hidden (view full) ---

1674 if (ioflag & O_DIRECT)
1675 ioflag |= IO_DIRECT;
1676 foffset_lock_uio(fp, uio, flags | FOF_NOLOCK);
1677
1678 resid = uio->uio_resid;
1679
1680 error = dsw->d_write(dev, uio, ioflag);
1681 if (uio->uio_resid != resid || (error == 0 && resid != 0)) {
1231 td->td_fpop = fpop;
1232 dev_relthread(dev, ref);
1233
1234 foffset_unlock_uio(fp, uio, flags | FOF_NOLOCK | FOF_NEXTOFF);
1235 return (error);
1236}
1237
1238static int

--- 462 unchanged lines hidden (view full) ---

1701 if (ioflag & O_DIRECT)
1702 ioflag |= IO_DIRECT;
1703 foffset_lock_uio(fp, uio, flags | FOF_NOLOCK);
1704
1705 resid = uio->uio_resid;
1706
1707 error = dsw->d_write(dev, uio, ioflag);
1708 if (uio->uio_resid != resid || (error == 0 && resid != 0)) {
1682 vfs_timestamp(&dev->si_ctime);
1709 devfs_timestamp(&dev->si_ctime);
1683 dev->si_mtime = dev->si_ctime;
1684 }
1685 td->td_fpop = fpop;
1686 dev_relthread(dev, ref);
1687
1688 foffset_unlock_uio(fp, uio, flags | FOF_NOLOCK | FOF_NEXTOFF);
1689 return (error);
1690}

--- 95 unchanged lines hidden ---
1710 dev->si_mtime = dev->si_ctime;
1711 }
1712 td->td_fpop = fpop;
1713 dev_relthread(dev, ref);
1714
1715 foffset_unlock_uio(fp, uio, flags | FOF_NOLOCK | FOF_NEXTOFF);
1716 return (error);
1717}

--- 95 unchanged lines hidden ---