1999-10-02 04:06:24 +00:00
|
|
|
/*
|
2000-10-02 09:29:59 +00:00
|
|
|
* Copyright (c) 1999, 2000 Boris Popov
|
1999-10-02 04:06:24 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Boris Popov.
|
|
|
|
* 4. Neither the name of the author nor the names of any co-contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/lock.h>
|
1999-10-02 04:06:24 +00:00
|
|
|
#include <sys/malloc.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/mutex.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/queue.h>
|
1999-10-02 04:06:24 +00:00
|
|
|
#include <sys/sysctl.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
|
1999-10-02 04:06:24 +00:00
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/vm_extern.h>
|
|
|
|
#include <vm/vm_page.h>
|
|
|
|
#include <vm/vm_object.h>
|
|
|
|
|
|
|
|
#include <netncp/ncp.h>
|
|
|
|
#include <netncp/ncp_conn.h>
|
|
|
|
#include <netncp/ncp_subr.h>
|
|
|
|
|
2001-05-26 11:57:45 +00:00
|
|
|
#include <fs/nwfs/nwfs.h>
|
|
|
|
#include <fs/nwfs/nwfs_mount.h>
|
|
|
|
#include <fs/nwfs/nwfs_node.h>
|
|
|
|
#include <fs/nwfs/nwfs_subr.h>
|
1999-10-02 04:06:24 +00:00
|
|
|
|
|
|
|
#define NWNOHASH(fhsum) (&nwhashtbl[(fhsum.f_id) & nwnodehash])
|
|
|
|
|
|
|
|
extern vop_t **nwfs_vnodeop_p;
|
|
|
|
|
2000-05-26 02:09:24 +00:00
|
|
|
static LIST_HEAD(nwnode_hash_head,nwnode) *nwhashtbl;
|
1999-10-02 04:06:24 +00:00
|
|
|
static u_long nwnodehash;
|
2000-10-02 09:49:04 +00:00
|
|
|
static struct lock nwhashlock;
|
1999-10-02 04:06:24 +00:00
|
|
|
|
|
|
|
MALLOC_DEFINE(M_NWNODE, "NWFS node", "NWFS vnode private part");
|
|
|
|
MALLOC_DEFINE(M_NWFSHASH, "NWFS hash", "NWFS has table");
|
|
|
|
|
2000-07-04 11:25:35 +00:00
|
|
|
static int nwfs_sysctl_vnprint(SYSCTL_HANDLER_ARGS);
|
1999-10-02 04:06:24 +00:00
|
|
|
|
|
|
|
SYSCTL_DECL(_vfs_nwfs);
|
|
|
|
|
|
|
|
SYSCTL_PROC(_vfs_nwfs, OID_AUTO, vnprint, CTLFLAG_WR|CTLTYPE_OPAQUE,
|
|
|
|
NULL, 0, nwfs_sysctl_vnprint, "S,vnlist", "vnode hash");
|
|
|
|
|
|
|
|
void
|
2000-10-02 09:49:04 +00:00
|
|
|
nwfs_hash_init(void) {
|
1999-10-02 04:06:24 +00:00
|
|
|
nwhashtbl = hashinit(desiredvnodes, M_NWFSHASH, &nwnodehash);
|
2000-10-02 09:49:04 +00:00
|
|
|
lockinit(&nwhashlock, PVFS, "nwfshl", 0, 0);
|
1999-10-02 04:06:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-10-02 09:49:04 +00:00
|
|
|
nwfs_hash_free(void) {
|
2000-10-04 01:29:17 +00:00
|
|
|
lockdestroy(&nwhashlock);
|
1999-10-02 04:06:24 +00:00
|
|
|
free(nwhashtbl, M_NWFSHASH);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2000-10-02 09:49:04 +00:00
|
|
|
nwfs_sysctl_vnprint(SYSCTL_HANDLER_ARGS) {
|
1999-10-02 04:06:24 +00:00
|
|
|
struct nwnode *np;
|
|
|
|
struct nwnode_hash_head *nhpp;
|
|
|
|
struct vnode *vp;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (nwfs_debuglevel == 0)
|
|
|
|
return 0;
|
|
|
|
printf("Name:uc:hc:fid:pfid\n");
|
|
|
|
for(i = 0; i <= nwnodehash; i++) {
|
|
|
|
nhpp = &nwhashtbl[i];
|
2001-02-04 13:13:25 +00:00
|
|
|
LIST_FOREACH(np, nhpp, n_hash) {
|
1999-10-02 04:06:24 +00:00
|
|
|
vp = NWTOV(np);
|
2000-10-02 09:49:04 +00:00
|
|
|
vprint(NULL, vp);
|
1999-10-02 04:06:24 +00:00
|
|
|
printf("%s:%d:%d:%d:%d\n",np->n_name,vp->v_usecount,vp->v_holdcnt,
|
|
|
|
np->n_fid.f_id, np->n_fid.f_parent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-10-02 09:49:04 +00:00
|
|
|
/*
|
|
|
|
* Search nwnode with given fid.
|
|
|
|
* Hash list should be locked by caller.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
nwfs_hashlookup(struct nwmount *nmp, ncpfid fid, struct nwnode **npp)
|
|
|
|
{
|
|
|
|
struct nwnode *np;
|
|
|
|
struct nwnode_hash_head *nhpp;
|
|
|
|
|
|
|
|
nhpp = NWNOHASH(fid);
|
|
|
|
LIST_FOREACH(np, nhpp, n_hash) {
|
|
|
|
if (nmp != np->n_mount || !NWCMPF(&fid, &np->n_fid))
|
|
|
|
continue;
|
|
|
|
if (npp)
|
|
|
|
*npp = np;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return ENOENT;
|
|
|
|
}
|
|
|
|
|
1999-10-02 04:06:24 +00:00
|
|
|
/*
|
|
|
|
* Allocate new nwfsnode/vnode from given nwnode.
|
|
|
|
* Vnode referenced and not locked.
|
|
|
|
*/
|
2001-03-10 05:39:03 +00:00
|
|
|
static int
|
|
|
|
nwfs_allocvp(struct mount *mp, ncpfid fid, struct nw_entry_info *fap,
|
|
|
|
struct vnode *dvp, struct vnode **vpp)
|
2000-10-02 09:29:59 +00:00
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td = curthread; /* XXX */
|
2000-10-02 09:49:04 +00:00
|
|
|
struct nwnode *np;
|
1999-10-02 04:06:24 +00:00
|
|
|
struct nwnode_hash_head *nhpp;
|
2000-10-02 09:49:04 +00:00
|
|
|
struct nwmount *nmp = VFSTONWFS(mp);
|
1999-10-02 04:06:24 +00:00
|
|
|
struct vnode *vp;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
loop:
|
2001-09-12 08:38:13 +00:00
|
|
|
lockmgr(&nwhashlock, LK_EXCLUSIVE, NULL, td);
|
2000-10-02 09:49:04 +00:00
|
|
|
rescan:
|
|
|
|
if (nwfs_hashlookup(nmp, fid, &np) == 0) {
|
1999-10-02 04:06:24 +00:00
|
|
|
vp = NWTOV(np);
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
mtx_lock(&vp->v_interlock);
|
2001-09-12 08:38:13 +00:00
|
|
|
lockmgr(&nwhashlock, LK_RELEASE, NULL, td);
|
|
|
|
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td))
|
1999-10-02 04:06:24 +00:00
|
|
|
goto loop;
|
2001-03-10 05:39:03 +00:00
|
|
|
if (fap)
|
|
|
|
np->n_attr = fap->attributes;
|
1999-10-02 04:06:24 +00:00
|
|
|
*vpp = vp;
|
|
|
|
return(0);
|
|
|
|
}
|
2001-09-12 08:38:13 +00:00
|
|
|
lockmgr(&nwhashlock, LK_RELEASE, NULL, td);
|
1999-10-02 04:06:24 +00:00
|
|
|
|
2001-03-10 05:39:03 +00:00
|
|
|
if (fap == NULL || ((fap->attributes & aDIR) == 0 && dvp == NULL))
|
|
|
|
panic("nwfs_allocvp: fap = %p, dvp = %p\n", fap, dvp);
|
1999-10-02 04:06:24 +00:00
|
|
|
/*
|
|
|
|
* Do the MALLOC before the getnewvnode since doing so afterward
|
|
|
|
* might cause a bogus v_data pointer to get dereferenced
|
|
|
|
* elsewhere if MALLOC should block.
|
|
|
|
*/
|
2000-10-29 16:14:28 +00:00
|
|
|
MALLOC(np, struct nwnode *, sizeof *np, M_NWNODE, M_WAITOK | M_ZERO);
|
1999-10-02 04:06:24 +00:00
|
|
|
error = getnewvnode(VT_NWFS, mp, nwfs_vnodeop_p, &vp);
|
|
|
|
if (error) {
|
2000-10-02 09:49:04 +00:00
|
|
|
*vpp = NULL;
|
1999-10-02 04:06:24 +00:00
|
|
|
FREE(np, M_NWNODE);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
vp->v_data = np;
|
|
|
|
np->n_vnode = vp;
|
2000-10-02 09:49:04 +00:00
|
|
|
np->n_mount = nmp;
|
2001-03-10 05:39:03 +00:00
|
|
|
np->n_attr = fap->attributes;
|
|
|
|
vp->v_type = np->n_attr & aDIR ? VDIR : VREG;
|
|
|
|
np->n_fid = fid;
|
|
|
|
if (dvp) {
|
|
|
|
np->n_parent = VTONW(dvp)->n_fid;
|
|
|
|
}
|
2001-12-20 22:42:27 +00:00
|
|
|
lockinit(&vp->v_lock, PINOD, "nwnode", VLKTIMEOUT, LK_CANRECURSE);
|
2001-09-12 08:38:13 +00:00
|
|
|
lockmgr(&nwhashlock, LK_EXCLUSIVE, NULL, td);
|
2000-10-02 09:49:04 +00:00
|
|
|
/*
|
|
|
|
* Another process can create vnode while we blocked in malloc() or
|
|
|
|
* getnewvnode(). Rescan list again.
|
|
|
|
*/
|
|
|
|
if (nwfs_hashlookup(nmp, fid, NULL) == 0) {
|
|
|
|
vp->v_data = NULL;
|
|
|
|
np->n_vnode = NULL;
|
1999-10-02 04:06:24 +00:00
|
|
|
vrele(vp);
|
|
|
|
FREE(np, M_NWNODE);
|
2000-10-02 09:49:04 +00:00
|
|
|
goto rescan;
|
1999-10-02 04:06:24 +00:00
|
|
|
}
|
2000-10-02 09:49:04 +00:00
|
|
|
*vpp = vp;
|
|
|
|
nhpp = NWNOHASH(fid);
|
1999-10-02 04:06:24 +00:00
|
|
|
LIST_INSERT_HEAD(nhpp, np, n_hash);
|
2001-09-12 08:38:13 +00:00
|
|
|
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
|
|
|
|
lockmgr(&nwhashlock, LK_RELEASE, NULL, td);
|
2001-03-10 05:39:03 +00:00
|
|
|
|
|
|
|
if (vp->v_type == VDIR && dvp && (dvp->v_flag & VROOT) == 0) {
|
|
|
|
np->n_flag |= NREFPARENT;
|
|
|
|
vref(dvp);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
nwfs_nget(struct mount *mp, ncpfid fid, struct nw_entry_info *fap,
|
|
|
|
struct vnode *dvp, struct vnode **vpp)
|
|
|
|
{
|
|
|
|
struct vnode *vp;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
*vpp = NULL;
|
|
|
|
error = nwfs_allocvp(mp, fid, fap, dvp, &vp);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
if (fap)
|
|
|
|
nwfs_attr_cacheenter(vp, fap);
|
|
|
|
*vpp = vp;
|
2000-10-02 09:49:04 +00:00
|
|
|
return 0;
|
1999-10-02 04:06:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
nwfs_lookupnp(struct nwmount *nmp, ncpfid fid, struct thread *td,
|
2000-10-02 09:49:04 +00:00
|
|
|
struct nwnode **npp)
|
2000-10-02 09:29:59 +00:00
|
|
|
{
|
2000-10-02 09:49:04 +00:00
|
|
|
int error;
|
1999-10-02 04:06:24 +00:00
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
lockmgr(&nwhashlock, LK_EXCLUSIVE, NULL, td);
|
2000-10-02 09:49:04 +00:00
|
|
|
error = nwfs_hashlookup(nmp, fid, npp);
|
2001-09-12 08:38:13 +00:00
|
|
|
lockmgr(&nwhashlock, LK_RELEASE, NULL, td);
|
2000-10-02 09:49:04 +00:00
|
|
|
return error;
|
1999-10-02 04:06:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free nwnode, and give vnode back to system
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
nwfs_reclaim(ap)
|
|
|
|
struct vop_reclaim_args /* {
|
2000-10-02 09:49:04 +00:00
|
|
|
struct vnode *a_vp;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *a_td;
|
1999-10-02 04:06:24 +00:00
|
|
|
} */ *ap;
|
|
|
|
{
|
|
|
|
struct vnode *dvp = NULL, *vp = ap->a_vp;
|
|
|
|
struct nwnode *dnp, *np = VTONW(vp);
|
2000-10-02 09:49:04 +00:00
|
|
|
struct nwmount *nmp = VTONWFS(vp);
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td = ap->a_td;
|
1999-10-02 04:06:24 +00:00
|
|
|
|
|
|
|
NCPVNDEBUG("%s,%d\n", np->n_name, vp->v_usecount);
|
2001-03-10 05:39:03 +00:00
|
|
|
if (np->n_flag & NREFPARENT) {
|
|
|
|
np->n_flag &= ~NREFPARENT;
|
2001-09-12 08:38:13 +00:00
|
|
|
if (nwfs_lookupnp(nmp, np->n_parent, td, &dnp) == 0) {
|
1999-10-02 04:06:24 +00:00
|
|
|
dvp = dnp->n_vnode;
|
|
|
|
} else {
|
|
|
|
NCPVNDEBUG("%s: has no parent ?\n",np->n_name);
|
|
|
|
}
|
|
|
|
}
|
2001-09-12 08:38:13 +00:00
|
|
|
lockmgr(&nwhashlock, LK_EXCLUSIVE, NULL, td);
|
1999-10-02 04:06:24 +00:00
|
|
|
LIST_REMOVE(np, n_hash);
|
2001-09-12 08:38:13 +00:00
|
|
|
lockmgr(&nwhashlock, LK_RELEASE, NULL, td);
|
1999-10-02 04:06:24 +00:00
|
|
|
cache_purge(vp);
|
|
|
|
if (nmp->n_root == np) {
|
|
|
|
nmp->n_root = NULL;
|
|
|
|
}
|
|
|
|
vp->v_data = NULL;
|
|
|
|
FREE(np, M_NWNODE);
|
|
|
|
if (dvp) {
|
|
|
|
vrele(dvp);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
nwfs_inactive(ap)
|
|
|
|
struct vop_inactive_args /* {
|
|
|
|
struct vnode *a_vp;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *a_td;
|
1999-10-02 04:06:24 +00:00
|
|
|
} */ *ap;
|
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td = ap->a_td;
|
2002-02-27 18:32:23 +00:00
|
|
|
struct ucred *cred = td->td_ucred;
|
1999-10-02 04:06:24 +00:00
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct nwnode *np = VTONW(vp);
|
|
|
|
int error;
|
|
|
|
|
|
|
|
NCPVNDEBUG("%s: %d\n", VTONW(vp)->n_name, vp->v_usecount);
|
|
|
|
if (np->opened) {
|
2001-09-12 08:38:13 +00:00
|
|
|
error = nwfs_vinvalbuf(vp, V_SAVE, cred, td, 1);
|
|
|
|
error = ncp_close_file(NWFSTOCONN(VTONWFS(vp)), &np->n_fh, td, cred);
|
1999-10-02 04:06:24 +00:00
|
|
|
np->opened = 0;
|
|
|
|
}
|
2001-09-12 08:38:13 +00:00
|
|
|
VOP_UNLOCK(vp, 0, td);
|
2000-10-02 09:49:04 +00:00
|
|
|
if (np->n_flag & NSHOULDFREE) {
|
|
|
|
cache_purge(vp);
|
|
|
|
vgone(vp);
|
|
|
|
}
|
1999-10-02 04:06:24 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* routines to maintain vnode attributes cache
|
|
|
|
* nwfs_attr_cacheenter: unpack np.i to va structure
|
|
|
|
*/
|
|
|
|
void
|
2000-10-02 09:29:59 +00:00
|
|
|
nwfs_attr_cacheenter(struct vnode *vp, struct nw_entry_info *fi)
|
|
|
|
{
|
1999-10-02 04:06:24 +00:00
|
|
|
struct nwnode *np = VTONW(vp);
|
|
|
|
struct nwmount *nmp = VTONWFS(vp);
|
2000-10-02 09:29:59 +00:00
|
|
|
struct vattr *va = &np->n_vattr;
|
1999-10-02 04:06:24 +00:00
|
|
|
|
|
|
|
va->va_type = vp->v_type; /* vnode type (for create) */
|
2001-03-06 09:59:18 +00:00
|
|
|
np->n_nmlen = fi->nameLen;
|
|
|
|
bcopy(fi->entryName, np->n_name, np->n_nmlen);
|
|
|
|
np->n_name[fi->nameLen] = 0;
|
1999-10-02 04:06:24 +00:00
|
|
|
if (vp->v_type == VREG) {
|
|
|
|
if (va->va_size != fi->dataStreamSize) {
|
|
|
|
va->va_size = fi->dataStreamSize;
|
|
|
|
vnode_pager_setsize(vp, va->va_size);
|
|
|
|
}
|
|
|
|
va->va_mode = nmp->m.file_mode; /* files access mode and type */
|
|
|
|
} else if (vp->v_type == VDIR) {
|
|
|
|
va->va_size = 16384; /* should be a better way ... */
|
|
|
|
va->va_mode = nmp->m.dir_mode; /* files access mode and type */
|
|
|
|
} else
|
|
|
|
return;
|
|
|
|
np->n_size = va->va_size;
|
|
|
|
va->va_nlink = 1; /* number of references to file */
|
|
|
|
va->va_uid = nmp->m.uid; /* owner user id */
|
|
|
|
va->va_gid = nmp->m.gid; /* owner group id */
|
|
|
|
va->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0];
|
|
|
|
va->va_fileid = np->n_fid.f_id; /* file id */
|
|
|
|
if (va->va_fileid == 0)
|
|
|
|
va->va_fileid = NWFS_ROOT_INO;
|
|
|
|
va->va_blocksize=nmp->connh->nh_conn->buffer_size;/* blocksize preferred for i/o */
|
|
|
|
/* time of last modification */
|
2000-04-05 10:44:04 +00:00
|
|
|
ncp_dos2unixtime(fi->modifyDate, fi->modifyTime, 0, nmp->m.tz, &va->va_mtime);
|
1999-10-02 04:06:24 +00:00
|
|
|
/* time of last access */
|
2000-04-05 10:44:04 +00:00
|
|
|
ncp_dos2unixtime(fi->lastAccessDate, 0, 0, nmp->m.tz, &va->va_atime);
|
1999-10-02 04:06:24 +00:00
|
|
|
va->va_ctime = va->va_mtime; /* time file changed */
|
|
|
|
va->va_gen = VNOVAL; /* generation number of file */
|
|
|
|
va->va_flags = 0; /* flags defined for file */
|
|
|
|
va->va_rdev = VNOVAL; /* device the special file represents */
|
|
|
|
va->va_bytes = va->va_size; /* bytes of disk space held by file */
|
|
|
|
va->va_filerev = 0; /* file modification number */
|
|
|
|
va->va_vaflags = 0; /* operations flags */
|
|
|
|
np->n_vattr = *va;
|
|
|
|
if (np->n_mtime == 0) {
|
|
|
|
np->n_mtime = va->va_mtime.tv_sec;
|
|
|
|
}
|
|
|
|
np->n_atime = time_second;
|
2001-03-06 09:59:18 +00:00
|
|
|
np->n_dosfid = fi->DosDirNum;
|
1999-10-02 04:06:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2000-10-02 09:29:59 +00:00
|
|
|
nwfs_attr_cachelookup(struct vnode *vp, struct vattr *va)
|
|
|
|
{
|
1999-10-02 04:06:24 +00:00
|
|
|
struct nwnode *np = VTONW(vp);
|
|
|
|
int diff;
|
|
|
|
|
|
|
|
diff = time_second - np->n_atime;
|
|
|
|
if (diff > 2) { /* XXX should be configurable */
|
|
|
|
return ENOENT;
|
|
|
|
}
|
|
|
|
*va = np->n_vattr;
|
|
|
|
return 0;
|
|
|
|
}
|