#ifndef _NFS_INET_H
#define _NFS_INET_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <netinet/in.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/udp.h>
#include <sys/saio.h>
#include <rpcsvc/nfs_prot.h>
#include <rpcsvc/nfs4_prot.h>
#include "clnt.h"
#include <sys/vfs.h>
#include <sys/dirent.h>
#define NFSBUF_SIZE (READ_SIZE+1024)
#define READ_SIZE (8192)
#define NFS_READ_DECR (1024)
#define NFS3BUF_SIZE (READ3_SIZE+1024)
#define READ3_SIZE (32 * 1024)
#define NFS4BUF_SIZE (READ4_SIZE+1024)
#define READ4_SIZE (32 * 1024)
#define NFS4_MAX_UTF8STRING (8 * 1024)
#define NFS4_MAX_BITWORDS (2)
#define NFS_MAX_FERRS (3)
#define NFS_REXMIT_MIN (3)
#define NFS_REXMIT_MAX (15)
extern int nfs_readsize;
extern struct nfs_file roothandle;
extern CLIENT *root_CLIENT;
struct nfs_bfh4 {
uint_t len;
char data[NFS4_FHSIZE];
};
struct nfs_bfh3 {
uint_t len;
char data[NFS3_FHSIZE];
};
union _nfs_fh {
nfs_fh fh2;
struct nfs_bfh3 fh3;
struct nfs_bfh4 fh4;
};
union _nfs_cookie {
nfscookie cookie2;
cookie3 cookie3;
nfs_cookie4 cookie4;
};
union _nfs_ftype {
ftype type2;
ftype3 type3;
nfs_ftype4 type4;
};
struct nfs_file {
int version;
ulong_t offset;
union _nfs_ftype ftype;
union _nfs_fh fh;
union _nfs_cookie cookie;
};
struct nfs_fid {
ushort_t nf_len;
ushort_t nf_pad;
struct nfs_fh fh;
};
#define cfile_is_dir(cf) (((cf)->version == NFS_VERSION) ? \
((cf)->ftype.type2 == NFDIR) : \
(((cf)->version == NFS_V3) ? \
((cf)->ftype.type3 == NF3DIR) : \
(((cf)->version == NFS_V4) ? \
((cf)->ftype.type4 == NF4DIR) : 0)))
#define cfile_is_lnk(cf) (((cf)->version == NFS_VERSION) ? \
((cf)->ftype.type2 == NFLNK) : \
(((cf)->version == NFS_V3) ? \
((cf)->ftype.type3 == NF3LNK) : \
(((cf)->version == NFS_V4) ? \
((cf)->ftype.type4 == NF4LNK) : 0)))
typedef union attr4_bitmap1_u {
struct {
unsigned int
#ifdef _BIT_FIELDS_HTOL
b_pad4: 11,
b_fattr4_fileid: 1,
b_fattr4_filehandle: 1,
b_pad3: 10,
b_fattr4_fsid: 1,
b_pad2: 3,
b_fattr4_size: 1,
b_pad1: 2,
b_fattr4_type: 1,
b_supported_attrs: 1;
#endif
#ifdef _BIT_FIELDS_LTOH
b_supported_attrs: 1,
b_fattr4_type: 1,
b_pad1: 2,
b_fattr4_size: 1,
b_pad2: 3,
b_fattr4_fsid: 1,
b_pad3: 10,
b_fattr4_filehandle: 1,
b_fattr4_fileid: 1,
b_pad4: 11;
#endif
} bitmap_s;
uint_t word;
} attr4_bitmap1_t;
#define bm_supported_attrs bitmap_s.b_supported_attrs
#define bm_fattr4_type bitmap_s.b_fattr4_type
#define bm_fattr4_size bitmap_s.b_fattr4_size
#define bm_fattr4_fsid bitmap_s.b_fattr4_fsid
#define bm_fattr4_fileid bitmap_s.b_fattr4_fileid
#define bm_fattr4_filehandle bitmap_s.b_fattr4_filehandle
typedef union attr4_bitmap2_u {
struct {
unsigned int
#ifdef _BIT_FIELDS_HTOL
b_pad4: 10,
b_fattr4_time_modify: 1,
b_fattr4_time_metadata: 1,
b_pad3: 4,
b_fattr4_time_access: 1,
b_pad2: 13,
b_fattr4_mode: 1,
b_pad1: 1;
#endif
#ifdef _BIT_FIELDS_LTOH
b_pad1: 1,
b_fattr4_mode: 1,
b_pad2: 13,
b_fattr4_time_access: 1,
b_pad3: 4,
b_fattr4_time_metadata: 1,
b_fattr4_time_modify: 1,
b_pad4: 10;
#endif
} bitmap_s;
uint_t word;
} attr4_bitmap2_t;
#define bm_fattr4_mode bitmap_s.b_fattr4_mode
#define bm_fattr4_time_access bitmap_s.b_fattr4_time_access
#define bm_fattr4_time_metadata bitmap_s.b_fattr4_time_metadata
#define bm_fattr4_time_modify bitmap_s.b_fattr4_time_modify
typedef struct b_bitmap4 {
uint_t b_bitmap_len;
uint_t b_bitmap_val[NFS4_MAX_BITWORDS];
} b_bitmap4_t;
typedef struct b_fattr4_s {
b_bitmap4_t b_supported_attrs;
nfs_ftype4 b_fattr4_type;
uint64_t b_fattr4_size;
fsid4 b_fattr4_fsid;
struct nfs_bfh4 b_fattr4_filehandle;
uint64_t b_fattr4_fileid;
mode4 b_fattr4_mode;
nfstime4 b_fattr4_time_access;
nfstime4 b_fattr4_time_metadata;
nfstime4 b_fattr4_time_modify;
} b_fattr4_t;
typedef struct putfh4arg_s {
uint_t pf_opnum;
struct nfs_bfh4 pf_filehandle;
} putfh4arg_t;
typedef union compound_u {
struct {
utf8string tag;
uint_t minorversion;
uint_t argarray_len;
bool_t isputrootfh;
putfh4arg_t opputfh;
} compound_ua_s;
struct {
nfsstat4 status;
utf8string tag;
uint_t resarray_len;
uint_t opputfh;
nfsstat4 putfh_status;
} compound_ur_s;
} b_compound_t;
#define ca_tag compound_ua_s.tag
#define ca_minorversion compound_ua_s.minorversion
#define ca_argarray_len compound_ua_s.argarray_len
#define ca_isputrootfh compound_ua_s.isputrootfh
#define ca_opputfh compound_ua_s.opputfh
#define cr_status compound_ur_s.status
#define cr_tag compound_ur_s.tag
#define cr_resarray_len compound_ur_s.resarray_len
#define cr_opputfh compound_ur_s.opputfh
#define cr_putfh_status compound_ur_s.putfh_status
typedef struct getattrres_cmn {
uint_t gc_opgetattr;
nfsstat4 gc_attr_status;
b_bitmap4_t gc_retattr;
uint_t gc_attrlist_len;
b_fattr4_t gc_attrs;
} getattrres_cmn_t;
typedef struct getattr4arg_s {
b_compound_t ga_arg;
uint_t ga_opgetattr;
b_bitmap4_t ga_attr_req;
} getattr4arg_t;
typedef struct getattr4res_s {
b_compound_t gr_res;
getattrres_cmn_t gr_cmn;
} getattr4res_t;
#define gr_opgetattr gr_cmn.gc_opgetattr
#define gr_attr_status gr_cmn.gc_attr_status
#define gr_retattr gr_cmn.gc_retattr
#define gr_attrs gr_cmn.gc_attrs
typedef struct lookup4arg_s {
b_compound_t la_arg;
uint_t la_oplookup;
component4 la_pathname;
uint_t la_opgetattr;
b_bitmap4_t la_attr_req;
} lookup4arg_t;
typedef struct lookup4res_s {
b_compound_t lr_res;
uint_t lr_oplookup;
nfsstat4 lr_lookup_status;
getattrres_cmn_t lr_gcmn;
} lookup4res_t;
#define lr_opgetattr lr_gcmn.gc_opgetattr
#define lr_attr_status lr_gcmn.gc_attr_status
#define lr_retattr lr_gcmn.gc_retattr
#define lr_attrs lr_gcmn.gc_attrs
typedef struct lookupp4arg_s {
b_compound_t la_arg;
uint_t la_oplookupp;
uint_t la_opgetattr;
b_bitmap4_t la_attr_req;
} lookupp4arg_t;
typedef struct read4arg_s {
b_compound_t r_arg;
uint_t r_opread;
stateid4 r_stateid;
offset4 r_offset;
count4 r_count;
} read4arg_t;
typedef struct read4res_s {
b_compound_t r_res;
uint_t r_opread;
nfsstat4 r_status;
bool_t r_eof;
uint_t r_data_len;
char *r_data_val;
} read4res_t;
typedef struct b_entry4_s {
nfs_cookie4 b_cookie;
utf8string b_name;
uint64_t b_fileid;
struct b_entry4_s *b_nextentry;
} b_entry4_t;
typedef struct readdir4arg_s {
b_compound_t rd_arg;
uint_t rd_opreaddir;
nfs_cookie4 rd_cookie;
verifier4 rd_cookieverf;
count4 rd_dircount;
count4 rd_maxcount;
b_bitmap4_t rd_attr_req;
} readdir4arg_t;
typedef struct readdir4res_s {
b_compound_t rd_res;
uint_t rd_opreaddir;
nfsstat4 rd_status;
verifier4 rd_cookieverf;
b_entry4_t *rd_entries;
bool_t rd_eof;
} readdir4res_t;
typedef struct readlink4arg_s {
b_compound_t rl_arg;
uint_t rl_opreadlink;
} readlink4arg_t;
typedef struct readlink4res_s {
b_compound_t rl_res;
uint_t rl_opreadlink;
nfsstat4 rl_status;
utf8string rl_link;
} readlink4res_t;
extern int boot_nfs_mountroot(char *);
extern int boot_nfs_unmountroot(void);
extern int lookup(char *pathname, struct nfs_file *, bool_t);
extern bool_t whoami(void);
extern bool_t getfile(char *, char *, struct in_addr *, char *);
extern void nfs_error(enum nfsstat);
extern ssize_t nfsread(struct nfs_file *, char *, size_t);
extern int nfsgetattr(struct nfs_file *, struct vattr *);
extern int nfsgetdents(struct nfs_file *, struct dirent *, unsigned);
extern struct nfs_file *nfslookup(struct nfs_file *, char *, int *);
extern int nfsgetsymlink(struct nfs_file *cfile, char **path);
extern void nfs3_error(enum nfsstat3);
extern ssize_t nfs3read(struct nfs_file *, char *, size_t);
extern int nfs3getattr(struct nfs_file *, struct vattr *);
extern int nfs3getdents(struct nfs_file *, struct dirent *, unsigned);
extern struct nfs_file *nfs3lookup(struct nfs_file *, char *, int *);
extern int nfs3getsymlink(struct nfs_file *, char **);
extern void nfs4_error(enum nfsstat4);
extern ssize_t nfs4read(struct nfs_file *, char *, size_t);
extern int nfs4getattr(struct nfs_file *, struct vattr *);
extern int nfs4_getdents(struct nfs_file *, struct dirent *, unsigned);
extern struct nfs_file *nfs4lookup(struct nfs_file *, char *, int *);
extern struct nfs_file *nfs4lookupp(struct nfs_file *, int *, uint64_t *);
extern int nfs4getsymlink(struct nfs_file *, char **);
extern void compound_init(b_compound_t *, utf8string *, uint_t, uint_t,
struct nfs_bfh4 *);
extern bool_t xdr_getattr4_args(XDR *, getattr4arg_t *);
extern bool_t xdr_getattr4_res(XDR *, getattr4res_t *);
extern bool_t xdr_lookup4_args(XDR *, lookup4arg_t *);
extern bool_t xdr_lookup4_res(XDR *, lookup4res_t *);
extern bool_t xdr_lookupp4_args(XDR *, lookupp4arg_t *);
extern bool_t xdr_read4_args(XDR *, read4arg_t *);
extern bool_t xdr_read4_res(XDR *, read4res_t *);
extern bool_t xdr_readdir4_args(XDR *, readdir4arg_t *);
extern bool_t xdr_readdir4_res(XDR *, readdir4res_t *);
extern bool_t xdr_readlink4_args(XDR *, readlink4arg_t *);
extern bool_t xdr_readlink4_res(XDR *, readlink4res_t *);
#ifdef __cplusplus
}
#endif
#endif