xref: /illumos-gate/usr/src/uts/common/smbsrv/smb_vops.h (revision 1d0ec46fafb49266ae79840a692bb48af60ade70)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23  * Copyright 2013-2021 Tintri by DDN, Inc. All rights reserved.
24  * Copyright 2023 RackTop Systems, Inc.
25  */
26 
27 #ifndef _SMBSRV_SMB_VOPS_H
28 #define	_SMBSRV_SMB_VOPS_H
29 
30 /*
31  * Common file system interfaces and definitions.
32  */
33 
34 #include <sys/types.h>
35 #include <sys/param.h>
36 #include <sys/file.h>
37 #include <sys/time.h>
38 #include <sys/mntent.h>
39 #include <sys/uio.h>
40 #include <sys/vnode.h>
41 #include <sys/vfs.h>
42 #include <sys/refstr.h>
43 #include <sys/acl.h>
44 #include <sys/fcntl.h>
45 #include <smbsrv/string.h>
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 #define	XATTR_DIR "xattr_dir"
52 
53 #define	SMB_STREAM_PREFIX "SUNWsmb"
54 #define	SMB_STREAM_PREFIX_LEN (sizeof (SMB_STREAM_PREFIX) - 1)
55 
56 #define	SMB_SHORTNAMELEN 14
57 #define	SMB_MAXDIRSIZE	0x7FFFFFFF
58 
59 struct smb_node;
60 struct smb_request;
61 
62 /*
63  * Note: When specifying the mask for an smb_attr_t,
64  * the sa_mask, and not the sa_vattr.va_mask, should be
65  * filled in.  The #define's that should be used are those
66  * prefixed with SMB_AT_*.  Only FSIL routines should
67  * manipulate the sa_vattr.va_mask field.
68  */
69 typedef struct smb_attr {
70 	uint_t		sa_mask;	/* For both vattr and CIFS attr's */
71 	vattr_t		sa_vattr;	/* Legacy vattr */
72 	uint32_t	sa_dosattr;	/* DOS attributes */
73 	timestruc_t	sa_crtime;	/* Creation time */
74 	u_offset_t	sa_allocsz;	/* File allocation size in bytes */
75 } smb_attr_t;
76 
77 #define	SMB_AT_TYPE	0x00001
78 #define	SMB_AT_MODE	0x00002
79 #define	SMB_AT_UID	0x00004
80 #define	SMB_AT_GID	0x00008
81 #define	SMB_AT_FSID	0x00010
82 #define	SMB_AT_NODEID	0x00020
83 #define	SMB_AT_NLINK	0x00040
84 #define	SMB_AT_SIZE	0x00080
85 #define	SMB_AT_ATIME	0x00100
86 #define	SMB_AT_MTIME	0x00200
87 #define	SMB_AT_CTIME	0x00400
88 #define	SMB_AT_RDEV	0x00800
89 #define	SMB_AT_BLKSIZE	0x01000
90 #define	SMB_AT_NBLOCKS	0x02000
91 #define	SMB_AT_SEQ	0x08000
92 
93 #define	SMB_AT_DOSATTR	0x00100000
94 #define	SMB_AT_CRTIME	0x00200000
95 #define	SMB_AT_ALLOCSZ	0x00400000
96 
97 /*
98  * Some useful combinations, for convenience.  Some of the sets are
99  * based on the info levels of SMB Query File Info.
100  */
101 
102 #define	SMB_AT_SMB	(SMB_AT_DOSATTR|SMB_AT_CRTIME|SMB_AT_ALLOCSZ)
103 
104 #define	SMB_AT_TIMES	(SMB_AT_ATIME | SMB_AT_MTIME |\
105 			SMB_AT_CTIME | SMB_AT_CRTIME)
106 
107 /* See SMB_FILE_BASIC_INFORMATION */
108 #define	SMB_AT_BASIC	(SMB_AT_DOSATTR | SMB_AT_TIMES)
109 
110 /* SMB_FILE_STANDARD_INFORMATION (also delete-on-close flag) */
111 #define	SMB_AT_STANDARD	(SMB_AT_TYPE | SMB_AT_NLINK |\
112 			SMB_AT_SIZE | SMB_AT_ALLOCSZ)
113 
114 /*
115  * SMB_FILE_ALL_INFORMATION
116  * Note: does not include: SMB_AT_UID, SMB_AT_GID, etc.
117  * It's not literally "all", but "all SMB cares about"
118  * in vattr_t for any of the file query/set info calls.
119  */
120 #define	SMB_AT_ALL	(SMB_AT_BASIC | SMB_AT_STANDARD | SMB_AT_NODEID)
121 
122 int fhopen(const struct smb_node *, int);
123 
124 int smb_vop_init(void);
125 void smb_vop_fini(void);
126 void smb_vop_start(void);
127 int smb_vop_open(vnode_t **, int, cred_t *);
128 void smb_vop_close(vnode_t *, int, cred_t *);
129 int smb_vop_read(vnode_t *, uio_t *, int, cred_t *);
130 int smb_vop_write(vnode_t *, uio_t *, int, uint32_t *, cred_t *);
131 int smb_vop_ioctl(vnode_t *, int, void *, cred_t *);
132 int smb_vop_reqzcbuf(vnode_t *, int, xuio_t *, cred_t *);
133 int smb_vop_retzcbuf(vnode_t *, xuio_t *, cred_t *);
134 int smb_vop_getattr(vnode_t *, vnode_t *, smb_attr_t *, int, cred_t *);
135 int smb_vop_setattr(vnode_t *, vnode_t *, smb_attr_t *, int, cred_t *);
136 int smb_vop_space(vnode_t *, int, flock64_t *, int, offset_t, cred_t *);
137 int smb_vop_access(vnode_t *, int, int, vnode_t *, cred_t *);
138 void smb_vop_eaccess(vnode_t *, int *, int, vnode_t *, cred_t *);
139 int smb_vop_lookup(vnode_t *, char *, vnode_t **, char *, int, int *, vnode_t *,
140     smb_attr_t *, cred_t *);
141 int smb_vop_create(vnode_t *, char *, smb_attr_t *, vnode_t **, int, cred_t *,
142     vsecattr_t *);
143 int smb_vop_link(vnode_t *, vnode_t *, char *, int, cred_t *);
144 int smb_vop_remove(vnode_t *, char *, int, cred_t *);
145 int smb_vop_rename(vnode_t *, char *, vnode_t *, char *, int, cred_t *);
146 int smb_vop_mkdir(vnode_t *, char *, smb_attr_t *, vnode_t **, int, cred_t *,
147     vsecattr_t *);
148 int smb_vop_rmdir(vnode_t *, char *, int, cred_t *);
149 int smb_vop_readdir(vnode_t *, uint32_t, void *, int *, int *,
150     uint32_t, cred_t *);
151 int smb_vop_commit(vnode_t *, cred_t *);
152 int smb_vop_statfs(vnode_t *, struct statvfs64 *, cred_t *);
153 int smb_vop_stream_lookup(vnode_t *, char *, vnode_t **, char *, vnode_t **,
154     int, vnode_t *, cred_t *);
155 int smb_vop_stream_create(vnode_t *, char *, smb_attr_t *, vnode_t **,
156     vnode_t **, int, cred_t *);
157 int smb_vop_stream_remove(vnode_t *, char *, int, cred_t *);
158 int smb_vop_lookup_xattrdir(vnode_t *, vnode_t **, int, cred_t *);
159 int smb_vop_traverse_check(vnode_t **);
160 
161 int smb_vop_acl_read(vnode_t *, acl_t **, int, acl_type_t, cred_t *);
162 int smb_vop_acl_write(vnode_t *, acl_t *, int, cred_t *);
163 acl_type_t smb_vop_acl_type(vnode_t *);
164 
165 int smb_vop_shrlock(vnode_t *, uint32_t, uint32_t, uint32_t, cred_t *);
166 int smb_vop_unshrlock(vnode_t *, uint32_t, cred_t *);
167 
168 int smb_vop_frlock(vnode_t *, cred_t *, int, flock64_t *);
169 
170 int smb_vop_other_opens(vnode_t *, int);
171 
172 void smb_vop_catia_v4tov5(char *, char *, int);
173 char *smb_vop_catia_v5tov4(char *, char *, int);
174 
175 boolean_t smb_vop_priv_check(cred_t *, int, boolean_t, vnode_t *);
176 
177 #ifdef __cplusplus
178 }
179 #endif
180 
181 #endif /* _SMBSRV_SMB_VOPS_H */
182