summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>1999-03-09 21:16:29 +0000
committerArtur Grabowski <art@cvs.openbsd.org>1999-03-09 21:16:29 +0000
commit9e4b8d7d130c8e5f80af2f6bca11385b88002d00 (patch)
tree0ef5d69af19b7085adaeefadc5a9bb1aaea7fe14
parentfefc2f9e9927fdb95554531df74bf9edac4aabcf (diff)
POSIX says:
If O_TRUNC is set and the file did previously exist, upon successful completion the open() function shall mark for update the st_ctime and st_mtime fields of the file.
-rw-r--r--sys/ufs/ufs/ufs_vnops.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index 9e13ad2e2ca..5575728b316 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs_vnops.c,v 1.26 1999/02/26 05:55:10 millert Exp $ */
+/* $OpenBSD: ufs_vnops.c,v 1.27 1999/03/09 21:16:28 art Exp $ */
/* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */
/*
@@ -184,14 +184,19 @@ ufs_open(v)
int a_mode;
struct ucred *a_cred;
struct proc *a_p;
- } */ *ap = v;
+ } */ *ap = v;
+ struct inode *ip = VTOI(ap->a_vp);
/*
* Files marked append-only must be opened for appending.
*/
- if ((VTOI(ap->a_vp)->i_ffs_flags & APPEND) &&
+ if ((ip->i_ffs_flags & APPEND) &&
(ap->a_mode & (FWRITE | O_APPEND)) == FWRITE)
return (EPERM);
+
+ if (ap->a_mode & O_TRUNC)
+ ip->i_flag |= IN_CHANGE | IN_UPDATE;
+
return (0);
}