- 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.
This commit is contained in:
parent
6f8e2ffe40
commit
a26eea283a
|
@ -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)
|
||||
|
@ -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 @@ ntfs_ntvattrget(
|
|||
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 @@ ntfs_ntlookupfile(
|
|||
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 @@ ntfs_ntlookupfile(
|
|||
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 @@ ntfs_ntlookupfile(
|
|||
if (error)
|
||||
goto fail;
|
||||
|
||||
nfp = VTOF(nvp);
|
||||
KASSERT(VTOF(nvp)->f_flag & FN_VALID);
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -1336,78 +1293,6 @@ ntfs_nttimetounix(
|
|||
return (t);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
|
|
@ -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 @@ int ntfs_readattr_plain(struct ntfsmount *, struct ntnode *, u_int32_t,
|
|||
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 **);
|
||||
|
|
|
@ -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 @@ ntfs_fhtovp(
|
|||
(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 @@ ntfs_vgetex(
|
|||
u_int32_t attrtype,
|
||||
const char *attrname,
|
||||
u_long lkflags,
|
||||
u_long flags,
|
||||
struct vnode **vpp)
|
||||
{
|
||||
int error;
|
||||
|
@ -720,9 +719,8 @@ ntfs_vgetex(
|
|||
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 @@ loop:
|
|||
}
|
||||
|
||||
/* 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 @@ loop:
|
|||
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 {
|
||||
ntfs_ntput(ip);
|
||||
return (error);
|
||||
}
|
||||
|
@ -850,7 +867,7 @@ ntfs_vget(
|
|||
ino_t ino,
|
||||
struct vnode **vpp)
|
||||
{
|
||||
return ntfs_vgetex(mp, ino, NTFS_A_DATA, "", LK_EXCLUSIVE, 0, vpp);
|
||||
return ntfs_vgetex(mp, ino, NTFS_A_DATA, "", LK_EXCLUSIVE, vpp);
|
||||
}
|
||||
|
||||
extern const struct vnodeopv_desc ntfs_vnodeop_opv_desc;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ntfs_vfsops.h,v 1.8 2014/11/13 16:49:56 hannken Exp $ */
|
||||
/* $NetBSD: ntfs_vfsops.h,v 1.9 2014/11/13 16:51:10 hannken Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
|
||||
|
@ -31,13 +31,6 @@
|
|||
#error not supposed to be exposed to userland.
|
||||
#endif
|
||||
|
||||
#define VG_DONTLOADIN 0x0001 /* Tells ntfs_vgetex to do not call */
|
||||
/* ntfs_loadntnode() on ntnode, even if */
|
||||
/* ntnode not loaded */
|
||||
#define VG_DONTVALIDFN 0x0002 /* Tells ntfs_vgetex to do not validate */
|
||||
/* fnode */
|
||||
#define VG_EXT 0x0004 /* This is not main record */
|
||||
|
||||
int ntfs_vgetex(struct mount *, ino_t, u_int32_t, const char *, u_long, u_long,
|
||||
int ntfs_vgetex(struct mount *, ino_t, u_int32_t, const char *, u_long,
|
||||
struct vnode **);
|
||||
int ntfs_calccfree(struct ntfsmount *, cn_t *);
|
||||
|
|
Loading…
Reference in New Issue