Blame | Last modification | View Log | RSS feed
/*
* Copyright (c) 1989, 1993, 1995
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Rick Macklem at The University of Guelph.
*
* 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 the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)nfs.h 8.4 (Berkeley) 5/1/95
* $Id: nfs.h,v 1.44 1998/09/07 05:42:15 bde Exp $
*/
#ifndef _9FS_H_
#define _9FS_H_
#ifdef KERNEL
#include "opt_u9fs.h"
#endif
#define U9FS_FABLKSIZE 512
#define U9FS_PORT 17008
/*
* The set of signals the interrupt an I/O in progress for U9FSMNT_INT mounts.
* What should be in this set is open to debate, but I believe that since
* I/O system calls on ufs are never interrupted by signals the set should
* be minimal. My reasoning is that many current programs that use signals
* such as SIGALRM will not expect file I/O system calls to be interrupted
* by them and break.
*/
#define U9FSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
sigmask(SIGHUP)|sigmask(SIGQUIT))
/*
* U9FS mount option flags
*/
#define U9FSMNT_SOFT 0x00000001 /* soft mount (hard is default) */
#define U9FSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */
#define U9FSMNT_INT 0x00000040 /* allow interrupts on hard mount */
#define U9FSMNT_KERB 0x00000400 /* Use Kerberos authentication */
#define U9FSMNT_READAHEAD 0x00002000 /* set read ahead */
#define U9FSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
#define U9FSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
#define U9FSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
#define U9FSSTA_MNTD 0x00200000 /* Mnt server for mnt point */
#define U9FSSTA_DISMINPROG 0x00400000 /* Dismount in progress */
#define U9FSSTA_DISMNT 0x00800000 /* Dismounted */
#define U9FSSTA_SNDLOCK 0x01000000 /* Send socket lock */
#define U9FSSTA_WANTSND 0x02000000 /* Want above */
#define U9FSSTA_RCVLOCK 0x04000000 /* Rcv socket lock */
#define U9FSSTA_WANTRCV 0x08000000 /* Want above */
#define U9FSSTA_WAITAUTH 0x10000000 /* Wait for authentication */
#define U9FSSTA_HASAUTH 0x20000000 /* Has authenticator */
#define U9FSSTA_WANTAUTH 0x40000000 /* Wants an authenticator */
#define U9FSSTA_AUTHERR 0x80000000 /* Authentication error */
#define U9FSNOHASH(fhsum) (&u9fsnodehashtbl[(fhsum) % u9fsnodehash])
/*
* Arguments to mount 9FS
*/
#define U9FS_ARGSVERSION 1 /* change when nfs_args changes */
struct u9fs_args {
int version; /* args structure version number */
struct sockaddr *addr; /* file server address */
int addrlen; /* length of address */
int sotype; /* Socket type */
int proto; /* and Protocol */
int fhsize; /* Size, in bytes, of fh */
int flags; /* flags */
int wsize; /* write size in bytes */
int rsize; /* read size in bytes */
int readdirsize; /* readdir size in bytes */
char *hostname; /* server's name */
struct sockaddr * authaddr;
int authaddrlen;
int authsotype;
int authsoproto;
int nusers;
char user[U9FS_NAMELEN];
char key[U9AUTH_DESKEYLEN];
struct p9user {
uid_t p9_uid;
char p9_name[U9FS_NAMELEN];
} * users;
};
#define U9FS_USER_HASHSIZE 512
struct u9fsuser {
LIST_ENTRY(u9fsuser) u_hash;
uid_t u_uid;
char u_name[U9FS_NAMELEN];
char u_ckey[U9AUTH_DESKEYLEN]; /* user key */
char u_skey[U9AUTH_DESKEYLEN]; /* session key */
};
/*
* The u9fsnode is the u9fs equivalent to ufs's inode. Any similarity
* is purely coincidental.
* There is a unique u9fsnode allocated for each active file,
* each current directory, each mounted-on file, text file, and the root.
* An u9fsnode is 'named' by its file handle. (nget/u9fs_node.c)
* If this structure exceeds 256 bytes (it is currently 256 using 4.4BSD-Lite
* type definitions), file handles of > 32 bytes should probably be split out
* into a separate MALLOC()'d data structure. (Reduce the size of u9fsfh_t by
* changing the definition in u9fsproto.h of U9FS_SMALLFH.)
* NB: Hopefully the current order of the fields is such that everything will
* be well aligned and, therefore, tightly packed.
*/
struct u9fsnode {
LIST_ENTRY(u9fsnode) n_hash; /* Hash chain */
u_quad_t n_size; /* Current size of file */
struct vattr n_vattr; /* Vnode attribute cache */
time_t n_attrstamp; /* Attr. cache timestamp */
u_int32_t n_mode; /* ACCESS mode cache */
uid_t n_modeuid; /* credentials having mode */
time_t n_modestamp; /* mode cache timestamp */
time_t n_mtime; /* Prev modify time. */
time_t n_ctime; /* Prev create time. */
struct u9fs_qid n_qid;
u_short n_fid; /* U9FS FID */
u_short n_rdfid;
u_short n_wrfid;
struct vnode *n_vnode; /* associated vnode */
struct lockf *n_lockf; /* Locking record of file */
int n_error; /* Save write error value */
struct u9fsdir n_dir;
short n_flag; /* Flag for locking.. */
int n_opens; /* number of opens */
};
#define n_atim n_un1.nf_atim
#define n_mtim n_un2.nf_mtim
#define n_sillyrename n_un3.nf_silly
#define n_cookieverf n_un1.nd_cookieverf
#define n_direofoffset n_un2.nd_direof
#define n_cookies n_un3.nd_cook
/*
* Flags for n_flag
*/
#define NFLUSHWANT 0x0001 /* Want wakeup from a flush in prog. */
#define NFLUSHINPROG 0x0002 /* Avoid multiple calls to vinvalbuf() */
#define NMODIFIED 0x0004 /* Might have a modified buffer in bio */
#define NWRITEERR 0x0008 /* Flag write errors so close will know */
#define NQU9FSNONCACHE 0x0020 /* Non-cachable lease */
#define NQU9FSWRITE 0x0040 /* Write lease */
#define NQU9FSEVICTED 0x0080 /* Has been evicted */
#define NACC 0x0100 /* Special file accessed */
#define NUPD 0x0200 /* Special file updated */
#define NCHG 0x0400 /* Special file times changed */
#define NLOCKED 0x0800 /* node is locked */
#define NWANTED 0x0100 /* someone wants to lock */
/*
* Convert between u9fsnode pointers and vnode pointers
*/
#define VTOU9FS(vp) ((struct u9fsnode *)(vp)->v_data)
#define U9FSTOV(np) ((struct vnode *)(np)->n_vnode)
/*
* Mount structure.
* One allocated on every U9FS mount.
* Holds U9FS specific information for mount.
*/
struct u9fsmount {
int nm_flag; /* Flags for soft/hard... */
int nm_state; /* Internal state flags */
struct mount *nm_mountp; /* Vfs structure for this filesystem */
int nm_numgrps; /* Max. size of groupslist */
u9fsfh_t nm_fh; /* qid.path */
u_short nm_fid; /* fid of root dir */
struct socket *nm_so; /* Rpc socket */
int nm_sotype; /* Type of socket */
int nm_soproto; /* and protocol */
int nm_soflags; /* pr_flags for socket protocol */
struct sockaddr *nm_nam; /* Addr of server */
int nm_sent; /* Request send count */
int nm_cwnd; /* Request send window */
int nm_rsize; /* Max size of read rpc */
int nm_wsize; /* Max size of write rpc */
int nm_readdirsize; /* Size of a readdir rpc */
struct lock nm_lock; /* lock for tag/fid freelist */
bitstr_t * nm_tags;
bitstr_t * nm_fids;
TAILQ_HEAD(u9fs_reqq, u9fsreq) nm_reqq;
uid_t nm_authuid; /* Uid for authenticator */
#if 0
struct vnode *nm_inprog; /* Vnode in prog by nqu9fs_clientd() */
uid_t nm_authuid; /* Uid for authenticator */
int nm_authtype; /* Authenticator type */
int nm_authlen; /* and length */
char *nm_authstr; /* Authenticator string */
char *nm_verfstr; /* and the verifier */
int nm_verflen;
u_char nm_verf[U9FSX_V3WRITEVERF]; /* V3 write verifier */
U9FSKERBKEY_T nm_key; /* and the session key */
int nm_numuids; /* Number of u9fsuid mappings */
TAILQ_HEAD(, u9fsuid) nm_uidlruhead; /* Lists of u9fsuid mappings */
LIST_HEAD(, u9fsuid) nm_uidhashtbl[U9FS_MUIDHASHSIZ];
TAILQ_HEAD(, buf) nm_bufq; /* async io buffer queue */
short nm_bufqlen; /* number of buffers in queue */
short nm_bufqwant; /* process wants to add to the queue */
int nm_bufqiods; /* number of iods processing queue */
#endif
u_int64_t nm_maxfilesize; /* maximum file size */
};
#ifdef KERNEL
#ifdef MALLOC_DECLARE
MALLOC_DECLARE(M_U9FSHASH);
MALLOC_DECLARE(M_U9FSBITS);
extern vop_t **u9fs_vnodeop_p;
/* u9fs_node.c */
void u9fs_nhinit __P((void));
int u9fs_nget __P((struct mount *mntp, u9fsfh_t fh, struct u9fsnode **npp, struct proc * p));
/* u9fs_subr.c */
void u9fs_id_init __P((bitstr_t ** bits));
u_short u9fs_id_new __P((bitstr_t * bits));
void u9fs_id_free __P((bitstr_t * bits, u_short v));
void u9fs_uhinit __P((void));
uid_t u9fs_name2uid __P((char * name));
struct u9fsuser * u9fs_finduser __P((uid_t uid));
void u9fs_hashuser __P((uid_t uid, char *name));
int u9fs_mbuftouio __P((struct mbuf *m, struct uio *uiop, int siz));
int u9fs_uiotombuf __P((struct uio *uiop, struct mbuf **mq, int siz));
/* u9fs_vnopes.c */
int u9fs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *));
int u9fs_readrpc __P((struct vnode *vp, struct uio *uiop, struct ucred *cred));
int u9fs_writerpc __P((struct vnode *vp, struct uio *uiop, struct ucred *cred));
/* u9fs_bio.c */
int u9fs_bioread __P((struct vnode *, struct uio *, int, struct ucred *,int));
int u9fs_biowrite __P((struct vnode *, struct uio *, int ioflag, struct ucred *));
int u9fs_doio __P((struct buf *, struct ucred *, struct proc *));
int u9fs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *, int));
/* u9fs_socket.c */
int u9fs_sigintr __P((struct u9fsmount *nmp, struct proc *p));
void u9fs_disconnect __P((struct socket *));
int u9fs_connect __P((struct socket ** sop, struct sockaddr * saddr, int sotype, int soproto, struct proc * p));
int u9fs_connect_9fs __P((struct u9fsmount *));
int u9fs_connect_9auth __P((struct u9fsmount *, struct u9fs_args *, struct socket **));
int u9fs_request __P((struct u9fsreq * req, struct u9fsreq * rep, int relm));
#endif
/*
* Convert mount ptr to u9fsmount ptr.
*/
#define VFSTOU9FS(mp) ((struct u9fsmount *)((mp)->mnt_data))
#endif /* KERNEL */
#endif