msdosfs_access(): initialize mode to ap->a_mode instead of 0. Fixes PR 7619.
The bug has been accidentaly introduced in revision 1.56. msdosfs_setattr(): do ROFS checks as appropriate; while here optimize to only call deupdat() if there actually has been any change Tested by: jdolecek Rewieved by: wrstuden
This commit is contained in:
parent
15e449f40e
commit
6d72115a23
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: msdosfs_vnops.c,v 1.85 1999/08/03 22:02:21 wrstuden Exp $ */
|
||||
/* $NetBSD: msdosfs_vnops.c,v 1.86 1999/08/16 07:43:12 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
|
||||
@ -250,7 +250,7 @@ msdosfs_access(v)
|
||||
struct vnode *vp = ap->a_vp;
|
||||
struct denode *dep = VTODE(vp);
|
||||
struct msdosfsmount *pmp = dep->de_pmp;
|
||||
mode_t mode = 0;
|
||||
mode_t mode = ap->a_mode;
|
||||
|
||||
/*
|
||||
* Disallow write attempts on read-only file systems;
|
||||
@ -355,9 +355,10 @@ msdosfs_setattr(v)
|
||||
struct ucred *a_cred;
|
||||
struct proc *a_p;
|
||||
} */ *ap = v;
|
||||
int error = 0;
|
||||
int error = 0, de_changed = 0;
|
||||
struct denode *dep = VTODE(ap->a_vp);
|
||||
struct msdosfsmount *pmp = dep->de_pmp;
|
||||
struct vnode *vp = ap->a_vp;
|
||||
struct vattr *vap = ap->a_vap;
|
||||
struct ucred *cred = ap->a_cred;
|
||||
|
||||
@ -388,11 +389,16 @@ msdosfs_setattr(v)
|
||||
return 0;
|
||||
|
||||
if (vap->va_size != VNOVAL) {
|
||||
if (vp->v_mount->mnt_flag & MNT_RDONLY)
|
||||
return (EROFS);
|
||||
error = detrunc(dep, (u_long)vap->va_size, 0, cred, ap->a_p);
|
||||
if (error)
|
||||
return (error);
|
||||
de_changed = 1;
|
||||
}
|
||||
if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
|
||||
if (vp->v_mount->mnt_flag & MNT_RDONLY)
|
||||
return (EROFS);
|
||||
if (cred->cr_uid != pmp->pm_uid &&
|
||||
(error = suser(cred, &ap->a_p->p_acflag)) &&
|
||||
((vap->va_vaflags & VA_UTIMES_NULL) == 0 ||
|
||||
@ -405,6 +411,7 @@ msdosfs_setattr(v)
|
||||
unix2dostime(&vap->va_mtime, &dep->de_MDate, &dep->de_MTime, NULL);
|
||||
dep->de_Attributes |= ATTR_ARCHIVE;
|
||||
dep->de_flag |= DE_MODIFIED;
|
||||
de_changed = 1;
|
||||
}
|
||||
/*
|
||||
* DOS files only have the ability to have their writability
|
||||
@ -412,6 +419,8 @@ msdosfs_setattr(v)
|
||||
* attribute.
|
||||
*/
|
||||
if (vap->va_mode != (mode_t)VNOVAL) {
|
||||
if (vp->v_mount->mnt_flag & MNT_RDONLY)
|
||||
return (EROFS);
|
||||
if (cred->cr_uid != pmp->pm_uid &&
|
||||
(error = suser(cred, &ap->a_p->p_acflag)))
|
||||
return (error);
|
||||
@ -421,11 +430,14 @@ msdosfs_setattr(v)
|
||||
else
|
||||
dep->de_Attributes |= ATTR_READONLY;
|
||||
dep->de_flag |= DE_MODIFIED;
|
||||
de_changed = 1;
|
||||
}
|
||||
/*
|
||||
* Allow the `archived' bit to be toggled.
|
||||
*/
|
||||
if (vap->va_flags != VNOVAL) {
|
||||
if (vp->v_mount->mnt_flag & MNT_RDONLY)
|
||||
return (EROFS);
|
||||
if (cred->cr_uid != pmp->pm_uid &&
|
||||
(error = suser(cred, &ap->a_p->p_acflag)))
|
||||
return (error);
|
||||
@ -434,8 +446,13 @@ msdosfs_setattr(v)
|
||||
else
|
||||
dep->de_Attributes |= ATTR_ARCHIVE;
|
||||
dep->de_flag |= DE_MODIFIED;
|
||||
de_changed = 1;
|
||||
}
|
||||
return (deupdat(dep, 1));
|
||||
|
||||
if (de_changed)
|
||||
return (deupdat(dep, 1));
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user