Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/ntfs - Change ntfs_vgetex() to always load the ntnode...
details: https://anonhg.NetBSD.org/src/rev/2850ac3a53ed
branches: trunk
changeset: 333681:2850ac3a53ed
user: hannken <hannken%NetBSD.org@localhost>
date: Thu Nov 13 16:51:10 2014 +0000
description:
- Change ntfs_vgetex() to always load the ntnode and fnode.
- Take the vnode attributes from the NAME attribute.
- Remove now unused ntfs_times() and ntfs_filesize().
- Treat nodes without an unnamed DATA attribute as zero-sized regular files.
diffstat:
sys/fs/ntfs/ntfs_subr.c | 127 ++-------------------------------------------
sys/fs/ntfs/ntfs_subr.h | 5 +-
sys/fs/ntfs/ntfs_vfsops.c | 49 +++++++++++-----
sys/fs/ntfs/ntfs_vfsops.h | 11 +---
4 files changed, 42 insertions(+), 150 deletions(-)
diffs (truncated from 336 to 300 lines):
diff -r 886a7f265fca -r 2850ac3a53ed sys/fs/ntfs/ntfs_subr.c
--- a/sys/fs/ntfs/ntfs_subr.c Thu Nov 13 16:49:56 2014 +0000
+++ b/sys/fs/ntfs/ntfs_subr.c Thu Nov 13 16:51:10 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntfs_subr.c,v 1.52 2014/11/13 16:49:56 hannken Exp $ */
+/* $NetBSD: ntfs_subr.c,v 1.53 2014/11/13 16:51:10 hannken Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko (semenu%FreeBSD.org@localhost)
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.52 2014/11/13 16:49:56 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.53 2014/11/13 16:51:10 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -232,11 +232,8 @@
dprintf(("%s: attribute in ino: %d\n", __func__,
aalp->al_inumber));
- /* this is not a main record, so we can't use just plain
- vget() */
error = ntfs_vgetex(ntmp->ntm_mountp, aalp->al_inumber,
- NTFS_A_DATA, "", LK_EXCLUSIVE,
- VG_EXT, &newvp);
+ NTFS_A_DATA, "", LK_EXCLUSIVE, &newvp);
if (error) {
printf("%s: CAN'T VGET INO: %d\n", __func__,
aalp->al_inumber);
@@ -880,9 +877,7 @@
u_int32_t aoff;
int attrtype = NTFS_A_DATA;
char *attrname = NULL;
- struct fnode *nfp;
struct vnode *nvp;
- enum vtype f_type;
int fullscan = 0;
struct ntfs_lookup_ctx *lookup_ctx = NULL, *tctx;
@@ -989,11 +984,10 @@
goto fail;
}
- /* vget node, but don't load it */
+ /* vget node */
error = ntfs_vgetex(ntmp->ntm_mountp, iep->ie_number,
attrtype, attrname ? attrname : "",
- LK_EXCLUSIVE, VG_DONTLOADIN | VG_DONTVALIDFN,
- &nvp);
+ LK_EXCLUSIVE, &nvp);
/* free the buffer returned by ntfs_ntlookupattr() */
if (attrname) {
@@ -1004,45 +998,8 @@
if (error)
goto fail;
- nfp = VTOF(nvp);
-
- if (nfp->f_flag & FN_VALID) {
- *vpp = nvp;
- goto fail;
- }
-
- nfp->f_fflag = iep->ie_fflag;
- nfp->f_pnumber = iep->ie_fpnumber;
- nfp->f_times = iep->ie_ftimes;
-
- if((nfp->f_fflag & NTFS_FFLAG_DIR) &&
- (nfp->f_attrtype == NTFS_A_DATA) &&
- strcmp(nfp->f_attrname, "") == 0)
- f_type = VDIR;
- else
- f_type = VREG;
-
- nvp->v_type = f_type;
+ KASSERT(VTOF(nvp)->f_flag & FN_VALID);
- if ((nfp->f_attrtype == NTFS_A_DATA) &&
- strcmp(nfp->f_attrname, "") == 0)
- {
- /* Opening default attribute */
- nfp->f_size = iep->ie_fsize;
- nfp->f_allocated = iep->ie_fallocated;
- nfp->f_flag |= FN_PRELOADED;
- uvm_vnp_setsize(nvp, iep->ie_fsize);
- } else {
- error = ntfs_filesize(ntmp, nfp,
- &nfp->f_size, &nfp->f_allocated);
- if (error) {
- vput(nvp);
- goto fail;
- }
- uvm_vnp_setsize(nvp, nfp->f_size);
- }
-
- nfp->f_flag &= ~FN_VALID;
*vpp = nvp;
goto fail;
}
@@ -1337,78 +1294,6 @@
}
/*
- * Get file times from NTFS_A_NAME attribute.
- */
-int
-ntfs_times(
- struct ntfsmount * ntmp,
- struct ntnode * ip,
- ntfs_times_t * tm)
-{
- struct ntvattr *vap;
- int error;
-
- dprintf(("%s: ino: %llu...\n", __func__,
- (unsigned long long)ip->i_number));
-
- error = ntfs_ntget(ip);
- if (error)
- return (error);
-
- error = ntfs_ntvattrget(ntmp, ip, NTFS_A_NAME, NULL, 0, &vap);
- if (error) {
- ntfs_ntput(ip);
- return (error);
- }
- *tm = vap->va_a_name->n_times;
- ntfs_ntvattrrele(vap);
- ntfs_ntput(ip);
-
- return (0);
-}
-
-/*
- * Get file sizes from corresponding attribute.
- *
- * ntnode under fnode should be locked.
- */
-int
-ntfs_filesize(
- struct ntfsmount * ntmp,
- struct fnode * fp,
- u_int64_t * size,
- u_int64_t * bytes)
-{
- struct ntvattr *vap;
- struct ntnode *ip = FTONT(fp);
- u_int64_t sz, bn;
- int error;
-
- dprintf(("%s: ino: %llu\n", __func__,
- (unsigned long long)ip->i_number));
-
- error = ntfs_ntvattrget(ntmp, ip,
- fp->f_attrtype, fp->f_attrname, 0, &vap);
- if (error)
- return (error);
-
- bn = vap->va_allocated;
- sz = vap->va_datalen;
-
- dprintf(("%s: %d bytes (%d bytes allocated)\n", __func__,
- (u_int32_t) sz, (u_int32_t) bn));
-
- if (size)
- *size = sz;
- if (bytes)
- *bytes = bn;
-
- ntfs_ntvattrrele(vap);
-
- return (0);
-}
-
-/*
* This is one of write routine.
*/
int
diff -r 886a7f265fca -r 2850ac3a53ed sys/fs/ntfs/ntfs_subr.h
--- a/sys/fs/ntfs/ntfs_subr.h Thu Nov 13 16:49:56 2014 +0000
+++ b/sys/fs/ntfs/ntfs_subr.h Thu Nov 13 16:51:10 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntfs_subr.h,v 1.7 2014/11/13 16:49:56 hannken Exp $ */
+/* $NetBSD: ntfs_subr.h,v 1.8 2014/11/13 16:51:10 hannken Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
@@ -82,9 +82,6 @@
const char *, off_t, size_t, void *,size_t *, struct uio *);
int ntfs_readattr(struct ntfsmount *, struct ntnode *, u_int32_t,
const char *, off_t, size_t, void *, struct uio *);
-int ntfs_filesize(struct ntfsmount *, struct fnode *, u_int64_t *,
- u_int64_t *);
-int ntfs_times(struct ntfsmount *, struct ntnode *, ntfs_times_t *);
struct timespec ntfs_nttimetounix(u_int64_t);
int ntfs_ntreaddir(struct ntfsmount *, struct fnode *, u_int32_t,
struct attr_indexentry **);
diff -r 886a7f265fca -r 2850ac3a53ed sys/fs/ntfs/ntfs_vfsops.c
--- a/sys/fs/ntfs/ntfs_vfsops.c Thu Nov 13 16:49:56 2014 +0000
+++ b/sys/fs/ntfs/ntfs_vfsops.c Thu Nov 13 16:51:10 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntfs_vfsops.c,v 1.95 2014/11/13 16:49:56 hannken Exp $ */
+/* $NetBSD: ntfs_vfsops.c,v 1.96 2014/11/13 16:51:10 hannken Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.95 2014/11/13 16:49:56 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.96 2014/11/13 16:51:10 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -660,7 +660,7 @@
(unsigned long long)ntfh.ntfid_ino));
error = ntfs_vgetex(mp, ntfh.ntfid_ino, ntfh.ntfid_attr, "",
- LK_EXCLUSIVE, 0, vpp);
+ LK_EXCLUSIVE, vpp);
if (error != 0) {
*vpp = NULLVP;
return (error);
@@ -710,7 +710,6 @@
u_int32_t attrtype,
const char *attrname,
u_long lkflags,
- u_long flags,
struct vnode **vpp)
{
int error;
@@ -720,9 +719,8 @@
struct vnode *vp;
enum vtype f_type = VBAD;
- dprintf(("ntfs_vgetex: ino: %llu, attr: 0x%x:%s, lkf: 0x%lx, f:"
- " 0x%lx\n", (unsigned long long)ino, attrtype,
- attrname, (u_long)lkflags, (u_long)flags));
+ dprintf(("ntfs_vgetex: ino: %llu, attr: 0x%x:%s, lkf: 0x%lx\n", (unsigned long long)ino, attrtype,
+ attrname, (u_long)lkflags));
ntmp = VFSTONTFS(mp);
*vpp = NULL;
@@ -736,7 +734,7 @@
}
/* It may be not initialized fully, so force load it */
- if (!(flags & VG_DONTLOADIN) && !(ip->i_flag & IN_LOADED)) {
+ if (!(ip->i_flag & IN_LOADED)) {
error = ntfs_loadntnode(ntmp, ip);
if(error) {
printf("ntfs_vget: CAN'T LOAD ATTRIBUTES FOR INO:"
@@ -753,20 +751,39 @@
return (error);
}
- if (!(flags & VG_DONTVALIDFN) && !(fp->f_flag & FN_VALID)) {
+ if (!(fp->f_flag & FN_VALID)) {
+ struct ntvattr *vap;
+
+ error = ntfs_ntvattrget(ntmp, ip, NTFS_A_NAME, NULL, 0, &vap);
+ if (error) {
+ ntfs_ntput(ip);
+ return error;
+ }
+ fp->f_fflag = vap->va_a_name->n_flag;
+ fp->f_pnumber = vap->va_a_name->n_pnumber;
+ fp->f_times = vap->va_a_name->n_times;
+ ntfs_ntvattrrele(vap);
+
if ((ip->i_frflag & NTFS_FRFLAG_DIR) &&
(fp->f_attrtype == NTFS_A_DATA &&
strcmp(fp->f_attrname, "") == 0)) {
f_type = VDIR;
- } else if (flags & VG_EXT) {
- f_type = VNON;
- fp->f_size = fp->f_allocated = 0;
} else {
f_type = VREG;
- error = ntfs_filesize(ntmp, fp,
- &fp->f_size, &fp->f_allocated);
- if (error) {
+ error = ntfs_ntvattrget(ntmp, ip,
+ fp->f_attrtype, fp->f_attrname, 0, &vap);
+ if (error == 0) {
+ fp->f_size = vap->va_datalen;
+ fp->f_allocated = vap->va_allocated;
+ ntfs_ntvattrrele(vap);
+ } else if (fp->f_attrtype == NTFS_A_DATA &&
+ strcmp(fp->f_attrname, "") == 0 &&
+ error == ENOENT) {
+ fp->f_size = 0;
+ fp->f_allocated = 0;
+ error = 0;
+ } else {
Home |
Main Index |
Thread Index |
Old Index