summaryrefslogtreecommitdiffstats
path: root/sys/fs/msdosfs
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1999-07-25 04:01:32 +0000
committerbde <bde@FreeBSD.org>1999-07-25 04:01:32 +0000
commitd4d099c14dc9cd65845505d1852e974126a29806 (patch)
treee03e18d4bae398c1a015431499d902b8fd77a893 /sys/fs/msdosfs
parentdf4afa176b6aff7b4d5ce1f3a546f9dec80658ff (diff)
downloadFreeBSD-src-d4d099c14dc9cd65845505d1852e974126a29806.zip
FreeBSD-src-d4d099c14dc9cd65845505d1852e974126a29806.tar.gz
Don't set DE_ACCESS for unsuccessful reads.
Translated from: a similar fix in ufs_readwrite.c rev.1.61. Don't forget to set DE_ACCESS for short reads. Check for invalid (negative) offsets before checking for reads of 0 bytes, as in ufs, although checking for invalid offsets at all is probably a bug.
Diffstat (limited to 'sys/fs/msdosfs')
-rw-r--r--sys/fs/msdosfs/msdosfs_vnops.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c
index 98e301e..2034f53 100644
--- a/sys/fs/msdosfs/msdosfs_vnops.c
+++ b/sys/fs/msdosfs/msdosfs_vnops.c
@@ -1,4 +1,4 @@
-/* $Id: msdosfs_vnops.c,v 1.85 1999/05/11 19:54:43 phk Exp $ */
+/* $Id: msdosfs_vnops.c,v 1.86 1999/06/26 02:46:26 mckusick Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.68 1998/02/10 14:10:04 mrg Exp $ */
/*-
@@ -554,6 +554,7 @@ msdosfs_read(ap)
int diff;
int blsize;
int isadir;
+ int orig_resid;
long n;
long on;
daddr_t lbn;
@@ -565,13 +566,15 @@ msdosfs_read(ap)
struct msdosfsmount *pmp = dep->de_pmp;
struct uio *uio = ap->a_uio;
+ if (uio->uio_offset < 0)
+ return (EINVAL);
+
/*
* If they didn't ask for any data, then we are done.
*/
- if (uio->uio_resid == 0)
+ orig_resid = uio->uio_resid;
+ if (orig_resid <= 0)
return (0);
- if (uio->uio_offset < 0)
- return (EINVAL);
isadir = dep->de_Attributes & ATTR_DIRECTORY;
do {
@@ -580,14 +583,14 @@ msdosfs_read(ap)
n = min((u_long) (pmp->pm_bpcluster - on), uio->uio_resid);
diff = dep->de_FileSize - uio->uio_offset;
if (diff <= 0)
- return (0);
+ break;
if (diff < n)
n = diff;
/* convert cluster # to block # if a directory */
if (isadir) {
error = pcbmap(dep, lbn, &lbn, 0, &blsize);
if (error)
- return (error);
+ break;
}
/*
* If we are operating on a directory file then be sure to
@@ -611,12 +614,13 @@ msdosfs_read(ap)
n = min(n, pmp->pm_bpcluster - bp->b_resid);
if (error) {
brelse(bp);
- return (error);
+ break;
}
error = uiomove(bp->b_data + on, (int) n, uio);
brelse(bp);
} while (error == 0 && uio->uio_resid > 0 && n != 0);
- if (!isadir && !(vp->v_mount->mnt_flag & MNT_NOATIME))
+ if (!isadir && (error == 0 || uio->uio_resid != orig_resid) &&
+ (vp->v_mount->mnt_flag & MNT_NOATIME) == 0)
dep->de_flag |= DE_ACCESS;
return (error);
}
OpenPOWER on IntegriCloud