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