diff options
author | Thorsten Lockert <tholo@cvs.openbsd.org> | 2002-01-09 17:55:57 +0000 |
---|---|---|
committer | Thorsten Lockert <tholo@cvs.openbsd.org> | 2002-01-09 17:55:57 +0000 |
commit | 1ee63d720d68d40048a4404347bb52fcd55f4d21 (patch) | |
tree | b171edbdb568e7318131adc446503004e442b8d4 /sys | |
parent | 3725e700cec5208e3166f78ef0ad1f7c38a0f2f3 (diff) |
If a write(2) is done with a length of zero bytes, short-circuit and do not
update the modification time -- required by POSIX. ok millert@ drahn@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_readwrite.c | 7 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_readwrite.c | 9 |
2 files changed, 15 insertions, 1 deletions
diff --git a/sys/ufs/ext2fs/ext2fs_readwrite.c b/sys/ufs/ext2fs/ext2fs_readwrite.c index 9ae4322756f..30332a71ab5 100644 --- a/sys/ufs/ext2fs/ext2fs_readwrite.c +++ b/sys/ufs/ext2fs/ext2fs_readwrite.c @@ -195,6 +195,13 @@ ext2fs_write(v) panic("%s: mode", "ext2fs_write"); #endif + /* + * If writing 0 bytes, succeed and do not change + * update time or file offset (standards compliance) + */ + if (uio->uio_resid == 0) + return (0); + switch (vp->v_type) { case VREG: if (ioflag & IO_APPEND) diff --git a/sys/ufs/ufs/ufs_readwrite.c b/sys/ufs/ufs/ufs_readwrite.c index 5b562568de7..9e99f06dbf1 100644 --- a/sys/ufs/ufs/ufs_readwrite.c +++ b/sys/ufs/ufs/ufs_readwrite.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_readwrite.c,v 1.23 2001/12/19 08:58:07 art Exp $ */ +/* $OpenBSD: ufs_readwrite.c,v 1.24 2002/01/09 17:55:56 tholo Exp $ */ /* $NetBSD: ufs_readwrite.c,v 1.9 1996/05/11 18:27:57 mycroft Exp $ */ /*- @@ -204,6 +204,13 @@ WRITE(v) panic("%s: mode", WRITE_S); #endif + /* + * If writing 0 bytes, succeed and do not change + * update time or file offset (standards compliance) + */ + if (uio->uio_resid == 0) + return (0); + switch (vp->v_type) { case VREG: if (ioflag & IO_APPEND) |