r3466: split out request.h, signing.h, and smb_server.h
[bbaumbach/samba-autobuild/.git] / source4 / ntvfs / posix / vfs_posix.h
1 /* 
2    Unix SMB/CIFS implementation.
3
4    POSIX NTVFS backend - structure definitions
5
6    Copyright (C) Andrew Tridgell 2004
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #ifndef _VFS_POSIX_H_
24 #define _VFS_POSIX_H_
25
26 #include "smb_server/smb_server.h"
27
28 /* this is the private structure for the posix vfs backend. It is used
29    to hold per-connection (per tree connect) state information */
30 struct pvfs_state {
31         struct smbsrv_tcon *tcon;
32         const char *base_directory;
33
34         const char *share_name;
35         uint_t flags;
36
37         struct pvfs_file *open_files;
38
39         struct pvfs_mangle_context *mangle_ctx;
40
41         struct brl_context *brl_context;
42         struct odb_context *odb_context;
43
44         /* an id tree mapping open search ID to a pvfs_search_state structure */
45         struct idr_context *idtree_search;
46
47         /* an id tree mapping open file handle -> struct pvfs_file */
48         struct idr_context *idtree_fnum;
49 };
50
51
52 /* this is the basic information needed about a file from the filesystem */
53 struct pvfs_dos_fileinfo {
54         NTTIME create_time;
55         NTTIME access_time;
56         NTTIME write_time;
57         NTTIME change_time;
58         uint32_t attrib;
59         uint64_t alloc_size;
60         uint32_t nlink;
61         uint32_t ea_size;
62         uint64_t file_id;
63 };
64
65 /*
66   this is the structure returned by pvfs_resolve_name(). It holds the posix details of
67   a filename passed by the client to any function
68 */
69 struct pvfs_filename {
70         const char *original_name;
71         char *full_name;
72         const char *stream_name;
73         BOOL has_wildcard;
74         BOOL exists;
75         struct stat st;
76         struct pvfs_dos_fileinfo dos;
77 };
78
79
80 /* open file state */
81 struct pvfs_file {
82         struct pvfs_file *next, *prev;
83         int fd;
84         uint16_t fnum;
85         struct pvfs_filename *name;
86
87         /* we need to remember the session it was opened on,
88            as it is illegal to operate on someone elses fnum */
89         struct smbsrv_session *session;
90
91         /* we need to remember the client pid that 
92            opened the file so SMBexit works */
93         uint16_t smbpid;
94
95         /* a unique file key to be used for file locking */
96         DATA_BLOB locking_key;
97
98         /* we need this hook back to our parent for lock destruction */
99         struct pvfs_state *pvfs;
100
101         /* a list of pending locks - used for locking cancel operations */
102         struct pvfs_pending_lock *pending_list;
103
104         /* a count of active locks - used to avoid calling brl_close on
105            file close */
106         uint64_t lock_count;
107
108         uint32_t create_options;
109         uint32_t share_access;
110         uint32_t access_mask;
111
112         /* yes, we need 2 independent positions ... */
113         uint64_t seek_offset;
114         uint64_t position;
115 };
116
117
118 struct pvfs_mangle_context {
119         uint8_t char_flags[256];
120         /*
121           this determines how many characters are used from the original
122           filename in the 8.3 mangled name. A larger value leads to a weaker
123           hash and more collisions.  The largest possible value is 6.
124         */
125         int mangle_prefix;
126         uint32_t mangle_modulus;
127
128         /* we will use a very simple direct mapped prefix cache. The big
129            advantage of this cache structure is speed and low memory usage 
130
131            The cache is indexed by the low-order bits of the hash, and confirmed by
132            hashing the resulting cache entry to match the known hash
133         */
134         char **prefix_cache;
135         uint32_t *prefix_cache_hashes;
136
137         /* this is used to reverse the base 36 mapping */
138         unsigned char base_reverse[256];
139 };
140
141
142
143 /* flags to pvfs_resolve_name() */
144 #define PVFS_RESOLVE_NO_WILDCARD (1<<0)
145 #define PVFS_RESOLVE_STREAMS     (1<<1)
146
147 /* flags in pvfs->flags */
148 #define PVFS_FLAG_CI_FILESYSTEM  (1<<0) /* the filesystem is case insensitive */
149 #define PVFS_FLAG_MAP_ARCHIVE    (1<<1)
150 #define PVFS_FLAG_MAP_SYSTEM     (1<<2)
151 #define PVFS_FLAG_MAP_HIDDEN     (1<<3)
152 #define PVFS_FLAG_READONLY       (1<<4)
153 #define PVFS_FLAG_STRICT_SYNC    (1<<5)
154 #define PVFS_FLAG_STRICT_LOCKING (1<<6)
155
156 /* forward declare some anonymous structures */
157 struct pvfs_dir;
158
159 #endif /* _VFS_POSIX_H_ */