struct ntnode: g/c i_uid, i_gid, i_mode - use directly appropriate

ntnode->ntmp->ntm_* values
ntfs_inactivate(): as NTFS doesn't support any filesystem changes,
	it's not needed to check whether the file handle is stale;
	the check was bogus anyway - besides the value of vp->v_usecount
	was checked with unlocked vnode, the vnode was unnecessarily
	_always_ recycled when the filesystem containing it has been
	mounted with mask (-i parameter to mount_ntfs(1))
	not specified or 0 -- unbelievable, but true
ntfs_reclaim(): don't call VOP_UNLOCK() even on FreeBSD - it's not
	done for any other their filesystem, so it should not be done even
	for NTFS
ntfs_access(): remove the commented-out check for immutable flag, it doesn't
	make sense for NTFS
other miscelaneous cosmetic cleanups
This commit is contained in:
jdolecek 1999-10-31 19:45:26 +00:00
parent ff5396ed7a
commit 94b1798c8c
4 changed files with 36 additions and 62 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ntfs.h,v 1.8 1999/10/25 19:08:26 jdolecek Exp $ */
/* $NetBSD: ntfs.h,v 1.9 1999/10/31 19:45:26 jdolecek Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
@ -305,7 +305,7 @@ MALLOC_DECLARE(M_NTFSNTHASH);
typedef int (vop_t) __P((void *));
#define HASHINIT(a, b, c, d) hashinit((a), (b), (c), (d))
#define bqrelse(bp) brelse(bp)
#define VOP__UNLOCK(a, b, c) VOP_UNLOCK((a), 0)
#define VOP__UNLOCK(a, b, c) VOP_UNLOCK((a), (b))
#define VGET(a, b, c) vget((a), (b))
#define VN_LOCK(a, b, c) vn_lock((a), (b))
#else /* !NetBSD */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ntfs_inode.h,v 1.7 1999/10/09 14:27:42 jdolecek Exp $ */
/* $NetBSD: ntfs_inode.h,v 1.8 1999/10/31 19:45:26 jdolecek Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
@ -78,10 +78,6 @@ struct ntnode {
long i_nlink; /* MFR */
ino_t i_mainrec; /* MFR */
u_int32_t i_frflag; /* MFR */
uid_t i_uid;
gid_t i_gid;
mode_t i_mode;
};
#define FN_PRELOADED 0x0001

View File

@ -1,4 +1,4 @@
/* $NetBSD: ntfs_subr.c,v 1.22 1999/10/25 21:17:21 jdolecek Exp $ */
/* $NetBSD: ntfs_subr.c,v 1.23 1999/10/31 19:45:26 jdolecek Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
@ -352,7 +352,7 @@ out:
/*
* Routine locks ntnode and increase usecount, just opposite of
* ntfs_ntput.
* ntfs_ntput().
*/
int
ntfs_ntget(ip)
@ -405,9 +405,6 @@ ntfs_ntlookup(
ip->i_dev = ntmp->ntm_dev;
ip->i_number = ino;
ip->i_mp = ntmp;
ip->i_uid = ntmp->ntm_uid;
ip->i_gid = ntmp->ntm_gid;
ip->i_mode = ntmp->ntm_mode;
LIST_INIT(&ip->i_fnlist);
@ -435,8 +432,8 @@ ntfs_ntlookup(
* ntnode should be locked on entry, and unlocked on return.
*/
void
ntfs_ntput(
struct ntnode *ip)
ntfs_ntput(ip)
struct ntnode *ip;
{
struct ntvattr *vap;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ntfs_vnops.c,v 1.22 1999/10/27 20:56:41 jdolecek Exp $ */
/* $NetBSD: ntfs_vnops.c,v 1.23 1999/10/31 19:45:27 jdolecek Exp $ */
/*
* Copyright (c) 1992, 1993
@ -221,10 +221,10 @@ ntfs_getattr(ap)
vap->va_fsid = ip->i_dev;
#endif
vap->va_fileid = ip->i_number;
vap->va_mode = ip->i_mode;
vap->va_mode = ip->i_mp->ntm_mode;
vap->va_nlink = ip->i_nlink;
vap->va_uid = ip->i_uid;
vap->va_gid = ip->i_gid;
vap->va_uid = ip->i_mp->ntm_uid;
vap->va_gid = ip->i_mp->ntm_gid;
vap->va_rdev = 0; /* XXX UNODEV ? */
vap->va_size = fp->f_size;
vap->va_bytes = fp->f_allocated;
@ -250,33 +250,25 @@ ntfs_inactive(ap)
} */ *ap;
{
register struct vnode *vp = ap->a_vp;
#ifdef NTFS_DEBUG
register struct ntnode *ip = VTONT(vp);
int error;
#endif
dprintf(("ntfs_inactive: vnode: %p, ntnode: %d\n", vp, ip->i_number));
if (ntfs_prtactive && vp->v_usecount != 0)
vprint("ntfs_inactive: pushing active", vp);
error = 0;
VOP__UNLOCK(vp, 0, ap->a_p);
VOP__UNLOCK(vp,0,ap->a_p);
/*
* If we are done with the ntnode, reclaim it
* so that it can be reused immediately.
/* XXX since we don't support any filesystem changes
* right now, nothing more needs to be done
*/
if (vp->v_usecount == 0 && ip->i_mode == 0)
#if defined(__FreeBSD__)
vrecycle(vp, (struct simplelock *)0, ap->a_p);
#else /* defined(__NetBSD__) */
vgone(vp);
#endif
return (error);
return (0);
}
/*
* Reclaim an inode so that it can be used for other purposes.
* Reclaim an fnode/ntnode so that it can be used for other purposes.
*/
int
ntfs_reclaim(ap)
@ -291,14 +283,12 @@ ntfs_reclaim(ap)
dprintf(("ntfs_reclaim: vnode: %p, ntnode: %d\n", vp, ip->i_number));
error = ntfs_ntget(ip);
if (error)
if (ntfs_prtactive && vp->v_usecount != 0)
vprint("ntfs_reclaim: pushing active", vp);
if ((error = ntfs_ntget(ip)) != 0)
return (error);
#if defined(__FreeBSD__)
VOP__UNLOCK(vp,0,ap->a_p);
#endif
/* Purge old data structures associated with the inode. */
cache_purge(vp);
if (ip->i_devvp) {
@ -306,10 +296,9 @@ ntfs_reclaim(ap)
ip->i_devvp = NULL;
}
vp->v_data = NULL;
ntfs_frele(fp);
ntfs_ntput(ip);
vp->v_data = NULL;
return (0);
}
@ -320,8 +309,6 @@ ntfs_print(ap)
struct vnode *a_vp;
} */ *ap;
{
/* printf("[ntfs_print]");*/
return (0);
}
@ -430,7 +417,7 @@ ntfs_write(ap)
dprintf(("ntfs_write: filesize: %d",(u_int32_t)fp->f_size));
if (uio->uio_resid + uio->uio_offset > fp->f_size) {
printf("ntfs_write: CAN'T WRITE BEYOND OF FILE\n");
printf("ntfs_write: CAN'T WRITE BEYOND END OF FILE\n");
return (EFBIG);
}
@ -440,12 +427,12 @@ ntfs_write(ap)
error = ntfs_writeattr_plain(ntmp, ip, fp->f_attrtype,
fp->f_attrname, uio->uio_offset, towrite, NULL, &written, uio);
if (error) {
printf("ntfs_write: ntfs_writeattr failed: %d\n",error);
return (error);
}
#ifdef NTFS_DEBUG
if (error)
printf("ntfs_write: ntfs_writeattr failed: %d\n", error);
#endif
return (0);
return (error);
}
int
@ -489,12 +476,6 @@ ntfs_access(ap)
}
}
/* If immutable bit set, nobody gets to write it. */
/*
if ((mode & VWRITE) && (ip->i_flags & IMMUTABLE))
return (EPERM);
*/
/* Otherwise, user id 0 always gets access. */
if (cred->cr_uid == 0)
return (0);
@ -502,26 +483,26 @@ ntfs_access(ap)
mask = 0;
/* Otherwise, check the owner. */
if (cred->cr_uid == ip->i_uid) {
if (cred->cr_uid == ip->i_mp->ntm_uid) {
if (mode & VEXEC)
mask |= S_IXUSR;
if (mode & VREAD)
mask |= S_IRUSR;
if (mode & VWRITE)
mask |= S_IWUSR;
return ((ip->i_mode & mask) == mask ? 0 : EACCES);
return ((ip->i_mp->ntm_mode & mask) == mask ? 0 : EACCES);
}
/* Otherwise, check the groups. */
for (i = 0, gp = cred->cr_groups; i < cred->cr_ngroups; i++, gp++)
if (ip->i_gid == *gp) {
if (ip->i_mp->ntm_gid == *gp) {
if (mode & VEXEC)
mask |= S_IXGRP;
if (mode & VREAD)
mask |= S_IRGRP;
if (mode & VWRITE)
mask |= S_IWGRP;
return ((ip->i_mode & mask) == mask ? 0 : EACCES);
return ((ip->i_mp->ntm_mode&mask) == mask ? 0 : EACCES);
}
/* Otherwise, check everyone else. */
@ -531,7 +512,7 @@ ntfs_access(ap)
mask |= S_IROTH;
if (mode & VWRITE)
mask |= S_IWOTH;
return ((ip->i_mode & mask) == mask ? 0 : EACCES);
return ((ip->i_mp->ntm_mode & mask) == mask ? 0 : EACCES);
}
/*
@ -799,7 +780,7 @@ ntfs_lookup(ap)
if (error) {
if (VN_LOCK(dvp,LK_EXCLUSIVE|LK_RETRY,cnp->cn_proc)==0)
cnp->cn_flags &= ~PDIRUNLOCK;
return(error);
return (error);
}
if (lockparent && (cnp->cn_flags & ISLASTCN)) {