windows: Set ReparsePoint Attribute in FileAttributes
[openafs.git] / src / WINNT / afsrdr / user / RDRPipe.h
1 /*
2  * Copyright (c) 2008 Secure Endpoints, Inc.
3  * Copyright (c) 2009-2011 Your File System, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * - Redistributions of source code must retain the above copyright notice,
10  *   this list of conditions and the following disclaimer.
11  * - Redistributions in binary form must reproduce the above copyright notice,
12  *   this list of conditions and the following disclaimer in the documentation
13  *   and/or other materials provided with the distribution.
14  * - Neither the name of Secure Endpoints Inc. nor the names of its contributors
15  *   may be used to endorse or promote products derived from this software without
16  *   specific prior written permission from Secure Endpoints, Inc. and
17  *   Your File System, Inc.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
23  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 extern void RDR_InitPipe(void);
33
34 extern DWORD RDR_SetupPipe( ULONG index, cm_fid_t *parentFid, cm_fid_t *rootFid,
35                             WCHAR *Name, DWORD NameLength,
36                             cm_user_t *userp);
37
38 extern void RDR_CleanupPipe(ULONG index);
39
40 extern DWORD RDR_Pipe_Read(ULONG index, ULONG BufferLength, void *MappedBuffer,
41                            ULONG *pBytesProcessed, cm_req_t *reqp, cm_user_t *userp);
42
43 extern DWORD RDR_Pipe_Write(ULONG index, ULONG BufferLength, void *MappedBuffer,
44                             cm_req_t *reqp, cm_user_t *userp);
45
46 extern DWORD RDR_Pipe_QueryInfo( ULONG index, ULONG InfoClass,
47                                  ULONG BufferLength, void *MappedBuffer,
48                                  ULONG *pBytesProcessed, cm_req_t *reqp, cm_user_t *userp);
49
50 extern DWORD RDR_Pipe_SetInfo( ULONG index, ULONG InfoClass,
51                                ULONG BufferLength, void *MappedBuffer,
52                                cm_req_t *reqp, cm_user_t *userp);
53
54 #ifdef RDR_PIPE_PRIVATE
55 typedef struct RDR_pipe {
56     struct RDR_pipe *next, *prev;
57     ULONG             index;
58     wchar_t           name[MAX_PATH];
59     cm_fid_t          parentFid;
60     cm_fid_t          rootFid;
61     cm_scache_t      *parentScp;
62     afs_uint32        flags;
63     afs_uint32        devstate;
64     msrpc_conn        rpc_conn;
65
66     /* input side */
67     char *inDatap;                      /* current position
68                                          * in input parameter block */
69     char *inAllocp;                     /* allocated input parameter block */
70     afs_uint32 inCopied;                /* # of input bytes copied in so far
71                                          * by write calls */
72     /* output side */
73     char *outDatap;                     /* output results assembled so far */
74     char *outAllocp;                    /* output results assembled so far */
75     afs_uint32 outCopied;               /* # of output bytes copied back so far */
76 } RDR_pipe_t;
77
78 /* flags for smb_ioctl_t */
79 #define RDR_PIPEFLAG_DATAIN     1       /* reading data from client to server */
80 #define RDR_PIPEFLAG_LOGON      2       /* got tokens from integrated logon */
81 #define RDR_PIPEFLAG_USEUTF8    4       /* this request is using UTF-8 strings */
82 #define RDR_PIPEFLAG_DATAOUT    8       /* sending data from server to client */
83
84 #define RDR_PIPEFLAG_RPC                0x0010
85 #define RDR_PIPEFLAG_MESSAGE_MODE       0x0020
86 #define RDR_PIPEFLAG_BLOCKING           0x0040
87 #define RDR_PIPEFLAG_INCALL             0x0080
88
89 /* Device state constants */
90 #define RDR_DEVICESTATE_READASBYTESTREAM    0x0000
91 #define RDR_DEVICESTATE_READMSGFROMPIPE     0x0100
92 #define RDR_DEVICESTATE_BYTESTREAMPIPE      0x0000
93 #define RDR_DEVICESTATE_MESSAGEMODEPIPE     0x0400
94 #define RDR_DEVICESTATE_PIPECLIENTEND       0x0000
95 #define RDR_DEVICESTATE_PIPESERVEREND       0x4000
96 #define RDR_DEVICESTATE_BLOCKING            0x8000
97
98 #define RDR_PIPE_MAXDATA        65536
99
100 /* procedure implementing an pipe */
101 typedef long (RDR_pipeProc_t)(RDR_pipe_t *, struct cm_user *userp);
102
103 extern RDR_pipe_t *RDR_FindPipe(ULONG index, int locked);
104
105 /*
106  * DDK Data Structures
107  *
108  * This is a userland module and does not include DDK headers.
109  * Replicate the DDK Data Structures required for pipe handling
110  * based on [MS-FSC]: File System Control Codes
111  *   http://msdn.microsoft.com/en-us/library/cc231987%28v=PROT.13%29.aspx
112  */
113 typedef enum _FILE_INFORMATION_CLASS {
114     FileDirectoryInformation         = 1,
115     FileFullDirectoryInformation,   // 2
116     FileBothDirectoryInformation,   // 3
117     FileBasicInformation,           // 4
118     FileStandardInformation,        // 5
119     FileInternalInformation,        // 6
120     FileEaInformation,              // 7
121     FileAccessInformation,          // 8
122     FileNameInformation,            // 9
123     FileRenameInformation,          // 10
124     FileLinkInformation,            // 11
125     FileNamesInformation,           // 12
126     FileDispositionInformation,     // 13
127     FilePositionInformation,        // 14
128     FileFullEaInformation,          // 15
129     FileModeInformation,            // 16
130     FileAlignmentInformation,       // 17
131     FileAllInformation,             // 18
132     FileAllocationInformation,      // 19
133     FileEndOfFileInformation,       // 20
134     FileAlternateNameInformation,   // 21
135     FileStreamInformation,          // 22
136     FilePipeInformation,            // 23
137     FilePipeLocalInformation,       // 24
138     FilePipeRemoteInformation,      // 25
139     FileMailslotQueryInformation,   // 26
140     FileMailslotSetInformation,     // 27
141     FileCompressionInformation,     // 28
142     FileObjectIdInformation,        // 29
143     FileCompletionInformation,      // 30
144     FileMoveClusterInformation,     // 31
145     FileQuotaInformation,           // 32
146     FileReparsePointInformation,    // 33
147     FileNetworkOpenInformation,     // 34
148     FileAttributeTagInformation,    // 35
149     FileTrackingInformation,        // 36
150     FileIdBothDirectoryInformation, // 37
151     FileIdFullDirectoryInformation, // 38
152     FileValidDataLengthInformation, // 39
153     FileShortNameInformation,       // 40
154     FileIoCompletionNotificationInformation, // 41
155     FileIoStatusBlockRangeInformation,       // 42
156     FileIoPriorityHintInformation,           // 43
157     FileSfioReserveInformation,              // 44
158     FileSfioVolumeInformation,               // 45
159     FileHardLinkInformation,                 // 46
160     FileProcessIdsUsingFileInformation,      // 47
161     FileNormalizedNameInformation,           // 48
162     FileNetworkPhysicalNameInformation,      // 49
163     FileIdGlobalTxDirectoryInformation,      // 50
164     FileIsRemoteDeviceInformation,           // 51
165     FileAttributeCacheInformation,           // 52
166     FileNumaNodeInformation,                 // 53
167     FileStandardLinkInformation,             // 54
168     FileRemoteProtocolInformation,           // 55
169     FileMaximumInformation
170 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
171
172 typedef struct _FILE_BASIC_INFORMATION {
173     LARGE_INTEGER CreationTime;
174     LARGE_INTEGER LastAccessTime;
175     LARGE_INTEGER LastWriteTime;
176     LARGE_INTEGER ChangeTime;
177     ULONG FileAttributes;
178 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
179
180 typedef struct _FILE_STANDARD_INFORMATION {
181     LARGE_INTEGER AllocationSize;
182     LARGE_INTEGER EndOfFile;
183     ULONG NumberOfLinks;
184     BOOLEAN DeletePending;
185     BOOLEAN IsDirectory;
186 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
187
188 typedef struct _FILE_NAME_INFORMATION {
189     ULONG FileNameLength;
190     WCHAR FileName[1];
191 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
192
193 typedef struct _FILE_PIPE_INFORMATION {
194      ULONG ReadMode;
195      ULONG CompletionMode;
196 } FILE_PIPE_INFORMATION, *PFILE_PIPE_INFORMATION;
197
198 typedef struct _FILE_PIPE_LOCAL_INFORMATION {
199      ULONG NamedPipeType;
200      ULONG NamedPipeConfiguration;
201      ULONG MaximumInstances;
202      ULONG CurrentInstances;
203      ULONG InboundQuota;
204      ULONG ReadDataAvailable;
205      ULONG OutboundQuota;
206      ULONG WriteQuotaAvailable;
207      ULONG NamedPipeState;
208      ULONG NamedPipeEnd;
209 } FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION;
210
211 typedef struct _FILE_PIPE_REMOTE_INFORMATION {
212      LARGE_INTEGER CollectDataTime;
213      ULONG MaximumCollectionCount;
214 } FILE_PIPE_REMOTE_INFORMATION, *PFILE_PIPE_REMOTE_INFORMATION;
215
216 #define FILE_PIPE_BYTE_STREAM_TYPE          0x00000000
217 #define FILE_PIPE_MESSAGE_TYPE              0x00000001
218
219 #define FILE_PIPE_ACCEPT_REMOTE_CLIENTS     0x00000000
220 #define FILE_PIPE_REJECT_REMOTE_CLIENTS     0x00000002
221 #define FILE_PIPE_TYPE_VALID_MASK           0x00000003
222
223 #define FILE_PIPE_QUEUE_OPERATION           0x00000000
224 #define FILE_PIPE_COMPLETE_OPERATION        0x00000001
225
226 #define FILE_PIPE_BYTE_STREAM_MODE          0x00000000
227 #define FILE_PIPE_MESSAGE_MODE              0x00000001
228
229 #define FILE_PIPE_INBOUND                   0x00000000
230 #define FILE_PIPE_OUTBOUND                  0x00000001
231 #define FILE_PIPE_FULL_DUPLEX               0x00000002
232
233 #define FILE_PIPE_DISCONNECTED_STATE        0x00000001
234 #define FILE_PIPE_LISTENING_STATE           0x00000002
235 #define FILE_PIPE_CONNECTED_STATE           0x00000003
236 #define FILE_PIPE_CLOSING_STATE             0x00000004
237
238 #define FILE_PIPE_CLIENT_END                0x00000000
239 #define FILE_PIPE_SERVER_END                0x00000001
240
241 #define FILE_PIPE_READ_DATA                 0x00000000
242 #define FILE_PIPE_WRITE_SPACE               0x00000001
243 #endif
244