1*86d7f5d3SJohn Marino /* 2*86d7f5d3SJohn Marino * Copyright (c) 2000-2001, Boris Popov 3*86d7f5d3SJohn Marino * All rights reserved. 4*86d7f5d3SJohn Marino * 5*86d7f5d3SJohn Marino * Redistribution and use in source and binary forms, with or without 6*86d7f5d3SJohn Marino * modification, are permitted provided that the following conditions 7*86d7f5d3SJohn Marino * are met: 8*86d7f5d3SJohn Marino * 1. Redistributions of source code must retain the above copyright 9*86d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer. 10*86d7f5d3SJohn Marino * 2. Redistributions in binary form must reproduce the above copyright 11*86d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer in the 12*86d7f5d3SJohn Marino * documentation and/or other materials provided with the distribution. 13*86d7f5d3SJohn Marino * 3. All advertising materials mentioning features or use of this software 14*86d7f5d3SJohn Marino * must display the following acknowledgement: 15*86d7f5d3SJohn Marino * This product includes software developed by Boris Popov. 16*86d7f5d3SJohn Marino * 4. Neither the name of the author nor the names of any co-contributors 17*86d7f5d3SJohn Marino * may be used to endorse or promote products derived from this software 18*86d7f5d3SJohn Marino * without specific prior written permission. 19*86d7f5d3SJohn Marino * 20*86d7f5d3SJohn Marino * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 21*86d7f5d3SJohn Marino * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22*86d7f5d3SJohn Marino * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23*86d7f5d3SJohn Marino * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 24*86d7f5d3SJohn Marino * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25*86d7f5d3SJohn Marino * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26*86d7f5d3SJohn Marino * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27*86d7f5d3SJohn Marino * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28*86d7f5d3SJohn Marino * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29*86d7f5d3SJohn Marino * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30*86d7f5d3SJohn Marino * SUCH DAMAGE. 31*86d7f5d3SJohn Marino * 32*86d7f5d3SJohn Marino * $FreeBSD: src/sys/fs/smbfs/smbfs_subr.h,v 1.1.2.1 2001/05/22 08:32:28 bp Exp $ 33*86d7f5d3SJohn Marino * $DragonFly: src/sys/vfs/smbfs/smbfs_subr.h,v 1.4 2006/12/23 00:41:30 swildner Exp $ 34*86d7f5d3SJohn Marino */ 35*86d7f5d3SJohn Marino #ifndef _FS_SMBFS_SMBFS_SUBR_H_ 36*86d7f5d3SJohn Marino #define _FS_SMBFS_SMBFS_SUBR_H_ 37*86d7f5d3SJohn Marino 38*86d7f5d3SJohn Marino #ifdef MALLOC_DECLARE 39*86d7f5d3SJohn Marino MALLOC_DECLARE(M_SMBFSDATA); 40*86d7f5d3SJohn Marino #endif 41*86d7f5d3SJohn Marino 42*86d7f5d3SJohn Marino #define SMBFSERR(format, args...) kprintf("%s: "format, __func__ ,## args) 43*86d7f5d3SJohn Marino 44*86d7f5d3SJohn Marino #ifdef SMB_VNODE_DEBUG 45*86d7f5d3SJohn Marino #define SMBVDEBUG(format, args...) kprintf("%s: "format, __func__ ,## args) 46*86d7f5d3SJohn Marino #else 47*86d7f5d3SJohn Marino #define SMBVDEBUG(format, args...) 48*86d7f5d3SJohn Marino #endif 49*86d7f5d3SJohn Marino 50*86d7f5d3SJohn Marino /* 51*86d7f5d3SJohn Marino * Possible lock commands 52*86d7f5d3SJohn Marino */ 53*86d7f5d3SJohn Marino #define SMB_LOCK_EXCL 0 54*86d7f5d3SJohn Marino #define SMB_LOCK_SHARED 1 55*86d7f5d3SJohn Marino #define SMB_LOCK_RELEASE 2 56*86d7f5d3SJohn Marino 57*86d7f5d3SJohn Marino struct smbmount; 58*86d7f5d3SJohn Marino struct proc; 59*86d7f5d3SJohn Marino struct timespec; 60*86d7f5d3SJohn Marino struct ucred; 61*86d7f5d3SJohn Marino struct vattr; 62*86d7f5d3SJohn Marino struct vnode; 63*86d7f5d3SJohn Marino struct statfs; 64*86d7f5d3SJohn Marino 65*86d7f5d3SJohn Marino struct smbfattr { 66*86d7f5d3SJohn Marino int fa_attr; 67*86d7f5d3SJohn Marino int64_t fa_size; 68*86d7f5d3SJohn Marino struct timespec fa_atime; 69*86d7f5d3SJohn Marino struct timespec fa_ctime; 70*86d7f5d3SJohn Marino struct timespec fa_mtime; 71*86d7f5d3SJohn Marino long fa_ino; 72*86d7f5d3SJohn Marino }; 73*86d7f5d3SJohn Marino 74*86d7f5d3SJohn Marino /* 75*86d7f5d3SJohn Marino * Context to perform findfirst/findnext/findclose operations 76*86d7f5d3SJohn Marino */ 77*86d7f5d3SJohn Marino #define SMBFS_RDD_FINDFIRST 0x01 78*86d7f5d3SJohn Marino #define SMBFS_RDD_EOF 0x02 79*86d7f5d3SJohn Marino #define SMBFS_RDD_FINDSINGLE 0x04 80*86d7f5d3SJohn Marino #define SMBFS_RDD_USESEARCH 0x08 81*86d7f5d3SJohn Marino #define SMBFS_RDD_NOCLOSE 0x10 82*86d7f5d3SJohn Marino #define SMBFS_RDD_GOTRNAME 0x1000 83*86d7f5d3SJohn Marino 84*86d7f5d3SJohn Marino /* 85*86d7f5d3SJohn Marino * Search context supplied by server 86*86d7f5d3SJohn Marino */ 87*86d7f5d3SJohn Marino #define SMB_SKEYLEN 21 /* search context */ 88*86d7f5d3SJohn Marino #define SMB_DENTRYLEN (SMB_SKEYLEN + 22) /* entire entry */ 89*86d7f5d3SJohn Marino 90*86d7f5d3SJohn Marino struct smbfs_fctx { 91*86d7f5d3SJohn Marino /* 92*86d7f5d3SJohn Marino * Setable values 93*86d7f5d3SJohn Marino */ 94*86d7f5d3SJohn Marino int f_flags; /* SMBFS_RDD_ */ 95*86d7f5d3SJohn Marino /* 96*86d7f5d3SJohn Marino * Return values 97*86d7f5d3SJohn Marino */ 98*86d7f5d3SJohn Marino struct smbfattr f_attr; /* current attributes */ 99*86d7f5d3SJohn Marino char * f_name; /* current file name */ 100*86d7f5d3SJohn Marino int f_nmlen; /* name len */ 101*86d7f5d3SJohn Marino /* 102*86d7f5d3SJohn Marino * Internal variables 103*86d7f5d3SJohn Marino */ 104*86d7f5d3SJohn Marino int f_limit; /* maximum number of entries */ 105*86d7f5d3SJohn Marino int f_attrmask; /* SMB_FA_ */ 106*86d7f5d3SJohn Marino int f_wclen; 107*86d7f5d3SJohn Marino const char * f_wildcard; 108*86d7f5d3SJohn Marino struct smbnode* f_dnp; 109*86d7f5d3SJohn Marino struct smb_cred*f_scred; 110*86d7f5d3SJohn Marino struct smb_share *f_ssp; 111*86d7f5d3SJohn Marino union { 112*86d7f5d3SJohn Marino struct smb_rq * uf_rq; 113*86d7f5d3SJohn Marino struct smb_t2rq * uf_t2; 114*86d7f5d3SJohn Marino } f_urq; 115*86d7f5d3SJohn Marino int f_left; /* entries left */ 116*86d7f5d3SJohn Marino int f_ecnt; /* entries left in the current reponse */ 117*86d7f5d3SJohn Marino int f_eofs; /* entry offset in the parameter block */ 118*86d7f5d3SJohn Marino u_char f_skey[SMB_SKEYLEN]; /* server side search context */ 119*86d7f5d3SJohn Marino u_char f_fname[8 + 1 + 3 + 1]; /* common case for 8.3 filenames */ 120*86d7f5d3SJohn Marino u_int16_t f_Sid; 121*86d7f5d3SJohn Marino u_int16_t f_infolevel; 122*86d7f5d3SJohn Marino int f_rnamelen; 123*86d7f5d3SJohn Marino char * f_rname; /* resume name/key */ 124*86d7f5d3SJohn Marino int f_rnameofs; 125*86d7f5d3SJohn Marino }; 126*86d7f5d3SJohn Marino 127*86d7f5d3SJohn Marino #define f_rq f_urq.uf_rq 128*86d7f5d3SJohn Marino #define f_t2 f_urq.uf_t2 129*86d7f5d3SJohn Marino 130*86d7f5d3SJohn Marino extern int smbfs_debuglevel; 131*86d7f5d3SJohn Marino 132*86d7f5d3SJohn Marino 133*86d7f5d3SJohn Marino /* 134*86d7f5d3SJohn Marino * smb level 135*86d7f5d3SJohn Marino */ 136*86d7f5d3SJohn Marino int smbfs_smb_lock(struct smbnode *np, int op, caddr_t id, 137*86d7f5d3SJohn Marino off_t start, off_t end, struct smb_cred *scred); 138*86d7f5d3SJohn Marino int smbfs_smb_statfs2(struct smb_share *ssp, struct statfs *sbp, 139*86d7f5d3SJohn Marino struct smb_cred *scred); 140*86d7f5d3SJohn Marino int smbfs_smb_statfs(struct smb_share *ssp, struct statfs *sbp, 141*86d7f5d3SJohn Marino struct smb_cred *scred); 142*86d7f5d3SJohn Marino int smbfs_smb_setfsize(struct smbnode *np, int newsize, struct smb_cred *scred); 143*86d7f5d3SJohn Marino 144*86d7f5d3SJohn Marino int smbfs_smb_setpattr(struct smbnode *np, u_int16_t attr, 145*86d7f5d3SJohn Marino struct timespec *mtime, struct smb_cred *scred); 146*86d7f5d3SJohn Marino int smbfs_smb_setptime2(struct smbnode *np, struct timespec *mtime, 147*86d7f5d3SJohn Marino struct timespec *atime, int attr, struct smb_cred *scred); 148*86d7f5d3SJohn Marino int smbfs_smb_setpattrNT(struct smbnode *np, u_int16_t attr, 149*86d7f5d3SJohn Marino struct timespec *mtime, struct timespec *atime, struct smb_cred *scred); 150*86d7f5d3SJohn Marino 151*86d7f5d3SJohn Marino int smbfs_smb_setftime(struct smbnode *np, struct timespec *mtime, 152*86d7f5d3SJohn Marino struct timespec *atime, struct smb_cred *scred); 153*86d7f5d3SJohn Marino int smbfs_smb_setfattrNT(struct smbnode *np, u_int16_t attr, 154*86d7f5d3SJohn Marino struct timespec *mtime, struct timespec *atime, struct smb_cred *scred); 155*86d7f5d3SJohn Marino 156*86d7f5d3SJohn Marino int smbfs_smb_open(struct smbnode *np, int accmode, struct smb_cred *scred); 157*86d7f5d3SJohn Marino int smbfs_smb_close(struct smb_share *ssp, u_int16_t fid, 158*86d7f5d3SJohn Marino struct timespec *mtime, struct smb_cred *scred); 159*86d7f5d3SJohn Marino int smbfs_smb_create(struct smbnode *dnp, const char *name, int len, 160*86d7f5d3SJohn Marino struct smb_cred *scred); 161*86d7f5d3SJohn Marino int smbfs_smb_delete(struct smbnode *np, struct smb_cred *scred); 162*86d7f5d3SJohn Marino int smbfs_smb_rename(struct smbnode *src, struct smbnode *tdnp, 163*86d7f5d3SJohn Marino const char *tname, int tnmlen, struct smb_cred *scred); 164*86d7f5d3SJohn Marino int smbfs_smb_move(struct smbnode *src, struct smbnode *tdnp, 165*86d7f5d3SJohn Marino const char *tname, int tnmlen, u_int16_t flags, struct smb_cred *scred); 166*86d7f5d3SJohn Marino int smbfs_smb_mkdir(struct smbnode *dnp, const char *name, int len, 167*86d7f5d3SJohn Marino struct smb_cred *scred); 168*86d7f5d3SJohn Marino int smbfs_smb_rmdir(struct smbnode *np, struct smb_cred *scred); 169*86d7f5d3SJohn Marino int smbfs_findopen(struct smbnode *dnp, const char *wildcard, int wclen, 170*86d7f5d3SJohn Marino int attr, struct smb_cred *scred, struct smbfs_fctx **ctxpp); 171*86d7f5d3SJohn Marino int smbfs_findnext(struct smbfs_fctx *ctx, int limit, struct smb_cred *scred); 172*86d7f5d3SJohn Marino int smbfs_findclose(struct smbfs_fctx *ctx, struct smb_cred *scred); 173*86d7f5d3SJohn Marino int smbfs_fullpath(struct mbchain *mbp, struct smb_vc *vcp, 174*86d7f5d3SJohn Marino struct smbnode *dnp, const char *name, int nmlen); 175*86d7f5d3SJohn Marino int smbfs_smb_lookup(struct smbnode *dnp, const char *name, int nmlen, 176*86d7f5d3SJohn Marino struct smbfattr *fap, struct smb_cred *scred); 177*86d7f5d3SJohn Marino 178*86d7f5d3SJohn Marino int smbfs_fname_tolocal(struct smb_vc *vcp, char *name, int nmlen, int caseopt); 179*86d7f5d3SJohn Marino 180*86d7f5d3SJohn Marino void smb_time_local2server(struct timespec *tsp, int tzoff, u_long *seconds); 181*86d7f5d3SJohn Marino void smb_time_server2local(u_long seconds, int tzoff, struct timespec *tsp); 182*86d7f5d3SJohn Marino void smb_time_NT2local(int64_t nsec, int tzoff, struct timespec *tsp); 183*86d7f5d3SJohn Marino void smb_time_local2NT(struct timespec *tsp, int tzoff, int64_t *nsec); 184*86d7f5d3SJohn Marino void smb_time_unix2dos(struct timespec *tsp, int tzoff, u_int16_t *ddp, 185*86d7f5d3SJohn Marino u_int16_t *dtp, u_int8_t *dhp); 186*86d7f5d3SJohn Marino void smb_dos2unixtime (u_int dd, u_int dt, u_int dh, int tzoff, struct timespec *tsp); 187*86d7f5d3SJohn Marino 188*86d7f5d3SJohn Marino #endif /* !_FS_SMBFS_SMBFS_SUBR_H_ */ 189