xref: /titanic_51/usr/src/uts/common/smbsrv/smb_vops.h (revision a90cf9f29973990687fa61de9f1f6ea22e924e40)
1da6c28aaSamw /*
2da6c28aaSamw  * CDDL HEADER START
3da6c28aaSamw  *
4da6c28aaSamw  * The contents of this file are subject to the terms of the
5da6c28aaSamw  * Common Development and Distribution License (the "License").
6da6c28aaSamw  * You may not use this file except in compliance with the License.
7da6c28aaSamw  *
8da6c28aaSamw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9da6c28aaSamw  * or http://www.opensolaris.org/os/licensing.
10da6c28aaSamw  * See the License for the specific language governing permissions
11da6c28aaSamw  * and limitations under the License.
12da6c28aaSamw  *
13da6c28aaSamw  * When distributing Covered Code, include this CDDL HEADER in each
14da6c28aaSamw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15da6c28aaSamw  * If applicable, add the following below this CDDL HEADER, with the
16da6c28aaSamw  * fields enclosed by brackets "[]" replaced with your own identifying
17da6c28aaSamw  * information: Portions Copyright [yyyy] [name of copyright owner]
18da6c28aaSamw  *
19da6c28aaSamw  * CDDL HEADER END
20da6c28aaSamw  */
21da6c28aaSamw /*
22cb174861Sjoyce mcintosh  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
235fd03bc0SGordon Ross  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
24da6c28aaSamw  */
25da6c28aaSamw 
26da6c28aaSamw #ifndef _SMBSRV_SMB_VOPS_H
27da6c28aaSamw #define	_SMBSRV_SMB_VOPS_H
28da6c28aaSamw 
29da6c28aaSamw /*
30da6c28aaSamw  * Common file system interfaces and definitions.
31da6c28aaSamw  */
32da6c28aaSamw 
33da6c28aaSamw #include <sys/types.h>
34da6c28aaSamw #include <sys/param.h>
35da6c28aaSamw #include <sys/file.h>
36da6c28aaSamw #include <sys/time.h>
37da6c28aaSamw #include <sys/mntent.h>
38da6c28aaSamw #include <sys/uio.h>
39da6c28aaSamw #include <sys/vnode.h>
40da6c28aaSamw #include <sys/vfs.h>
41da6c28aaSamw #include <sys/refstr.h>
42da6c28aaSamw #include <sys/acl.h>
438c10a865Sas200622 #include <sys/fcntl.h>
44bbf6f00cSJordan Brown #include <smbsrv/string.h>
45da6c28aaSamw 
46da6c28aaSamw #ifdef __cplusplus
47da6c28aaSamw extern "C" {
48da6c28aaSamw #endif
49da6c28aaSamw 
50da6c28aaSamw #define	XATTR_DIR "xattr_dir"
51da6c28aaSamw 
52da6c28aaSamw #define	SMB_STREAM_PREFIX "SUNWsmb"
53da6c28aaSamw #define	SMB_STREAM_PREFIX_LEN (sizeof (SMB_STREAM_PREFIX) - 1)
54da6c28aaSamw 
55c8ec8eeaSjose borrego #define	SMB_SHORTNAMELEN 14
567f667e74Sjose borrego #define	SMB_MAXDIRSIZE	0x7FFFFFFF
57da6c28aaSamw 
58da6c28aaSamw struct smb_node;
59da6c28aaSamw struct smb_request;
60da6c28aaSamw 
61da6c28aaSamw /*
62da6c28aaSamw  * Note: When specifying the mask for an smb_attr_t,
63da6c28aaSamw  * the sa_mask, and not the sa_vattr.va_mask, should be
64da6c28aaSamw  * filled in.  The #define's that should be used are those
65da6c28aaSamw  * prefixed with SMB_AT_*.  Only FSIL routines should
66da6c28aaSamw  * manipulate the sa_vattr.va_mask field.
67da6c28aaSamw  */
68da6c28aaSamw typedef struct smb_attr {
69da6c28aaSamw 	uint_t		sa_mask;	/* For both vattr and CIFS attr's */
70da6c28aaSamw 	vattr_t		sa_vattr;	/* Legacy vattr */
71da6c28aaSamw 	uint32_t	sa_dosattr;	/* DOS attributes */
72da6c28aaSamw 	timestruc_t	sa_crtime;	/* Creation time */
73e3f2c991SKeyur Desai 	u_offset_t	sa_allocsz;	/* File allocation size in bytes */
74da6c28aaSamw } smb_attr_t;
75da6c28aaSamw 
76da6c28aaSamw #define	SMB_AT_TYPE	0x00001
77da6c28aaSamw #define	SMB_AT_MODE	0x00002
78da6c28aaSamw #define	SMB_AT_UID	0x00004
79da6c28aaSamw #define	SMB_AT_GID	0x00008
80da6c28aaSamw #define	SMB_AT_FSID	0x00010
81da6c28aaSamw #define	SMB_AT_NODEID	0x00020
82da6c28aaSamw #define	SMB_AT_NLINK	0x00040
83da6c28aaSamw #define	SMB_AT_SIZE	0x00080
84da6c28aaSamw #define	SMB_AT_ATIME	0x00100
85da6c28aaSamw #define	SMB_AT_MTIME	0x00200
86da6c28aaSamw #define	SMB_AT_CTIME	0x00400
87da6c28aaSamw #define	SMB_AT_RDEV	0x00800
88da6c28aaSamw #define	SMB_AT_BLKSIZE	0x01000
89da6c28aaSamw #define	SMB_AT_NBLOCKS	0x02000
90da6c28aaSamw #define	SMB_AT_SEQ	0x08000
91da6c28aaSamw 
92da6c28aaSamw #define	SMB_AT_DOSATTR	0x00100000
93da6c28aaSamw #define	SMB_AT_CRTIME	0x00200000
94e3f2c991SKeyur Desai #define	SMB_AT_ALLOCSZ	0x00400000
95e3f2c991SKeyur Desai 
965fd03bc0SGordon Ross /*
975fd03bc0SGordon Ross  * Some useful combinations, for convenience.  Some of the sets are
985fd03bc0SGordon Ross  * based on the info levels of SMB Query File Info.
995fd03bc0SGordon Ross  */
100da6c28aaSamw 
1015fd03bc0SGordon Ross #define	SMB_AT_SMB	(SMB_AT_DOSATTR|SMB_AT_CRTIME|SMB_AT_ALLOCSZ)
102e3f2c991SKeyur Desai 
103037cac00Sjoyce mcintosh #define	SMB_AT_TIMES	(SMB_AT_ATIME | SMB_AT_MTIME |\
104037cac00Sjoyce mcintosh 			SMB_AT_CTIME | SMB_AT_CRTIME)
105da6c28aaSamw 
1065fd03bc0SGordon Ross /* See SMB_FILE_BASIC_INFORMATION */
1075fd03bc0SGordon Ross #define	SMB_AT_BASIC	(SMB_AT_DOSATTR | SMB_AT_TIMES)
1085fd03bc0SGordon Ross 
1095fd03bc0SGordon Ross /* SMB_FILE_STANDARD_INFORMATION (also delete-on-close flag) */
1105fd03bc0SGordon Ross #define	SMB_AT_STANDARD	(SMB_AT_TYPE | SMB_AT_NLINK |\
1115fd03bc0SGordon Ross 			SMB_AT_SIZE | SMB_AT_ALLOCSZ)
1125fd03bc0SGordon Ross 
1135fd03bc0SGordon Ross /*
1145fd03bc0SGordon Ross  * SMB_FILE_ALL_INFORMATION
1155fd03bc0SGordon Ross  * Note: does not include: SMB_AT_UID, SMB_AT_GID, etc.
1165fd03bc0SGordon Ross  * It's not literally "all", but "all SMB cares about"
1175fd03bc0SGordon Ross  * in vattr_t for any of the file query/set info calls.
1185fd03bc0SGordon Ross  */
1195fd03bc0SGordon Ross #define	SMB_AT_ALL	(SMB_AT_BASIC | SMB_AT_STANDARD | SMB_AT_NODEID)
1205fd03bc0SGordon Ross 
121da6c28aaSamw int fhopen(const struct smb_node *, int);
122da6c28aaSamw 
123faa1795aSjb150015 int smb_vop_init(void);
124faa1795aSjb150015 void smb_vop_fini(void);
125faa1795aSjb150015 void smb_vop_start(void);
126faa1795aSjb150015 int smb_vop_open(vnode_t **, int, cred_t *);
127c8ec8eeaSjose borrego void smb_vop_close(vnode_t *, int, cred_t *);
128faa1795aSjb150015 int smb_vop_read(vnode_t *, uio_t *, cred_t *);
1293db3f65cSamw int smb_vop_write(vnode_t *, uio_t *, int, uint32_t *, cred_t *);
130faa1795aSjb150015 int smb_vop_getattr(vnode_t *, vnode_t *, smb_attr_t *, int, cred_t *);
1319660e5cbSJanice Chang int smb_vop_setattr(vnode_t *, vnode_t *, smb_attr_t *, int, cred_t *);
132*a90cf9f2SGordon Ross int smb_vop_space(vnode_t *, int, flock64_t *, int, offset_t, cred_t *);
133faa1795aSjb150015 int smb_vop_access(vnode_t *, int, int, vnode_t *, cred_t *);
134faa1795aSjb150015 void smb_vop_eaccess(vnode_t *, int *, int, vnode_t *, cred_t *);
1358b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States int smb_vop_lookup(vnode_t *, char *, vnode_t **, char *, int, int *, vnode_t *,
1369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States     smb_attr_t *, cred_t *);
137faa1795aSjb150015 int smb_vop_create(vnode_t *, char *, smb_attr_t *, vnode_t **, int, cred_t *,
138faa1795aSjb150015     vsecattr_t *);
139b1352070SAlan Wright int smb_vop_link(vnode_t *, vnode_t *, char *, int, cred_t *);
140faa1795aSjb150015 int smb_vop_remove(vnode_t *, char *, int, cred_t *);
141faa1795aSjb150015 int smb_vop_rename(vnode_t *, char *, vnode_t *, char *, int, cred_t *);
142faa1795aSjb150015 int smb_vop_mkdir(vnode_t *, char *, smb_attr_t *, vnode_t **, int, cred_t *,
143faa1795aSjb150015     vsecattr_t *);
144faa1795aSjb150015 int smb_vop_rmdir(vnode_t *, char *, int, cred_t *);
145e3f2c991SKeyur Desai int smb_vop_readdir(vnode_t *, uint32_t, void *, int *, int *,
146e3f2c991SKeyur Desai     uint32_t, cred_t *);
147faa1795aSjb150015 int smb_vop_commit(vnode_t *, cred_t *);
148faa1795aSjb150015 int smb_vop_statfs(vnode_t *, struct statvfs64 *, cred_t *);
149faa1795aSjb150015 int smb_vop_stream_lookup(vnode_t *, char *, vnode_t **, char *, vnode_t **,
150faa1795aSjb150015     int, vnode_t *, cred_t *);
151faa1795aSjb150015 int smb_vop_stream_create(vnode_t *, char *, smb_attr_t *, vnode_t **,
152faa1795aSjb150015     vnode_t **, int, cred_t *);
153faa1795aSjb150015 int smb_vop_stream_remove(vnode_t *, char *, int, cred_t *);
154faa1795aSjb150015 int smb_vop_lookup_xattrdir(vnode_t *, vnode_t **, int, cred_t *);
155faa1795aSjb150015 int smb_vop_traverse_check(vnode_t **);
156da6c28aaSamw 
157dc20a302Sas200622 int smb_vop_acl_read(vnode_t *, acl_t **, int, acl_type_t, cred_t *);
158dc20a302Sas200622 int smb_vop_acl_write(vnode_t *, acl_t *, int, cred_t *);
159dc20a302Sas200622 acl_type_t smb_vop_acl_type(vnode_t *);
160dc20a302Sas200622 
161dc20a302Sas200622 int smb_vop_shrlock(vnode_t *, uint32_t, uint32_t, uint32_t, cred_t *);
162dc20a302Sas200622 int smb_vop_unshrlock(vnode_t *, uint32_t, cred_t *);
163da6c28aaSamw 
1648c10a865Sas200622 int smb_vop_frlock(vnode_t *, cred_t *, int, flock64_t *);
1658c10a865Sas200622 
166cb174861Sjoyce mcintosh int smb_vop_other_opens(vnode_t *, int);
167cb174861Sjoyce mcintosh 
1688b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States void smb_vop_catia_v4tov5(char *, char *, int);
1698b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States char *smb_vop_catia_v5tov4(char *, char *, int);
1708b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States 
171da6c28aaSamw #ifdef __cplusplus
172da6c28aaSamw }
173da6c28aaSamw #endif
174da6c28aaSamw 
175da6c28aaSamw #endif /* _SMBSRV_SMB_VOPS_H */
176