#ifndef _FS_SMBFS_SMBFS_SUBR_H_
#define _FS_SMBFS_SMBFS_SUBR_H_
#include <sys/cmn_err.h>
#include <netsmb/mchain.h>
#include <netsmb/smb_subr.h>
#include <smbfs/smbfs_node.h>
#if defined(DEBUG) || defined(lint)
#define SMB_VNODE_DEBUG 1
#endif
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef TRUE
#define TRUE (1)
#endif
#define SMBFSERR(...) \
smb_errmsg(CE_NOTE, __func__, __VA_ARGS__)
#define SMBVDEBUG(...) \
smb_errmsg(CE_CONT, __func__, __VA_ARGS__)
#define SMB_LOCK_EXCL 0
#define SMB_LOCK_SHARED 1
#define SMB_LOCK_RELEASE 2
struct smb_cred;
struct smb_vc;
struct statvfs;
struct timespec;
typedef enum {
ft_LM1 = 1,
ft_LM2,
ft_SMB2,
ft_XA
} smbfs_fctx_type_t;
#define SMBFS_RDD_FINDFIRST 0x01
#define SMBFS_RDD_EOF 0x02
#define SMBFS_RDD_FINDSINGLE 0x04
#define SMBFS_RDD_NOCLOSE 0x10
#define SMB_SKEYLEN 21
#define SMB_DENTRYLEN (SMB_SKEYLEN + 22)
struct smbfs_fctx {
smbfs_fctx_type_t f_type;
int f_flags;
struct smbfattr f_attr;
u_longlong_t f_inum;
char *f_name;
int f_nmlen;
int f_namesz;
uint16_t f_infolevel;
uint16_t f_limit;
uint32_t f_attrmask;
int f_wclen;
const char *f_wildcard;
struct smbnode *f_dnp;
struct smb_cred *f_scred;
struct smb_share *f_ssp;
struct smb_fh *f_fhp;
union {
struct smb_rq *uf_rq;
struct smb_t2rq *uf_t2;
} f_urq;
struct mdchain f_mdchain;
int f_left;
int f_ecnt;
int f_eofs;
uchar_t f_skey[SMB_SKEYLEN];
uchar_t f_fname[8 + 1 + 3 + 1];
uint16_t f_Sid;
int f_rnamelen;
char *f_rname;
int f_rnameofs;
int f_otws;
char *f_firstnm;
int f_firstnmlen;
uint32_t f_rkey;
};
typedef struct smbfs_fctx smbfs_fctx_t;
#define f_rq f_urq.uf_rq
#define f_t2 f_urq.uf_t2
struct smb_fs_size_info {
uint64_t total_units;
uint64_t caller_avail;
uint64_t actual_avail;
uint32_t sect_per_unit;
uint32_t bytes_per_sect;
};
int smbfs_smb_lock(struct smbnode *np, int op, caddr_t id,
offset_t start, uint64_t len, int largelock,
struct smb_cred *scrp, uint32_t timeout);
int smbfs_smb_getfattr(struct smbnode *np, smb_fh_t *fhp,
struct smbfattr *fap, struct smb_cred *scrp);
int smbfs_smb_getpattr(struct smbnode *np, struct smbfattr *fap,
struct smb_cred *scrp);
int smbfs_smb_qfsattr(struct smb_share *ssp, struct smb_fs_attr_info *,
struct smb_cred *scrp);
int smbfs_smb_statfs(struct smb_share *ssp, statvfs64_t *sbp,
struct smb_cred *scrp);
int smbfs_smb_setdisp(struct smb_share *ssp, smb_fh_t *fid, uint8_t newdisp,
struct smb_cred *scrp);
int smbfs_smb_setfsize(struct smb_share *ssp, smb_fh_t *fid, uint64_t newsize,
struct smb_cred *scrp);
int smbfs_smb_setfattr(struct smb_share *ssp, smb_fh_t *fid,
uint32_t attr, struct timespec *mtime, struct timespec *atime,
struct smb_cred *scrp);
int smbfs_smb_flush(struct smb_share *ssp, smb_fh_t *fid,
struct smb_cred *scrp);
int smbfs_smb_ntcreatex(
struct smbnode *np, const char *name, int nmlen, int xattr,
uint32_t req_acc, uint32_t efa, uint32_t share_acc,
uint32_t disp, uint32_t createopt, struct smb_cred *scrp,
smb_fh_t *fhpp, uint32_t *cr_act_p, struct smbfattr *fap);
int smbfs_smb_tmpopen(struct smbnode *np, uint32_t rights,
struct smb_cred *scrp, smb_fh_t **fidpp);
void smbfs_smb_tmpclose(struct smbnode *ssp, smb_fh_t *fid);
int smbfs_smb_open(struct smbnode *np, const char *name, int nmlen,
int xattr, uint32_t rights, struct smb_cred *scrp,
smb_fh_t **fidpp, struct smbfattr *fap);
void smbfs_smb_close(smb_fh_t *fid);
int smbfs_smb_create(struct smbnode *dnp, const char *name, int nmlen,
int xattr, uint32_t disp, struct smb_cred *scrp, smb_fh_t **fidpp);
int smbfs_smb_rename(struct smbnode *sdnp, struct smbnode *src,
struct smbnode *tdnp, const char *tname, int tnmlen,
smb_fh_t *fid, struct smb_cred *scrp);
int smbfs_smb_mkdir(struct smbnode *dnp, const char *name, int len,
struct smb_cred *scrp);
int smbfs_smb_findopen(struct smbnode *dnp, const char *wildcard, int wclen,
int attr, struct smb_cred *scrp, struct smbfs_fctx **ctxpp);
int smbfs_smb_findnext(struct smbfs_fctx *ctx, int limit,
struct smb_cred *scrp);
int smbfs_smb_findclose(struct smbfs_fctx *ctx, struct smb_cred *scrp);
int smbfs_smb_lookup(struct smbnode *dnp, const char **namep, int *nmlenp,
struct smbfattr *fap, struct smb_cred *scrp);
int smbfs_smb_getsec(struct smb_share *ssp, smb_fh_t *fid,
uint32_t selector, mblk_t **res, uint32_t *reslen,
struct smb_cred *scrp);
int smbfs_smb_setsec(struct smb_share *ssp, smb_fh_t *fid,
uint32_t selector, mblk_t **mp, struct smb_cred *scrp);
int smbfs_smb1_trans2_query(struct smbnode *np, uint16_t fid,
struct smbfattr *fap, struct smb_cred *scrp);
int smbfs_smb1_qfsattr(struct smb_share *ssp, struct smb_fs_attr_info *,
struct smb_cred *scrp);
int smbfs_smb1_statfs(struct smb_share *ssp,
struct smb_fs_size_info *info, struct smb_cred *scrp);
int smbfs_smb1_seteof(struct smb_share *ssp, uint16_t fid, uint64_t newsize,
struct smb_cred *scrp);
int smbfs_smb1_setdisp(struct smb_share *ssp, uint16_t fid, uint8_t newdisp,
struct smb_cred *scrp);
int smbfs_smb1_setfattr(struct smb_share *ssp, uint16_t fid,
struct mbchain *, struct smb_cred *);
int smbfs_smb1_flush(struct smb_share *ssp, uint16_t fid,
struct smb_cred *scrp);
int smbfs_smb1_t2rename(struct smbnode *np, const char *tname, int tnmlen,
uint16_t fid, struct smb_cred *scrp);
int smbfs_smb1_oldrename(struct smbnode *src, struct smbnode *tdnp,
const char *tname, int tnmlen, struct smb_cred *scrp);
int smbfs_smb_findopenLM2(struct smbfs_fctx *ctx, struct smbnode *dnp,
const char *wildcard, int wclen, uint32_t attr);
int smbfs_smb_findnextLM2(struct smbfs_fctx *ctx, uint16_t limit);
int smbfs_smb_findcloseLM2(struct smbfs_fctx *ctx);
int smbfs_smb1_get_streaminfo(smbnode_t *np, struct mdchain *mdp,
struct smb_cred *scrp);
int smbfs_smb1_getsec(struct smb_share *ssp, uint16_t fid,
uint32_t selector, mblk_t **res, uint32_t *reslen,
struct smb_cred *scrp);
int smbfs_smb1_setsec(struct smb_share *ssp, uint16_t fid,
uint32_t selector, mblk_t **mp,
struct smb_cred *scrp);
int smbfs_smb2_getpattr(struct smbnode *np, struct smbfattr *fap,
struct smb_cred *scrp);
int smbfs_smb2_qfileinfo(struct smb_share *ssp, smb2fid_t *fid,
struct smbfattr *fap, struct smb_cred *scrp);
int smbfs_smb2_qfsattr(struct smb_share *ssp, struct smb_fs_attr_info *,
struct smb_cred *scrp);
int smbfs_smb2_statfs(struct smb_share *ssp,
struct smb_fs_size_info *info, struct smb_cred *scrp);
int smbfs_smb2_seteof(struct smb_share *ssp, smb2fid_t *fid, uint64_t newsize,
struct smb_cred *scrp);
int smbfs_smb2_setdisp(struct smb_share *ssp, smb2fid_t *fid, uint8_t newdisp,
struct smb_cred *scrp);
int smbfs_smb2_flush(struct smb_share *ssp, smb2fid_t *fid,
struct smb_cred *scrp);
int smbfs_smb2_setfattr(struct smb_share *ssp, smb2fid_t *fid,
struct mbchain *, struct smb_cred *);
int smbfs_smb2_rename(struct smbnode *np, struct smbnode *tdnp,
const char *tname, int tnlen, int overwrite,
smb2fid_t *fid, struct smb_cred *scrp);
int smbfs_smb2_findopen(struct smbfs_fctx *ctx, struct smbnode *dnp,
const char *wildcard, int wclen, uint32_t attr);
int smbfs_smb2_findnext(struct smbfs_fctx *ctx, uint16_t limit);
int smbfs_smb2_findclose(struct smbfs_fctx *ctx);
int smbfs_smb2_get_streaminfo(smbnode_t *np, struct mdchain *mdp,
struct smb_cred *scrp);
int smbfs_smb2_getsec(struct smb_share *ssp, smb2fid_t *fid,
uint32_t selector, mblk_t **res, uint32_t *reslen,
struct smb_cred *scrp);
int smbfs_smb2_setsec(struct smb_share *ssp, smb2fid_t *fid,
uint32_t selector, mblk_t **mp,
struct smb_cred *scrp);
int smbfs_fullpath(struct mbchain *mbp, struct smb_vc *vcp,
struct smbnode *dnp, const char *name, int nmlen, uint8_t sep);
int smbfs_decode_dirent(struct smbfs_fctx *ctx);
int smbfs_decode_file_all_info(struct smb_share *ssp,
struct mdchain *mdp, struct smbfattr *fap);
int smbfs_decode_fs_attr_info(struct smb_share *ssp,
struct mdchain *mdp, struct smb_fs_attr_info *fsa);
int smbfs_vfsinit(void);
void smbfs_vfsfini(void);
int smbfs_subrinit(void);
void smbfs_subrfini(void);
int smbfs_clntinit(void);
void smbfs_clntfini(void);
void smbfs_zonelist_add(smbmntinfo_t *smi);
void smbfs_zonelist_remove(smbmntinfo_t *smi);
int smbfs_check_table(struct vfs *vfsp, struct smbnode *srp);
void smbfs_destroy_table(struct vfs *vfsp);
void smbfs_rflush(struct vfs *vfsp, cred_t *cr);
void smbfs_flushall(cred_t *cr);
int smbfs_directio(vnode_t *vp, int cmd, cred_t *cr);
uint32_t smbfs_newnum(void);
int smbfs_newname(char *buf, size_t buflen);
void smbfs_attrcache_prune(struct smbnode *np);
void smbfs_attrcache_remove(struct smbnode *np);
void smbfs_attrcache_rm_locked(struct smbnode *np);
#ifndef DEBUG
#define smbfs_attrcache_rm_locked(np) (np)->r_attrtime = gethrtime()
#endif
void smbfs_attr_touchdir(struct smbnode *dnp);
void smbfs_attrcache_fa(vnode_t *vp, struct smbfattr *fap);
int smbfs_validate_caches(struct vnode *vp, cred_t *cr);
void smbfs_purge_caches(struct vnode *vp, cred_t *cr);
void smbfs_addfree(struct smbnode *sp);
void smbfs_rmhash(struct smbnode *);
void smbfs_init_hash_avl(avl_tree_t *);
uint32_t smbfs_gethash(const char *rpath, int prlen);
uint32_t smbfs_getino(struct smbnode *dnp, const char *name, int nmlen);
extern struct smbfattr smbfs_fattr0;
smbnode_t *smbfs_node_findcreate(smbmntinfo_t *mi,
const char *dir, int dirlen,
const char *name, int nmlen,
char sep, struct smbfattr *fap);
int smbfs_nget(vnode_t *dvp, const char *name, int nmlen,
struct smbfattr *fap, vnode_t **vpp);
void smbfs_fname_tolocal(struct smbfs_fctx *ctx);
char *smbfs_name_alloc(const char *name, int nmlen);
void smbfs_name_free(const char *name, int nmlen);
int smbfs_readvnode(vnode_t *, uio_t *, cred_t *, struct vattr *);
int smbfs_writevnode(vnode_t *vp, uio_t *uiop, cred_t *cr,
int ioflag, int timo);
int smbfsgetattr(vnode_t *vp, struct vattr *vap, cred_t *cr);
void smbfs_invalidate_pages(vnode_t *vp, u_offset_t off, cred_t *cr);
int smbfs_acl_getids(vnode_t *, cred_t *);
int smbfs_acl_setids(vnode_t *, vattr_t *, cred_t *);
int smbfs_acl_getvsa(vnode_t *, vsecattr_t *, int, cred_t *);
int smbfs_acl_setvsa(vnode_t *, vsecattr_t *, int, cred_t *);
int smbfs_acl_iocget(vnode_t *, intptr_t, int, cred_t *);
int smbfs_acl_iocset(vnode_t *, intptr_t, int, cred_t *);
int smbfs_get_xattrdir(vnode_t *dvp, vnode_t **vpp, cred_t *cr, int);
int smbfs_xa_parent(vnode_t *vp, vnode_t **vpp);
int smbfs_xa_exists(vnode_t *vp, cred_t *cr);
int smbfs_xa_getfattr(struct smbnode *np, struct smbfattr *fap,
struct smb_cred *scrp);
int smbfs_xa_findopen(struct smbfs_fctx *ctx, struct smbnode *dnp,
const char *name, int nmlen);
int smbfs_xa_findnext(struct smbfs_fctx *ctx, uint16_t limit);
int smbfs_xa_findclose(struct smbfs_fctx *ctx);
int smbfs_rw_enter_sig(smbfs_rwlock_t *l, krw_t rw, int intr);
int smbfs_rw_tryenter(smbfs_rwlock_t *l, krw_t rw);
void smbfs_rw_exit(smbfs_rwlock_t *l);
int smbfs_rw_lock_held(smbfs_rwlock_t *l, krw_t rw);
void smbfs_rw_init(smbfs_rwlock_t *l, char *name, krw_type_t type, void *arg);
void smbfs_rw_destroy(smbfs_rwlock_t *l);
#endif