Fri Nov 18 21:18:52 2011 UTC ()
Obey MNT_RELATIME, the only addition is that mkdir in ufs sets IN_ACCESS too.


(christos)
diff -r1.15 -r1.16 src/sys/fs/nilfs/nilfs_vnops.c
diff -r1.36 -r1.37 src/sys/fs/ptyfs/ptyfs_vnops.c
diff -r1.161 -r1.162 src/sys/fs/puffs/puffs_vnops.c
diff -r1.92 -r1.93 src/sys/fs/tmpfs/tmpfs_vnops.c
diff -r1.68 -r1.69 src/sys/fs/udf/udf_vnops.c
diff -r1.57 -r1.58 src/sys/ufs/ext2fs/ext2fs_readwrite.c
diff -r1.100 -r1.101 src/sys/ufs/ext2fs/ext2fs_vnops.c
diff -r1.99 -r1.100 src/sys/ufs/ufs/ufs_readwrite.c
diff -r1.205 -r1.206 src/sys/ufs/ufs/ufs_vnops.c

cvs diff -r1.15 -r1.16 src/sys/fs/nilfs/nilfs_vnops.c (expand / switch to unified diff)

--- src/sys/fs/nilfs/nilfs_vnops.c 2011/10/16 12:41:45 1.15
+++ src/sys/fs/nilfs/nilfs_vnops.c 2011/11/18 21:18:50 1.16
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: nilfs_vnops.c,v 1.15 2011/10/16 12:41:45 hannken Exp $ */ 1/* $NetBSD: nilfs_vnops.c,v 1.16 2011/11/18 21:18:50 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008, 2009 Reinoud Zandijk 4 * Copyright (c) 2008, 2009 Reinoud Zandijk
5 * All rights reserved. 5 * All rights reserved.
6 *  6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -18,27 +18,27 @@ @@ -18,27 +18,27 @@
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *  26 *
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30#ifndef lint 30#ifndef lint
31__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.15 2011/10/16 12:41:45 hannken Exp $"); 31__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.16 2011/11/18 21:18:50 christos Exp $");
32#endif /* not lint */ 32#endif /* not lint */
33 33
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/systm.h> 36#include <sys/systm.h>
37#include <sys/namei.h> 37#include <sys/namei.h>
38#include <sys/resourcevar.h> /* defines plimit structure in proc struct */ 38#include <sys/resourcevar.h> /* defines plimit structure in proc struct */
39#include <sys/kernel.h> 39#include <sys/kernel.h>
40#include <sys/file.h> /* define FWRITE ... */ 40#include <sys/file.h> /* define FWRITE ... */
41#include <sys/stat.h> 41#include <sys/stat.h>
42#include <sys/buf.h> 42#include <sys/buf.h>
43#include <sys/proc.h> 43#include <sys/proc.h>
44#include <sys/mount.h> 44#include <sys/mount.h>
@@ -270,26 +270,28 @@ return EIO; @@ -270,26 +270,28 @@ return EIO;
270 if (len == 0) 270 if (len == 0)
271 break; 271 break;
272 272
273 /* ubc, here we come, prepare to trap */ 273 /* ubc, here we come, prepare to trap */
274 error = ubc_uiomove(uobj, uio, len, advice, 274 error = ubc_uiomove(uobj, uio, len, advice,
275 UBC_WRITE | UBC_UNMAP_FLAG(vp)); 275 UBC_WRITE | UBC_UNMAP_FLAG(vp));
276 if (error) 276 if (error)
277 break; 277 break;
278 } 278 }
279 uvm_vnp_setsize(vp, file_size); 279 uvm_vnp_setsize(vp, file_size);
280 280
281 /* mark node changed and request update */ 281 /* mark node changed and request update */
282 nilfs_node->i_flags |= IN_CHANGE | IN_UPDATE; 282 nilfs_node->i_flags |= IN_CHANGE | IN_UPDATE;
 283 if (vp->v_mount->mnt_flag & MNT_RELATIME)
 284 nilfs_node->i_flags |= IN_ACCESS;
283 285
284 /* 286 /*
285 * XXX TODO FFS has code here to reset setuid & setgid when we're not 287 * XXX TODO FFS has code here to reset setuid & setgid when we're not
286 * the superuser as a precaution against tampering. 288 * the superuser as a precaution against tampering.
287 */ 289 */
288 290
289 /* if we wrote a thing, note write action on vnode */ 291 /* if we wrote a thing, note write action on vnode */
290 if (resid > uio->uio_resid) 292 if (resid > uio->uio_resid)
291 VN_KNOTE(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0)); 293 VN_KNOTE(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0));
292 294
293 if (error) { 295 if (error) {
294 /* bring back file size to its former size */ 296 /* bring back file size to its former size */
295 /* take notice of its errors? */ 297 /* take notice of its errors? */

cvs diff -r1.36 -r1.37 src/sys/fs/ptyfs/ptyfs_vnops.c (expand / switch to unified diff)

--- src/sys/fs/ptyfs/ptyfs_vnops.c 2011/09/16 18:43:44 1.36
+++ src/sys/fs/ptyfs/ptyfs_vnops.c 2011/11/18 21:18:50 1.37
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ptyfs_vnops.c,v 1.36 2011/09/16 18:43:44 christos Exp $ */ 1/* $NetBSD: ptyfs_vnops.c,v 1.37 2011/11/18 21:18:50 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1993, 1995 4 * Copyright (c) 1993, 1995
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Jan-Simon Pendry. 8 * Jan-Simon Pendry.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -66,27 +66,27 @@ @@ -66,27 +66,27 @@
66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 * SUCH DAMAGE. 69 * SUCH DAMAGE.
70 * 70 *
71 * @(#)procfs_vnops.c 8.18 (Berkeley) 5/21/95 71 * @(#)procfs_vnops.c 8.18 (Berkeley) 5/21/95
72 */ 72 */
73 73
74/* 74/*
75 * ptyfs vnode interface 75 * ptyfs vnode interface
76 */ 76 */
77 77
78#include <sys/cdefs.h> 78#include <sys/cdefs.h>
79__KERNEL_RCSID(0, "$NetBSD: ptyfs_vnops.c,v 1.36 2011/09/16 18:43:44 christos Exp $"); 79__KERNEL_RCSID(0, "$NetBSD: ptyfs_vnops.c,v 1.37 2011/11/18 21:18:50 christos Exp $");
80 80
81#include <sys/param.h> 81#include <sys/param.h>
82#include <sys/systm.h> 82#include <sys/systm.h>
83#include <sys/time.h> 83#include <sys/time.h>
84#include <sys/kernel.h> 84#include <sys/kernel.h>
85#include <sys/file.h> 85#include <sys/file.h>
86#include <sys/filedesc.h> 86#include <sys/filedesc.h>
87#include <sys/proc.h> 87#include <sys/proc.h>
88#include <sys/vnode.h> 88#include <sys/vnode.h>
89#include <sys/namei.h> 89#include <sys/namei.h>
90#include <sys/malloc.h> 90#include <sys/malloc.h>
91#include <sys/mount.h> 91#include <sys/mount.h>
92#include <sys/select.h> 92#include <sys/select.h>
@@ -416,28 +416,31 @@ ptyfs_setattr(void *v) @@ -416,28 +416,31 @@ ptyfs_setattr(void *v)
416 if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL || 416 if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL ||
417 vap->va_birthtime.tv_sec != VNOVAL) { 417 vap->va_birthtime.tv_sec != VNOVAL) {
418 if (vp->v_mount->mnt_flag & MNT_RDONLY) 418 if (vp->v_mount->mnt_flag & MNT_RDONLY)
419 return EROFS; 419 return EROFS;
420 if ((ptyfs->ptyfs_flags & SF_SNAPSHOT) != 0) 420 if ((ptyfs->ptyfs_flags & SF_SNAPSHOT) != 0)
421 return EPERM; 421 return EPERM;
422 error = genfs_can_chtimes(vp, vap->va_vaflags, ptyfs->ptyfs_uid, 422 error = genfs_can_chtimes(vp, vap->va_vaflags, ptyfs->ptyfs_uid,
423 cred); 423 cred);
424 if (error) 424 if (error)
425 return (error); 425 return (error);
426 if (vap->va_atime.tv_sec != VNOVAL) 426 if (vap->va_atime.tv_sec != VNOVAL)
427 if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) 427 if (!(vp->v_mount->mnt_flag & MNT_NOATIME))
428 ptyfs->ptyfs_flag |= PTYFS_ACCESS; 428 ptyfs->ptyfs_flag |= PTYFS_ACCESS;
429 if (vap->va_mtime.tv_sec != VNOVAL) 429 if (vap->va_mtime.tv_sec != VNOVAL) {
430 ptyfs->ptyfs_flag |= PTYFS_CHANGE | PTYFS_MODIFY; 430 ptyfs->ptyfs_flag |= PTYFS_CHANGE | PTYFS_MODIFY;
 431 if (vp->v_mount->mnt_flag & MNT_RELATIME)
 432 ptyfs->ptyfs_flag |= PTYFS_ACCESS;
 433 }
431 if (vap->va_birthtime.tv_sec != VNOVAL) 434 if (vap->va_birthtime.tv_sec != VNOVAL)
432 ptyfs->ptyfs_birthtime = vap->va_birthtime; 435 ptyfs->ptyfs_birthtime = vap->va_birthtime;
433 ptyfs->ptyfs_flag |= PTYFS_CHANGE; 436 ptyfs->ptyfs_flag |= PTYFS_CHANGE;
434 error = ptyfs_update(vp, &vap->va_atime, &vap->va_mtime, 0); 437 error = ptyfs_update(vp, &vap->va_atime, &vap->va_mtime, 0);
435 if (error) 438 if (error)
436 return error; 439 return error;
437 } 440 }
438 if (vap->va_mode != (mode_t)VNOVAL) { 441 if (vap->va_mode != (mode_t)VNOVAL) {
439 if (vp->v_mount->mnt_flag & MNT_RDONLY) 442 if (vp->v_mount->mnt_flag & MNT_RDONLY)
440 return EROFS; 443 return EROFS;
441 if (ptyfs->ptyfs_type == PTYFSroot) 444 if (ptyfs->ptyfs_type == PTYFSroot)
442 return EPERM; 445 return EPERM;
443 if ((ptyfs->ptyfs_flags & SF_SNAPSHOT) != 0 && 446 if ((ptyfs->ptyfs_flags & SF_SNAPSHOT) != 0 &&

cvs diff -r1.161 -r1.162 src/sys/fs/puffs/puffs_vnops.c (expand / switch to unified diff)

--- src/sys/fs/puffs/puffs_vnops.c 2011/10/30 13:24:13 1.161
+++ src/sys/fs/puffs/puffs_vnops.c 2011/11/18 21:18:50 1.162
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: puffs_vnops.c,v 1.161 2011/10/30 13:24:13 hannken Exp $ */ 1/* $NetBSD: puffs_vnops.c,v 1.162 2011/11/18 21:18:50 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Development of this software was supported by the 6 * Development of this software was supported by the
7 * Google Summer of Code program and the Ulla Tuominen Foundation. 7 * Google Summer of Code program and the Ulla Tuominen Foundation.
8 * The Google SoC project was mentored by Bill Studenmund. 8 * The Google SoC project was mentored by Bill Studenmund.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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 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 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.161 2011/10/30 13:24:13 hannken Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.162 2011/11/18 21:18:50 christos Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/buf.h> 36#include <sys/buf.h>
37#include <sys/lockf.h> 37#include <sys/lockf.h>
38#include <sys/malloc.h> 38#include <sys/malloc.h>
39#include <sys/mount.h> 39#include <sys/mount.h>
40#include <sys/namei.h> 40#include <sys/namei.h>
41#include <sys/vnode.h> 41#include <sys/vnode.h>
42#include <sys/proc.h> 42#include <sys/proc.h>
43 43
44#include <uvm/uvm.h> 44#include <uvm/uvm.h>
45 45
46#include <fs/puffs/puffs_msgif.h> 46#include <fs/puffs/puffs_msgif.h>
@@ -1957,26 +1957,28 @@ puffs_vnop_write(void *v) @@ -1957,26 +1957,28 @@ puffs_vnop_write(void *v)
1957 1957
1958 if (vp->v_type == VREG && PUFFS_USE_PAGECACHE(pmp)) { 1958 if (vp->v_type == VREG && PUFFS_USE_PAGECACHE(pmp)) {
1959 ubcflags = UBC_WRITE | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp); 1959 ubcflags = UBC_WRITE | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp);
1960 1960
1961 /* 1961 /*
1962 * userspace *should* be allowed to control this, 1962 * userspace *should* be allowed to control this,
1963 * but with UBC it's a bit unclear how to handle it 1963 * but with UBC it's a bit unclear how to handle it
1964 */ 1964 */
1965 if (ap->a_ioflag & IO_APPEND) 1965 if (ap->a_ioflag & IO_APPEND)
1966 uio->uio_offset = vp->v_size; 1966 uio->uio_offset = vp->v_size;
1967 1967
1968 origoff = uio->uio_offset; 1968 origoff = uio->uio_offset;
1969 while (uio->uio_resid > 0) { 1969 while (uio->uio_resid > 0) {
 1970 if (vp->v_mount->mnt_flag & MNT_RELATIME)
 1971 uflags |= PUFFS_UPDATEATIME;
1970 uflags |= PUFFS_UPDATECTIME; 1972 uflags |= PUFFS_UPDATECTIME;
1971 uflags |= PUFFS_UPDATEMTIME; 1973 uflags |= PUFFS_UPDATEMTIME;
1972 oldoff = uio->uio_offset; 1974 oldoff = uio->uio_offset;
1973 bytelen = uio->uio_resid; 1975 bytelen = uio->uio_resid;
1974 1976
1975 newoff = oldoff + bytelen; 1977 newoff = oldoff + bytelen;
1976 if (vp->v_size < newoff) { 1978 if (vp->v_size < newoff) {
1977 uvm_vnp_setwritesize(vp, newoff); 1979 uvm_vnp_setwritesize(vp, newoff);
1978 } 1980 }
1979 error = ubc_uiomove(&vp->v_uobj, uio, bytelen, 1981 error = ubc_uiomove(&vp->v_uobj, uio, bytelen,
1980 UVM_ADV_RANDOM, ubcflags); 1982 UVM_ADV_RANDOM, ubcflags);
1981 1983
1982 /* 1984 /*

cvs diff -r1.92 -r1.93 src/sys/fs/tmpfs/tmpfs_vnops.c (expand / switch to unified diff)

--- src/sys/fs/tmpfs/tmpfs_vnops.c 2011/09/27 01:32:21 1.92
+++ src/sys/fs/tmpfs/tmpfs_vnops.c 2011/11/18 21:18:51 1.93
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tmpfs_vnops.c,v 1.92 2011/09/27 01:32:21 christos Exp $ */ 1/* $NetBSD: tmpfs_vnops.c,v 1.93 2011/11/18 21:18:51 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. 4 * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Julio M. Merino Vidal, developed as part of Google's Summer of Code 8 * by Julio M. Merino Vidal, developed as part of Google's Summer of Code
9 * 2005 program. 9 * 2005 program.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE. 30 * POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33/* 33/*
34 * tmpfs vnode interface. 34 * tmpfs vnode interface.
35 */ 35 */
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.92 2011/09/27 01:32:21 christos Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.93 2011/11/18 21:18:51 christos Exp $");
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/dirent.h> 41#include <sys/dirent.h>
42#include <sys/fcntl.h> 42#include <sys/fcntl.h>
43#include <sys/event.h> 43#include <sys/event.h>
44#include <sys/malloc.h> 44#include <sys/malloc.h>
45#include <sys/namei.h> 45#include <sys/namei.h>
46#include <sys/stat.h> 46#include <sys/stat.h>
47#include <sys/uio.h> 47#include <sys/uio.h>
48#include <sys/unistd.h> 48#include <sys/unistd.h>
49#include <sys/vnode.h> 49#include <sys/vnode.h>
50#include <sys/lockf.h> 50#include <sys/lockf.h>
51#include <sys/kauth.h> 51#include <sys/kauth.h>
@@ -2455,28 +2455,31 @@ tmpfs_getpages(void *v) @@ -2455,28 +2455,31 @@ tmpfs_getpages(void *v)
2455 } 2455 }
2456 2456
2457 if (vp->v_size < offset + (npages << PAGE_SHIFT)) { 2457 if (vp->v_size < offset + (npages << PAGE_SHIFT)) {
2458 npages = (round_page(vp->v_size) - offset) >> PAGE_SHIFT; 2458 npages = (round_page(vp->v_size) - offset) >> PAGE_SHIFT;
2459 } 2459 }
2460 2460
2461 if ((flags & PGO_LOCKED) != 0) 2461 if ((flags & PGO_LOCKED) != 0)
2462 return EBUSY; 2462 return EBUSY;
2463 2463
2464 if ((flags & PGO_NOTIMESTAMP) == 0) { 2464 if ((flags & PGO_NOTIMESTAMP) == 0) {
2465 if ((vp->v_mount->mnt_flag & MNT_NOATIME) == 0) 2465 if ((vp->v_mount->mnt_flag & MNT_NOATIME) == 0)
2466 node->tn_status |= TMPFS_NODE_ACCESSED; 2466 node->tn_status |= TMPFS_NODE_ACCESSED;
2467 2467
2468 if ((access_type & VM_PROT_WRITE) != 0) 2468 if ((access_type & VM_PROT_WRITE) != 0) {
2469 node->tn_status |= TMPFS_NODE_MODIFIED; 2469 node->tn_status |= TMPFS_NODE_MODIFIED;
 2470 if (vp->v_mount->mnt_flag & MNT_RELATIME)
 2471 node->tn_status |= TMPFS_NODE_ACCESSED;
 2472 }
2470 } 2473 }
2471 2474
2472 /* 2475 /*
2473 * Invoke the pager. 2476 * Invoke the pager.
2474 * 2477 *
2475 * Clean the array of pages before. XXX: PR/32166 2478 * Clean the array of pages before. XXX: PR/32166
2476 * Note that vnode lock is shared with underlying UVM object. 2479 * Note that vnode lock is shared with underlying UVM object.
2477 */ 2480 */
2478 if (pgs) { 2481 if (pgs) {
2479 memset(pgs, 0, sizeof(struct vm_pages *) * npages); 2482 memset(pgs, 0, sizeof(struct vm_pages *) * npages);
2480 } 2483 }
2481 KASSERT(vp->v_interlock == uobj->vmobjlock); 2484 KASSERT(vp->v_interlock == uobj->vmobjlock);
2482 2485

cvs diff -r1.68 -r1.69 src/sys/fs/udf/udf_vnops.c (expand / switch to unified diff)

--- src/sys/fs/udf/udf_vnops.c 2011/10/18 20:20:29 1.68
+++ src/sys/fs/udf/udf_vnops.c 2011/11/18 21:18:51 1.69
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: udf_vnops.c,v 1.68 2011/10/18 20:20:29 hannken Exp $ */ 1/* $NetBSD: udf_vnops.c,v 1.69 2011/11/18 21:18:51 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006, 2008 Reinoud Zandijk 4 * Copyright (c) 2006, 2008 Reinoud Zandijk
5 * All rights reserved. 5 * All rights reserved.
6 *  6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *  26 *
27 * Generic parts are derived from software contributed to The NetBSD Foundation 27 * Generic parts are derived from software contributed to The NetBSD Foundation
28 * by Julio M. Merino Vidal, developed as part of Google's Summer of Code 28 * by Julio M. Merino Vidal, developed as part of Google's Summer of Code
29 * 2005 program. 29 * 2005 program.
30 * 30 *
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34#ifndef lint 34#ifndef lint
35__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.68 2011/10/18 20:20:29 hannken Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.69 2011/11/18 21:18:51 christos Exp $");
36#endif /* not lint */ 36#endif /* not lint */
37 37
38 38
39#include <sys/param.h> 39#include <sys/param.h>
40#include <sys/systm.h> 40#include <sys/systm.h>
41#include <sys/namei.h> 41#include <sys/namei.h>
42#include <sys/resourcevar.h> /* defines plimit structure in proc struct */ 42#include <sys/resourcevar.h> /* defines plimit structure in proc struct */
43#include <sys/kernel.h> 43#include <sys/kernel.h>
44#include <sys/file.h> /* define FWRITE ... */ 44#include <sys/file.h> /* define FWRITE ... */
45#include <sys/stat.h> 45#include <sys/stat.h>
46#include <sys/buf.h> 46#include <sys/buf.h>
47#include <sys/proc.h> 47#include <sys/proc.h>
48#include <sys/mount.h> 48#include <sys/mount.h>
@@ -366,26 +366,28 @@ udf_write(void *v) @@ -366,26 +366,28 @@ udf_write(void *v)
366 */ 366 */
367 if (!async && (vp->v_type != VDIR) && 367 if (!async && (vp->v_type != VDIR) &&
368 (old_offset >> 16 != uio->uio_offset >> 16)) { 368 (old_offset >> 16 != uio->uio_offset >> 16)) {
369 mutex_enter(vp->v_interlock); 369 mutex_enter(vp->v_interlock);
370 error = VOP_PUTPAGES(vp, (old_offset >> 16) << 16, 370 error = VOP_PUTPAGES(vp, (old_offset >> 16) << 16,
371 (uio->uio_offset >> 16) << 16, PGO_CLEANIT); 371 (uio->uio_offset >> 16) << 16, PGO_CLEANIT);
372 old_offset = uio->uio_offset; 372 old_offset = uio->uio_offset;
373 } 373 }
374 } 374 }
375 uvm_vnp_setsize(vp, file_size); 375 uvm_vnp_setsize(vp, file_size);
376 376
377 /* mark node changed and request update */ 377 /* mark node changed and request update */
378 udf_node->i_flags |= IN_CHANGE | IN_UPDATE; 378 udf_node->i_flags |= IN_CHANGE | IN_UPDATE;
 379 if (vp->v_mount->mnt_flag & MNT_RELATIME)
 380 udf_node->i_flags |= IN_ACCESS;
379 381
380 /* 382 /*
381 * XXX TODO FFS has code here to reset setuid & setgid when we're not 383 * XXX TODO FFS has code here to reset setuid & setgid when we're not
382 * the superuser as a precaution against tampering. 384 * the superuser as a precaution against tampering.
383 */ 385 */
384 386
385 /* if we wrote a thing, note write action on vnode */ 387 /* if we wrote a thing, note write action on vnode */
386 if (resid > uio->uio_resid) 388 if (resid > uio->uio_resid)
387 VN_KNOTE(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0)); 389 VN_KNOTE(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0));
388 390
389 if (error) { 391 if (error) {
390 /* bring back file size to its former size */ 392 /* bring back file size to its former size */
391 /* take notice of its errors? */ 393 /* take notice of its errors? */
@@ -967,26 +969,28 @@ udf_chown(struct vnode *vp, uid_t new_ui @@ -967,26 +969,28 @@ udf_chown(struct vnode *vp, uid_t new_ui
967 if ((gid_t) ((uint32_t) new_gid) != new_gid) 969 if ((gid_t) ((uint32_t) new_gid) != new_gid)
968 return EINVAL; 970 return EINVAL;
969 971
970 /* check permissions */ 972 /* check permissions */
971 error = genfs_can_chown(vp, cred, uid, gid, new_uid, new_gid); 973 error = genfs_can_chown(vp, cred, uid, gid, new_uid, new_gid);
972 if (error) 974 if (error)
973 return (error); 975 return (error);
974 976
975 /* change the ownership */ 977 /* change the ownership */
976 udf_setownership(udf_node, new_uid, new_gid); 978 udf_setownership(udf_node, new_uid, new_gid);
977 979
978 /* mark node changed */ 980 /* mark node changed */
979 udf_node->i_flags |= IN_CHANGE; 981 udf_node->i_flags |= IN_CHANGE;
 982 if (vp->v_mount->mnt_flag & MNT_RELATIME)
 983 udf_node->i_flags |= IN_ACCESS;
980 984
981 return 0; 985 return 0;
982} 986}
983 987
984 988
985static int 989static int
986udf_chmod(struct vnode *vp, mode_t mode, kauth_cred_t cred) 990udf_chmod(struct vnode *vp, mode_t mode, kauth_cred_t cred)
987{ 991{
988 struct udf_node *udf_node = VTOI(vp); 992 struct udf_node *udf_node = VTOI(vp);
989 uid_t uid; 993 uid_t uid;
990 gid_t gid; 994 gid_t gid;
991 int error; 995 int error;
992 996
@@ -1003,26 +1007,28 @@ udf_chmod(struct vnode *vp, mode_t mode, @@ -1003,26 +1007,28 @@ udf_chmod(struct vnode *vp, mode_t mode,
1003 /* retrieve uid/gid values */ 1007 /* retrieve uid/gid values */
1004 udf_getownership(udf_node, &uid, &gid); 1008 udf_getownership(udf_node, &uid, &gid);
1005 1009
1006 /* check permissions */ 1010 /* check permissions */
1007 error = genfs_can_chmod(vp, cred, uid, gid, mode); 1011 error = genfs_can_chmod(vp, cred, uid, gid, mode);
1008 if (error) 1012 if (error)
1009 return (error); 1013 return (error);
1010 1014
1011 /* change mode */ 1015 /* change mode */
1012 udf_setaccessmode(udf_node, mode); 1016 udf_setaccessmode(udf_node, mode);
1013 1017
1014 /* mark node changed */ 1018 /* mark node changed */
1015 udf_node->i_flags |= IN_CHANGE; 1019 udf_node->i_flags |= IN_CHANGE;
 1020 if (vp->v_mount->mnt_flag & MNT_RELATIME)
 1021 udf_node->i_flags |= IN_ACCESS;
1016 1022
1017 return 0; 1023 return 0;
1018} 1024}
1019 1025
1020 1026
1021/* exported */ 1027/* exported */
1022int 1028int
1023udf_chsize(struct vnode *vp, u_quad_t newsize, kauth_cred_t cred) 1029udf_chsize(struct vnode *vp, u_quad_t newsize, kauth_cred_t cred)
1024{ 1030{
1025 struct udf_node *udf_node = VTOI(vp); 1031 struct udf_node *udf_node = VTOI(vp);
1026 int error, extended; 1032 int error, extended;
1027 1033
1028 if (vp->v_mount->mnt_flag & MNT_RDONLY) 1034 if (vp->v_mount->mnt_flag & MNT_RDONLY)
@@ -1053,26 +1059,28 @@ udf_chsize(struct vnode *vp, u_quad_t ne @@ -1053,26 +1059,28 @@ udf_chsize(struct vnode *vp, u_quad_t ne
1053#if notyet 1059#if notyet
1054 /* TODO get vaflags from the extended attributes? */ 1060 /* TODO get vaflags from the extended attributes? */
1055 /* Immutable or append-only files cannot be modified, either. */ 1061 /* Immutable or append-only files cannot be modified, either. */
1056 if (node->flags & (IMMUTABLE | APPEND)) 1062 if (node->flags & (IMMUTABLE | APPEND))
1057 return EPERM; 1063 return EPERM;
1058#endif 1064#endif
1059 1065
1060 /* resize file to the requested size */ 1066 /* resize file to the requested size */
1061 error = udf_resize_node(udf_node, newsize, &extended); 1067 error = udf_resize_node(udf_node, newsize, &extended);
1062 1068
1063 if (error == 0) { 1069 if (error == 0) {
1064 /* mark change */ 1070 /* mark change */
1065 udf_node->i_flags |= IN_CHANGE | IN_MODIFY; 1071 udf_node->i_flags |= IN_CHANGE | IN_MODIFY;
 1072 if (vp->v_mount->mnt_flag & MNT_RELATIME)
 1073 udf_node->i_flags |= IN_ACCESS;
1066 VN_KNOTE(vp, NOTE_ATTRIB | (extended ? NOTE_EXTEND : 0)); 1074 VN_KNOTE(vp, NOTE_ATTRIB | (extended ? NOTE_EXTEND : 0));
1067 udf_update(vp, NULL, NULL, NULL, 0); 1075 udf_update(vp, NULL, NULL, NULL, 0);
1068 } 1076 }
1069 1077
1070 return error; 1078 return error;
1071} 1079}
1072 1080
1073 1081
1074static int 1082static int
1075udf_chflags(struct vnode *vp, mode_t mode, kauth_cred_t cred) 1083udf_chflags(struct vnode *vp, mode_t mode, kauth_cred_t cred)
1076{ 1084{
1077 if (vp->v_mount->mnt_flag & MNT_RDONLY) 1085 if (vp->v_mount->mnt_flag & MNT_RDONLY)
1078 return EROFS; 1086 return EROFS;
@@ -1106,28 +1114,31 @@ udf_chtimes(struct vnode *vp, @@ -1106,28 +1114,31 @@ udf_chtimes(struct vnode *vp,
1106 1114
1107 /* retrieve uid/gid values */ 1115 /* retrieve uid/gid values */
1108 udf_getownership(udf_node, &uid, &gid); 1116 udf_getownership(udf_node, &uid, &gid);
1109 1117
1110 /* check permissions */ 1118 /* check permissions */
1111 error = genfs_can_chtimes(vp, setattrflags, uid, cred); 1119 error = genfs_can_chtimes(vp, setattrflags, uid, cred);
1112 if (error) 1120 if (error)
1113 return (error); 1121 return (error);
1114 1122
1115 /* update node flags depending on what times are passed */ 1123 /* update node flags depending on what times are passed */
1116 if (atime->tv_sec != VNOVAL) 1124 if (atime->tv_sec != VNOVAL)
1117 if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) 1125 if (!(vp->v_mount->mnt_flag & MNT_NOATIME))
1118 udf_node->i_flags |= IN_ACCESS; 1126 udf_node->i_flags |= IN_ACCESS;
1119 if ((mtime->tv_sec != VNOVAL) || (birthtime->tv_sec != VNOVAL)) 1127 if ((mtime->tv_sec != VNOVAL) || (birthtime->tv_sec != VNOVAL)) {
1120 udf_node->i_flags |= IN_CHANGE | IN_UPDATE; 1128 udf_node->i_flags |= IN_CHANGE | IN_UPDATE;
 1129 if (vp->v_mount->mnt_flag & MNT_RELATIME)
 1130 udf_node->i_flags |= IN_ACCESS;
 1131 }
1121 1132
1122 return udf_update(vp, atime, mtime, birthtime, 0); 1133 return udf_update(vp, atime, mtime, birthtime, 0);
1123} 1134}
1124 1135
1125 1136
1126int 1137int
1127udf_setattr(void *v) 1138udf_setattr(void *v)
1128{ 1139{
1129 struct vop_setattr_args /* { 1140 struct vop_setattr_args /* {
1130 struct vnode *a_vp; 1141 struct vnode *a_vp;
1131 struct vattr *a_vap; 1142 struct vattr *a_vap;
1132 kauth_cred_t a_cred; 1143 kauth_cred_t a_cred;
1133 struct lwp *a_l; 1144 struct lwp *a_l;

cvs diff -r1.57 -r1.58 src/sys/ufs/ext2fs/ext2fs_readwrite.c (expand / switch to unified diff)

--- src/sys/ufs/ext2fs/ext2fs_readwrite.c 2011/06/12 03:36:00 1.57
+++ src/sys/ufs/ext2fs/ext2fs_readwrite.c 2011/11/18 21:18:51 1.58
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ext2fs_readwrite.c,v 1.57 2011/06/12 03:36:00 rmind Exp $ */ 1/* $NetBSD: ext2fs_readwrite.c,v 1.58 2011/11/18 21:18:51 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1993 4 * Copyright (c) 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -50,27 +50,27 @@ @@ -50,27 +50,27 @@
50 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 50 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
51 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 51 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
52 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 52 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
53 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 53 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
54 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 54 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
55 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 55 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
56 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 56 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 * 57 *
58 * @(#)ufs_readwrite.c 8.8 (Berkeley) 8/4/94 58 * @(#)ufs_readwrite.c 8.8 (Berkeley) 8/4/94
59 * Modified for ext2fs by Manuel Bouyer. 59 * Modified for ext2fs by Manuel Bouyer.
60 */ 60 */
61 61
62#include <sys/cdefs.h> 62#include <sys/cdefs.h>
63__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.57 2011/06/12 03:36:00 rmind Exp $"); 63__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.58 2011/11/18 21:18:51 christos Exp $");
64 64
65#include <sys/param.h> 65#include <sys/param.h>
66#include <sys/systm.h> 66#include <sys/systm.h>
67#include <sys/resourcevar.h> 67#include <sys/resourcevar.h>
68#include <sys/kernel.h> 68#include <sys/kernel.h>
69#include <sys/file.h> 69#include <sys/file.h>
70#include <sys/stat.h> 70#include <sys/stat.h>
71#include <sys/buf.h> 71#include <sys/buf.h>
72#include <sys/proc.h> 72#include <sys/proc.h>
73#include <sys/mount.h> 73#include <sys/mount.h>
74#include <sys/vnode.h> 74#include <sys/vnode.h>
75#include <sys/malloc.h> 75#include <sys/malloc.h>
76#include <sys/signalvar.h> 76#include <sys/signalvar.h>
@@ -364,26 +364,28 @@ ext2fs_write(void *v) @@ -364,26 +364,28 @@ ext2fs_write(void *v)
364 bdwrite(bp); 364 bdwrite(bp);
365 if (error || xfersize == 0) 365 if (error || xfersize == 0)
366 break; 366 break;
367 } 367 }
368 368
369 /* 369 /*
370 * If we successfully wrote any data, and we are not the superuser 370 * If we successfully wrote any data, and we are not the superuser
371 * we clear the setuid and setgid bits as a precaution against 371 * we clear the setuid and setgid bits as a precaution against
372 * tampering. 372 * tampering.
373 */ 373 */
374 374
375out: 375out:
376 ip->i_flag |= IN_CHANGE | IN_UPDATE; 376 ip->i_flag |= IN_CHANGE | IN_UPDATE;
 377 if (vp->v_mount->mnt_flag & MNT_RELATIME)
 378 ip->i_flag |= IN_ACCESS;
377 if (resid > uio->uio_resid && ap->a_cred && 379 if (resid > uio->uio_resid && ap->a_cred &&
378 kauth_authorize_generic(ap->a_cred, KAUTH_GENERIC_ISSUSER, NULL)) 380 kauth_authorize_generic(ap->a_cred, KAUTH_GENERIC_ISSUSER, NULL))
379 ip->i_e2fs_mode &= ~(ISUID | ISGID); 381 ip->i_e2fs_mode &= ~(ISUID | ISGID);
380 if (resid > uio->uio_resid) 382 if (resid > uio->uio_resid)
381 VN_KNOTE(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0)); 383 VN_KNOTE(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0));
382 if (error) { 384 if (error) {
383 (void) ext2fs_truncate(vp, osize, ioflag & IO_SYNC, ap->a_cred); 385 (void) ext2fs_truncate(vp, osize, ioflag & IO_SYNC, ap->a_cred);
384 uio->uio_offset -= resid - uio->uio_resid; 386 uio->uio_offset -= resid - uio->uio_resid;
385 uio->uio_resid = resid; 387 uio->uio_resid = resid;
386 } else if (resid > uio->uio_resid && (ioflag & IO_SYNC) == IO_SYNC) 388 } else if (resid > uio->uio_resid && (ioflag & IO_SYNC) == IO_SYNC)
387 error = ext2fs_update(vp, NULL, NULL, UPDATE_WAIT); 389 error = ext2fs_update(vp, NULL, NULL, UPDATE_WAIT);
388 KASSERT(vp->v_size == ext2fs_size(ip)); 390 KASSERT(vp->v_size == ext2fs_size(ip));
389 return (error); 391 return (error);

cvs diff -r1.100 -r1.101 src/sys/ufs/ext2fs/ext2fs_vnops.c (expand / switch to unified diff)

--- src/sys/ufs/ext2fs/ext2fs_vnops.c 2011/07/12 16:59:48 1.100
+++ src/sys/ufs/ext2fs/ext2fs_vnops.c 2011/11/18 21:18:51 1.101
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ext2fs_vnops.c,v 1.100 2011/07/12 16:59:48 dholland Exp $ */ 1/* $NetBSD: ext2fs_vnops.c,v 1.101 2011/11/18 21:18:51 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1986, 1989, 1993 4 * Copyright (c) 1982, 1986, 1989, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc. 6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed 7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph 8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc. 10 * the permission of UNIX System Laboratories, Inc.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -55,27 +55,27 @@ @@ -55,27 +55,27 @@
55 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 55 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
56 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 56 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
57 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 57 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 58 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 59 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 60 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
61 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 61 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62 * 62 *
63 * @(#)ufs_vnops.c 8.14 (Berkeley) 10/26/94 63 * @(#)ufs_vnops.c 8.14 (Berkeley) 10/26/94
64 * Modified for ext2fs by Manuel Bouyer. 64 * Modified for ext2fs by Manuel Bouyer.
65 */ 65 */
66 66
67#include <sys/cdefs.h> 67#include <sys/cdefs.h>
68__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.100 2011/07/12 16:59:48 dholland Exp $"); 68__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.101 2011/11/18 21:18:51 christos Exp $");
69 69
70#include <sys/param.h> 70#include <sys/param.h>
71#include <sys/systm.h> 71#include <sys/systm.h>
72#include <sys/resourcevar.h> 72#include <sys/resourcevar.h>
73#include <sys/kernel.h> 73#include <sys/kernel.h>
74#include <sys/file.h> 74#include <sys/file.h>
75#include <sys/stat.h> 75#include <sys/stat.h>
76#include <sys/buf.h> 76#include <sys/buf.h>
77#include <sys/proc.h> 77#include <sys/proc.h>
78#include <sys/mount.h> 78#include <sys/mount.h>
79#include <sys/namei.h> 79#include <sys/namei.h>
80#include <sys/vnode.h> 80#include <sys/vnode.h>
81#include <sys/lockf.h> 81#include <sys/lockf.h>
@@ -421,28 +421,31 @@ ext2fs_setattr(void *v) @@ -421,28 +421,31 @@ ext2fs_setattr(void *v)
421 if (error) 421 if (error)
422 return (error); 422 return (error);
423 } 423 }
424 ip = VTOI(vp); 424 ip = VTOI(vp);
425 if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) { 425 if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
426 if (vp->v_mount->mnt_flag & MNT_RDONLY) 426 if (vp->v_mount->mnt_flag & MNT_RDONLY)
427 return (EROFS); 427 return (EROFS);
428 error = genfs_can_chtimes(vp, vap->va_vaflags, ip->i_uid, cred); 428 error = genfs_can_chtimes(vp, vap->va_vaflags, ip->i_uid, cred);
429 if (error) 429 if (error)
430 return (error); 430 return (error);
431 if (vap->va_atime.tv_sec != VNOVAL) 431 if (vap->va_atime.tv_sec != VNOVAL)
432 if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) 432 if (!(vp->v_mount->mnt_flag & MNT_NOATIME))
433 ip->i_flag |= IN_ACCESS; 433 ip->i_flag |= IN_ACCESS;
434 if (vap->va_mtime.tv_sec != VNOVAL) 434 if (vap->va_mtime.tv_sec != VNOVAL) {
435 ip->i_flag |= IN_CHANGE | IN_UPDATE; 435 ip->i_flag |= IN_CHANGE | IN_UPDATE;
 436 if (vp->v_mount->mnt_flag & MNT_RELATIME)
 437 ip->i_flag |= IN_ACCESS;
 438 }
436 error = ext2fs_update(vp, &vap->va_atime, &vap->va_mtime, 439 error = ext2fs_update(vp, &vap->va_atime, &vap->va_mtime,
437 UPDATE_WAIT); 440 UPDATE_WAIT);
438 if (error) 441 if (error)
439 return (error); 442 return (error);
440 } 443 }
441 error = 0; 444 error = 0;
442 if (vap->va_mode != (mode_t)VNOVAL) { 445 if (vap->va_mode != (mode_t)VNOVAL) {
443 if (vp->v_mount->mnt_flag & MNT_RDONLY) 446 if (vp->v_mount->mnt_flag & MNT_RDONLY)
444 return (EROFS); 447 return (EROFS);
445 error = ext2fs_chmod(vp, (int)vap->va_mode, cred, l); 448 error = ext2fs_chmod(vp, (int)vap->va_mode, cred, l);
446 } 449 }
447 VN_KNOTE(vp, NOTE_ATTRIB); 450 VN_KNOTE(vp, NOTE_ATTRIB);
448 return (error); 451 return (error);
@@ -1272,26 +1275,28 @@ ext2fs_symlink(void *v) @@ -1272,26 +1275,28 @@ ext2fs_symlink(void *v)
1272 vpp, ap->a_cnp); 1275 vpp, ap->a_cnp);
1273 if (error) 1276 if (error)
1274 return (error); 1277 return (error);
1275 VN_KNOTE(ap->a_dvp, NOTE_WRITE); 1278 VN_KNOTE(ap->a_dvp, NOTE_WRITE);
1276 vp = *vpp; 1279 vp = *vpp;
1277 len = strlen(ap->a_target); 1280 len = strlen(ap->a_target);
1278 ip = VTOI(vp); 1281 ip = VTOI(vp);
1279 if (len < ip->i_ump->um_maxsymlinklen) { 1282 if (len < ip->i_ump->um_maxsymlinklen) {
1280 memcpy((char *)ip->i_din.e2fs_din->e2di_shortlink, ap->a_target, len); 1283 memcpy((char *)ip->i_din.e2fs_din->e2di_shortlink, ap->a_target, len);
1281 error = ext2fs_setsize(ip, len); 1284 error = ext2fs_setsize(ip, len);
1282 if (error) 1285 if (error)
1283 goto bad; 1286 goto bad;
1284 ip->i_flag |= IN_CHANGE | IN_UPDATE; 1287 ip->i_flag |= IN_CHANGE | IN_UPDATE;
 1288 if (vp->v_mount->mnt_flag & MNT_RELATIME)
 1289 ip->i_flag |= IN_ACCESS;
1285 uvm_vnp_setsize(vp, len); 1290 uvm_vnp_setsize(vp, len);
1286 } else 1291 } else
1287 error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0, 1292 error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0,
1288 UIO_SYSSPACE, IO_NODELOCKED, ap->a_cnp->cn_cred, 1293 UIO_SYSSPACE, IO_NODELOCKED, ap->a_cnp->cn_cred,
1289 (size_t *)0, NULL); 1294 (size_t *)0, NULL);
1290bad: 1295bad:
1291 if (error) 1296 if (error)
1292 vput(vp); 1297 vput(vp);
1293 return (error); 1298 return (error);
1294} 1299}
1295 1300
1296/* 1301/*
1297 * Return target name of a symbolic link 1302 * Return target name of a symbolic link

cvs diff -r1.99 -r1.100 src/sys/ufs/ufs/ufs_readwrite.c (expand / switch to unified diff)

--- src/sys/ufs/ufs/ufs_readwrite.c 2011/07/11 08:27:41 1.99
+++ src/sys/ufs/ufs/ufs_readwrite.c 2011/11/18 21:18:52 1.100
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ufs_readwrite.c,v 1.99 2011/07/11 08:27:41 hannken Exp $ */ 1/* $NetBSD: ufs_readwrite.c,v 1.100 2011/11/18 21:18:52 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1993 4 * Copyright (c) 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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 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 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 * 30 *
31 * @(#)ufs_readwrite.c 8.11 (Berkeley) 5/8/95 31 * @(#)ufs_readwrite.c 8.11 (Berkeley) 5/8/95
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.99 2011/07/11 08:27:41 hannken Exp $"); 35__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.100 2011/11/18 21:18:52 christos Exp $");
36 36
37#ifdef LFS_READWRITE 37#ifdef LFS_READWRITE
38#define FS struct lfs 38#define FS struct lfs
39#define I_FS i_lfs 39#define I_FS i_lfs
40#define READ lfs_read 40#define READ lfs_read
41#define READ_S "lfs_read" 41#define READ_S "lfs_read"
42#define WRITE lfs_write 42#define WRITE lfs_write
43#define WRITE_S "lfs_write" 43#define WRITE_S "lfs_write"
44#define fs_bsize lfs_bsize 44#define fs_bsize lfs_bsize
45#define fs_bmask lfs_bmask 45#define fs_bmask lfs_bmask
46#define UFS_WAPBL_BEGIN(mp) 0 46#define UFS_WAPBL_BEGIN(mp) 0
47#define UFS_WAPBL_END(mp) do { } while (0) 47#define UFS_WAPBL_END(mp) do { } while (0)
48#define UFS_WAPBL_UPDATE(vp, access, modify, flags) do { } while (0) 48#define UFS_WAPBL_UPDATE(vp, access, modify, flags) do { } while (0)
@@ -497,26 +497,28 @@ WRITE(void *v) @@ -497,26 +497,28 @@ WRITE(void *v)
497 if (need_unreserve) { 497 if (need_unreserve) {
498 lfs_reserve(fs, vp, NULL, 498 lfs_reserve(fs, vp, NULL,
499 -btofsb(fs, (NIADDR + 1) << fs->lfs_bshift)); 499 -btofsb(fs, (NIADDR + 1) << fs->lfs_bshift));
500 } 500 }
501#endif 501#endif
502 502
503 /* 503 /*
504 * If we successfully wrote any data, and we are not the superuser 504 * If we successfully wrote any data, and we are not the superuser
505 * we clear the setuid and setgid bits as a precaution against 505 * we clear the setuid and setgid bits as a precaution against
506 * tampering. 506 * tampering.
507 */ 507 */
508out: 508out:
509 ip->i_flag |= IN_CHANGE | IN_UPDATE; 509 ip->i_flag |= IN_CHANGE | IN_UPDATE;
 510 if (vp->v_mount->mnt_flag & MNT_RELATIME)
 511 ip->i_flag |= IN_ACCESS;
510 if (resid > uio->uio_resid && ap->a_cred && 512 if (resid > uio->uio_resid && ap->a_cred &&
511 kauth_authorize_generic(ap->a_cred, KAUTH_GENERIC_ISSUSER, NULL)) { 513 kauth_authorize_generic(ap->a_cred, KAUTH_GENERIC_ISSUSER, NULL)) {
512 ip->i_mode &= ~(ISUID | ISGID); 514 ip->i_mode &= ~(ISUID | ISGID);
513 DIP_ASSIGN(ip, mode, ip->i_mode); 515 DIP_ASSIGN(ip, mode, ip->i_mode);
514 } 516 }
515 if (resid > uio->uio_resid) 517 if (resid > uio->uio_resid)
516 VN_KNOTE(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0)); 518 VN_KNOTE(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0));
517 if (error) { 519 if (error) {
518 (void) UFS_TRUNCATE(vp, osize, ioflag & IO_SYNC, ap->a_cred); 520 (void) UFS_TRUNCATE(vp, osize, ioflag & IO_SYNC, ap->a_cred);
519 uio->uio_offset -= resid - uio->uio_resid; 521 uio->uio_offset -= resid - uio->uio_resid;
520 uio->uio_resid = resid; 522 uio->uio_resid = resid;
521 } else if (resid > uio->uio_resid && (ioflag & IO_SYNC) == IO_SYNC) 523 } else if (resid > uio->uio_resid && (ioflag & IO_SYNC) == IO_SYNC)
522 error = UFS_UPDATE(vp, NULL, NULL, UPDATE_WAIT); 524 error = UFS_UPDATE(vp, NULL, NULL, UPDATE_WAIT);

cvs diff -r1.205 -r1.206 src/sys/ufs/ufs/ufs_vnops.c (expand / switch to unified diff)

--- src/sys/ufs/ufs/ufs_vnops.c 2011/09/27 02:10:32 1.205
+++ src/sys/ufs/ufs/ufs_vnops.c 2011/11/18 21:18:52 1.206
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ufs_vnops.c,v 1.205 2011/09/27 02:10:32 christos Exp $ */ 1/* $NetBSD: ufs_vnops.c,v 1.206 2011/11/18 21:18:52 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Wasabi Systems, Inc. 8 * by Wasabi Systems, Inc.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -56,27 +56,27 @@ @@ -56,27 +56,27 @@
56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * SUCH DAMAGE. 63 * SUCH DAMAGE.
64 * 64 *
65 * @(#)ufs_vnops.c 8.28 (Berkeley) 7/31/95 65 * @(#)ufs_vnops.c 8.28 (Berkeley) 7/31/95
66 */ 66 */
67 67
68#include <sys/cdefs.h> 68#include <sys/cdefs.h>
69__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.205 2011/09/27 02:10:32 christos Exp $"); 69__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.206 2011/11/18 21:18:52 christos Exp $");
70 70
71#if defined(_KERNEL_OPT) 71#if defined(_KERNEL_OPT)
72#include "opt_ffs.h" 72#include "opt_ffs.h"
73#include "opt_quota.h" 73#include "opt_quota.h"
74#endif 74#endif
75 75
76#include <sys/param.h> 76#include <sys/param.h>
77#include <sys/systm.h> 77#include <sys/systm.h>
78#include <sys/namei.h> 78#include <sys/namei.h>
79#include <sys/resourcevar.h> 79#include <sys/resourcevar.h>
80#include <sys/kernel.h> 80#include <sys/kernel.h>
81#include <sys/file.h> 81#include <sys/file.h>
82#include <sys/stat.h> 82#include <sys/stat.h>
@@ -628,28 +628,31 @@ ufs_setattr(void *v) @@ -628,28 +628,31 @@ ufs_setattr(void *v)
628 if ((ip->i_flags & SF_SNAPSHOT) != 0) { 628 if ((ip->i_flags & SF_SNAPSHOT) != 0) {
629 error = EPERM; 629 error = EPERM;
630 goto out; 630 goto out;
631 } 631 }
632 error = genfs_can_chtimes(vp, vap->va_vaflags, ip->i_uid, cred); 632 error = genfs_can_chtimes(vp, vap->va_vaflags, ip->i_uid, cred);
633 if (error) 633 if (error)
634 goto out; 634 goto out;
635 error = UFS_WAPBL_BEGIN(vp->v_mount); 635 error = UFS_WAPBL_BEGIN(vp->v_mount);
636 if (error) 636 if (error)
637 goto out; 637 goto out;
638 if (vap->va_atime.tv_sec != VNOVAL) 638 if (vap->va_atime.tv_sec != VNOVAL)
639 if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) 639 if (!(vp->v_mount->mnt_flag & MNT_NOATIME))
640 ip->i_flag |= IN_ACCESS; 640 ip->i_flag |= IN_ACCESS;
641 if (vap->va_mtime.tv_sec != VNOVAL) 641 if (vap->va_mtime.tv_sec != VNOVAL) {
642 ip->i_flag |= IN_CHANGE | IN_UPDATE; 642 ip->i_flag |= IN_CHANGE | IN_UPDATE;
 643 if (vp->v_mount->mnt_flag & MNT_RELATIME)
 644 ip->i_flag |= IN_ACCESS;
 645 }
643 if (vap->va_birthtime.tv_sec != VNOVAL && 646 if (vap->va_birthtime.tv_sec != VNOVAL &&
644 ip->i_ump->um_fstype == UFS2) { 647 ip->i_ump->um_fstype == UFS2) {
645 ip->i_ffs2_birthtime = vap->va_birthtime.tv_sec; 648 ip->i_ffs2_birthtime = vap->va_birthtime.tv_sec;
646 ip->i_ffs2_birthnsec = vap->va_birthtime.tv_nsec; 649 ip->i_ffs2_birthnsec = vap->va_birthtime.tv_nsec;
647 } 650 }
648 error = UFS_UPDATE(vp, &vap->va_atime, &vap->va_mtime, 0); 651 error = UFS_UPDATE(vp, &vap->va_atime, &vap->va_mtime, 0);
649 UFS_WAPBL_END(vp->v_mount); 652 UFS_WAPBL_END(vp->v_mount);
650 if (error) 653 if (error)
651 goto out; 654 goto out;
652 } 655 }
653 error = 0; 656 error = 0;
654 if (vap->va_mode != (mode_t)VNOVAL) { 657 if (vap->va_mode != (mode_t)VNOVAL) {
655 if (vp->v_mount->mnt_flag & MNT_RDONLY) { 658 if (vp->v_mount->mnt_flag & MNT_RDONLY) {
@@ -2082,27 +2085,27 @@ ufs_mkdir(void *v) @@ -2082,27 +2085,27 @@ ufs_mkdir(void *v)
2082#endif 2085#endif
2083 { 2086 {
2084 dirtemplate.dot_type = dirtemplate.dot_namlen; 2087 dirtemplate.dot_type = dirtemplate.dot_namlen;
2085 dirtemplate.dotdot_type = dirtemplate.dotdot_namlen; 2088 dirtemplate.dotdot_type = dirtemplate.dotdot_namlen;
2086 dirtemplate.dot_namlen = dirtemplate.dotdot_namlen = 0; 2089 dirtemplate.dot_namlen = dirtemplate.dotdot_namlen = 0;
2087 } else 2090 } else
2088 dirtemplate.dot_type = dirtemplate.dotdot_type = 0; 2091 dirtemplate.dot_type = dirtemplate.dotdot_type = 0;
2089 } 2092 }
2090 if ((error = UFS_BALLOC(tvp, (off_t)0, dirblksiz, cnp->cn_cred, 2093 if ((error = UFS_BALLOC(tvp, (off_t)0, dirblksiz, cnp->cn_cred,
2091 B_CLRBUF, &bp)) != 0) 2094 B_CLRBUF, &bp)) != 0)
2092 goto bad; 2095 goto bad;
2093 ip->i_size = dirblksiz; 2096 ip->i_size = dirblksiz;
2094 DIP_ASSIGN(ip, size, dirblksiz); 2097 DIP_ASSIGN(ip, size, dirblksiz);
2095 ip->i_flag |= IN_CHANGE | IN_UPDATE; 2098 ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
2096 uvm_vnp_setsize(tvp, ip->i_size); 2099 uvm_vnp_setsize(tvp, ip->i_size);
2097 memcpy((void *)bp->b_data, (void *)&dirtemplate, sizeof dirtemplate); 2100 memcpy((void *)bp->b_data, (void *)&dirtemplate, sizeof dirtemplate);
2098 2101
2099 /* 2102 /*
2100 * Directory set up, now install it's entry in the parent directory. 2103 * Directory set up, now install it's entry in the parent directory.
2101 * We must write out the buffer containing the new directory body 2104 * We must write out the buffer containing the new directory body
2102 * before entering the new name in the parent. 2105 * before entering the new name in the parent.
2103 */ 2106 */
2104 if ((error = VOP_BWRITE(bp->b_vp, bp)) != 0) 2107 if ((error = VOP_BWRITE(bp->b_vp, bp)) != 0)
2105 goto bad; 2108 goto bad;
2106 if ((error = UFS_UPDATE(tvp, NULL, NULL, UPDATE_DIROP)) != 0) { 2109 if ((error = UFS_UPDATE(tvp, NULL, NULL, UPDATE_DIROP)) != 0) {
2107 goto bad; 2110 goto bad;
2108 } 2111 }
@@ -2276,26 +2279,28 @@ ufs_symlink(void *v) @@ -2276,26 +2279,28 @@ ufs_symlink(void *v)
2276 vpp, ap->a_cnp); 2279 vpp, ap->a_cnp);
2277 if (error) 2280 if (error)
2278 goto out; 2281 goto out;
2279 VN_KNOTE(ap->a_dvp, NOTE_WRITE); 2282 VN_KNOTE(ap->a_dvp, NOTE_WRITE);
2280 vp = *vpp; 2283 vp = *vpp;
2281 len = strlen(ap->a_target); 2284 len = strlen(ap->a_target);
2282 ip = VTOI(vp); 2285 ip = VTOI(vp);
2283 if (len < ip->i_ump->um_maxsymlinklen) { 2286 if (len < ip->i_ump->um_maxsymlinklen) {
2284 memcpy((char *)SHORTLINK(ip), ap->a_target, len); 2287 memcpy((char *)SHORTLINK(ip), ap->a_target, len);
2285 ip->i_size = len; 2288 ip->i_size = len;
2286 DIP_ASSIGN(ip, size, len); 2289 DIP_ASSIGN(ip, size, len);
2287 uvm_vnp_setsize(vp, ip->i_size); 2290 uvm_vnp_setsize(vp, ip->i_size);
2288 ip->i_flag |= IN_CHANGE | IN_UPDATE; 2291 ip->i_flag |= IN_CHANGE | IN_UPDATE;
 2292 if (vp->v_mount->mnt_flag & MNT_RELATIME)
 2293 ip->i_flag |= IN_ACCESS;
2289 UFS_WAPBL_UPDATE(vp, NULL, NULL, 0); 2294 UFS_WAPBL_UPDATE(vp, NULL, NULL, 0);
2290 } else 2295 } else
2291 error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0, 2296 error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0,
2292 UIO_SYSSPACE, IO_NODELOCKED | IO_JOURNALLOCKED, 2297 UIO_SYSSPACE, IO_NODELOCKED | IO_JOURNALLOCKED,
2293 ap->a_cnp->cn_cred, NULL, NULL); 2298 ap->a_cnp->cn_cred, NULL, NULL);
2294 UFS_WAPBL_END1(ap->a_dvp->v_mount, ap->a_dvp); 2299 UFS_WAPBL_END1(ap->a_dvp->v_mount, ap->a_dvp);
2295 if (error) 2300 if (error)
2296 vput(vp); 2301 vput(vp);
2297out: 2302out:
2298 fstrans_done(ap->a_dvp->v_mount); 2303 fstrans_done(ap->a_dvp->v_mount);
2299 return (error); 2304 return (error);
2300} 2305}
2301 2306