1139776Simp/*-
274064Sbp * Copyright (c) 1999, 2000, 2001 Boris Popov
351852Sbp * All rights reserved.
451852Sbp *
551852Sbp * Redistribution and use in source and binary forms, with or without
651852Sbp * modification, are permitted provided that the following conditions
751852Sbp * are met:
851852Sbp * 1. Redistributions of source code must retain the above copyright
951852Sbp *    notice, this list of conditions and the following disclaimer.
1051852Sbp * 2. Redistributions in binary form must reproduce the above copyright
1151852Sbp *    notice, this list of conditions and the following disclaimer in the
1251852Sbp *    documentation and/or other materials provided with the distribution.
1351852Sbp *
1451852Sbp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1551852Sbp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1651852Sbp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1751852Sbp * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1851852Sbp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1951852Sbp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2051852Sbp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2151852Sbp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2251852Sbp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2351852Sbp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2451852Sbp * SUCH DAMAGE.
2551852Sbp *
2651852Sbp * $FreeBSD$
2751852Sbp */
2851852Sbp#ifndef _NWFS_NODE_H_
2951852Sbp#define _NWFS_NODE_H_
3051852Sbp
3151852Sbp#define	NWFS_ROOT_INO	0x7ffffffd
3251852Sbp
3351852Sbp/* Bits for nwnode.n_flag */
3451852Sbp#define	NFLUSHINPROG	0x0001
3551852Sbp#define	NFLUSHWANT	0x0002		/* they should gone ... */
3651852Sbp#define	NMODIFIED	0x0004		/* bogus, until async IO implemented */
3774064Sbp#define	NREFPARENT	0x0008		/* vnode holds reference to a parent vnode */
3851852Sbp#define	NVOLUME		0x0010		/* vnode references a volume */
3966540Sbp#define	NSHOULDFREE	0x0020		/* vnode should be removed from hash */
4051852Sbp
4151852Sbpstruct nwnode {
4260938Sjake	LIST_ENTRY(nwnode)	n_hash;
4351852Sbp	struct vnode 		*n_vnode;
4451852Sbp	struct vattr		n_vattr;
4551852Sbp	struct nwmount		*n_mount;
4651852Sbp	time_t			n_atime;	/* attributes cache time*/
4751852Sbp	time_t			n_ctime;
4851852Sbp	time_t			n_mtime;
4951852Sbp	int			n_flag;
5051852Sbp	ncpfid			n_parent;
5151852Sbp	ncpfid			n_fid;
5251852Sbp	u_long			n_attr;		/* LH */
5351852Sbp	u_long			n_size;
5451852Sbp	u_long			n_dosfid;
5551852Sbp	int 			opened;
5651852Sbp/*	int 			access;*/
5751852Sbp	u_long 			n_origfh;
5851852Sbp	ncp_fh			n_fh;
5951852Sbp	struct nw_search_seq	n_seq;
6051852Sbp	u_char			n_nmlen;
6151852Sbp	u_char			n_name[256];
6251852Sbp};
6351852Sbp
6451852Sbp#define VTONW(vp)	((struct nwnode *)(vp)->v_data)
6551852Sbp#define NWTOV(np)	((struct vnode *)(np)->n_vnode)
6651852Sbp#define	NWCMPF(f1,f2)	((f1)->f_parent == (f2)->f_parent && \
6751852Sbp			 (f1)->f_id == (f2)->f_id)
6851852Sbp#define	NWCMPN(np1,np2)	NWCMPF(&(np1)->n_fid, &(np2)->n_fid)
6951852Sbp#define NWCMPV(vp1,vp2)	NWCMPN(VTONW(vp1),VTONW(vp2))
7051852Sbp
7155991Sbdestruct vop_getpages_args;
7255991Sbdestruct vop_inactive_args;
7355991Sbdestruct vop_putpages_args;
7455991Sbdestruct vop_reclaim_args;
7555991Sbdestruct ucred;
7655991Sbdestruct uio;
7755991Sbde
7851852Sbpvoid nwfs_hash_init(void);
7951852Sbpvoid nwfs_hash_free(void);
8083366Sjulianint  nwfs_lookupnp(struct nwmount *nmp, ncpfid fid, struct thread *td,
8166540Sbp	struct nwnode **npp);
8266539Sbpint  nwfs_inactive(struct vop_inactive_args *);
8366539Sbpint  nwfs_reclaim(struct vop_reclaim_args *);
8474064Sbpint  nwfs_nget(struct mount *mp, ncpfid fid, struct nw_entry_info *fap,
8574064Sbp	struct vnode *dvp, struct vnode **vpp);
8651852Sbp
8766539Sbpint  nwfs_getpages(struct vop_getpages_args *);
8866539Sbpint  nwfs_putpages(struct vop_putpages_args *);
8951852Sbpint  nwfs_readvnode(struct vnode *vp, struct uio *uiop, struct ucred *cred);
9051852Sbpint  nwfs_writevnode(struct vnode *vp, struct uio *uiop, struct ucred *cred, int ioflag);
9151852Sbpvoid nwfs_attr_cacheenter(struct vnode *vp, struct nw_entry_info *fi);
9251852Sbpint  nwfs_attr_cachelookup(struct vnode *vp,struct vattr *va);
9351852Sbp
9451852Sbp#define nwfs_attr_cacheremove(vp)	VTONW(vp)->n_atime = 0
9551852Sbp
9651852Sbp#endif /* _NWFS_NODE_H_ */
97