2 * Copyright (c) 2008-2011 Kernel Drivers, LLC.
3 * Copyright (c) 2009-2011 Your File System, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * - Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
14 * this list of conditions and the following disclaimer in the
16 * and/or other materials provided with the distribution.
17 * - Neither the name of Kernel Drivers, LLC nor the names of its
19 * used to endorse or promote products derived from this software without
20 * specific prior written permission from Kernel Drivers, LLC
21 * and Your File System, Inc.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
26 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
27 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #ifndef _AFS_USER_STRUCT_H
37 #define _AFS_USER_STRUCT_H
39 typedef struct _AFS_FILE_ID
55 // This control structure is the request block passed to the filter. The filter will populate the structure
56 // when it requires a request to be handled by the service.
59 typedef struct _AFS_COMM_REQUEST_BLOCK
62 AFSFileID FileId; /* Initialize unused elements to 0 */
66 ULONG RequestIndex; /* Must return to caller */
68 ULONG RequestFlags; /* AFS_REQUEST_FLAG_xxxx */
70 ULONG NameLength; // Length of the name in bytes
72 ULONG DataOffset; // This offset is from the end of the structure, including the name
76 GUID AuthGroup; // Length: sizeof(GUID) */
78 ULONG ResultBufferLength; /* Do not exceed this length in response */
80 LONG QueueCount; // Current outstanding requests in the queue
88 // This is the result block passed back to the redirector after a request has been handled
91 typedef struct _AFS_COMM_RESULT_BLOCK
94 ULONG RequestIndex; /* Must match the AFSCommRequest value */
96 ULONG ResultStatus; /* NTSTATUS_xxx */
98 ULONG ResultBufferLength; /* Not to exceed AFSCommRequest ResultBufferLength */
100 ULONG Reserved; /* To ease Quad Alignment */
107 // Control block passed to IOCTL_AFS_INITIALIZE_REDIRECTOR_DEVICE
110 #define AFS_REDIR_INIT_FLAG_HIDE_DOT_FILES 0x00000001
112 #define AFS_REDIR_INIT_NO_PAGING_FILE 0x00000002
114 typedef struct _AFS_REDIR_INIT_INFO_CB
119 ULONG MaximumChunkLength; // Maximum RPC length issued so we should limit
120 // requests for data to this length
122 AFSFileID GlobalFileId; // AFS FID of the Global root.afs volume
124 LARGE_INTEGER ExtentCount; // Number of extents in the current data cache
126 ULONG CacheBlockSize; // Size, in bytes, of the current cache block
128 ULONG MaxPathLinkCount; // Number of symlinks / mountpoints that may
129 // be cross during the evaluation of any path
131 ULONG NameArrayLength; // Number of components that should be allocated
132 // in each name array chunk. Name arrays are
133 // dynamic and will be increased in size as
134 // needed by this amount
136 LARGE_INTEGER MemoryCacheOffset; // The offset in the afsd_service process memory
137 // space at which the extents are allocated
138 LARGE_INTEGER MemoryCacheLength; // and the length of the allocated region
140 ULONG DumpFileLocationOffset; // Offset from the beginning of this structure to
141 // the start of the directory where dump files
142 // are to be stored. The path must be fully
143 // qualified such as C:\Windows\Temp
145 ULONG DumpFileLocationLength; // Length, in bytes, of the DumpFileLocation path
147 ULONG CacheFileNameLength; // size, in bytes, of the cache file name
149 WCHAR CacheFileName[ 1]; // Fully qualified cache file name in the form
150 // C:\OPenAFSDir\CacheFile.dat
152 } AFSRedirectorInitInfo;
155 // Directory query CB
158 typedef struct _AFS_DIR_QUERY_CB
161 ULONG_PTR EnumHandle; // If this is 0 then it is a new query,
162 // otherwise it is the FileIndex of the last
168 // Directory enumeration control block
169 // Entries are aligned on a QuadWord boundary
172 typedef struct _AFS_DIR_ENUM_ENTRY
177 ULONG FileIndex; /* Incremented */
179 LARGE_INTEGER Expiration; /* FILETIME */
181 LARGE_INTEGER DataVersion;
183 ULONG FileType; /* File, Dir, MountPoint, Symlink */
185 LARGE_INTEGER CreationTime; /* FILETIME */
187 LARGE_INTEGER LastAccessTime; /* FILETIME */
189 LARGE_INTEGER LastWriteTime; /* FILETIME */
191 LARGE_INTEGER ChangeTime; /* FILETIME */
193 LARGE_INTEGER EndOfFile;
195 LARGE_INTEGER AllocationSize;
197 ULONG FileAttributes; /* NTFS FILE_ATTRIBUTE_xxxx see below */
199 ULONG FileNameLength;
205 ULONG FileNameOffset; /* From beginning of this structure */
207 ULONG TargetNameOffset; /* From beginning of this structure */
209 ULONG TargetNameLength;
211 AFSFileID TargetFileId; /* Target fid for mp's and symlinks */
213 CCHAR ShortNameLength;
217 /* Long Filename and Target (Symlink and MountPoint only) to follow without NULs */
222 typedef struct _AFS_DIR_ENUM_RESP
225 ULONG_PTR EnumHandle;
227 AFSDirEnumEntry Entry[ 1]; /* Each entry is Quad aligned */
232 // Volume information CB passed in the create request
235 typedef struct _AFS_VOLUME_INFORMATION
238 LARGE_INTEGER TotalAllocationUnits; /* Partition Max Blocks */
240 LARGE_INTEGER AvailableAllocationUnits; /* Partition Blocks Avail */
242 LARGE_INTEGER VolumeCreationTime; /* AFS Last Update - Not Creation */
244 ULONG Characteristics; /* FILE_READ_ONLY_DEVICE (if readonly)
245 * FILE_REMOTE_DEVICE (always)
248 ULONG FileSystemAttributes; /* FILE_CASE_PRESERVED_NAMES (always)
249 FILE_UNICODE_ON_DISK (always) */
251 ULONG SectorsPerAllocationUnit; /* = 1 */
253 ULONG BytesPerSector; /* = 1024 */
255 ULONG CellID; /* AFS Cell ID */
257 ULONG VolumeID; /* AFS Volume ID */
259 ULONG VolumeLabelLength;
261 WCHAR VolumeLabel[20]; /* Volume:Cell */
269 typedef struct _AFS_FILE_CREATE_CB
274 LARGE_INTEGER AllocationSize;
276 ULONG FileAttributes;
284 typedef struct _AFS_FILE_CREATE_RESULT_CB
287 LARGE_INTEGER ParentDataVersion;
289 AFSDirEnumEntry DirEnum;
291 } AFSFileCreateResultCB;
297 typedef struct _AFS_FILE_OPEN_CB
308 typedef struct _AFS_FILE_OPEN_RESULT_CB
313 } AFSFileOpenResultCB;
316 // IO Interace control blocks for extent processing when performing
317 // queries via the AFS_REQUEST_TYPE_REQUEST_FILE_EXTENTS or synchronous
318 // results from the service
321 typedef struct _AFS_FILE_EXTENT_CB
328 LARGE_INTEGER FileOffset;
330 LARGE_INTEGER CacheOffset;
340 typedef struct _AFS_REQUEST_EXTENTS_CB
345 LARGE_INTEGER ByteOffset;
349 } AFSRequestExtentsCB;
352 // Extent processing when the file system calls the service to
353 // release extents through the AFS_REQUEST_TYPE_RELEASE_FILE_EXTENTS interface
356 typedef struct _AFS_RELEASE_EXTENTS_CB
363 LARGE_INTEGER LastAccessTime;
365 LARGE_INTEGER LastWriteTime;
367 LARGE_INTEGER ChangeTime;
369 LARGE_INTEGER CreateTime;
371 LARGE_INTEGER AllocationSize;
373 AFSFileExtentCB FileExtents[ 1];
375 } AFSReleaseExtentsCB;
378 // This is the control structure used when the service passes the extent
379 // information via the IOCTL_AFS_SET_FILE_EXTENTS interface
382 typedef struct _AFS_SET_FILE_EXTENTS_CB
391 AFSFileExtentCB FileExtents[ 1];
393 } AFSSetFileExtentsCB;
396 // This is the control structure used when the service passes the extent
397 // information via the IOCTL_AFS_RELEASE_FILE_EXTENTS interface
400 #define AFS_RELEASE_EXTENTS_FLAGS_RELEASE_ALL 0x00000001
402 typedef struct _AFS_RELEASE_FILE_EXTENTS_CB
411 LARGE_INTEGER HeldExtentCount;
413 AFSFileExtentCB FileExtents[ 1];
415 } AFSReleaseFileExtentsCB;
418 // These are the control structures that the filesystem returns from a
419 // IOCTL_AFS_RELEASE_FILE_EXTENTS
422 typedef struct _AFS_RELEASE_FILE_EXTENTS_RESULT_FILE_CB
428 GUID AuthGroup; /* Length: sizeof(GUID) */
432 LARGE_INTEGER LastAccessTime;
434 LARGE_INTEGER LastWriteTime;
436 LARGE_INTEGER ChangeTime;
438 LARGE_INTEGER CreateTime;
440 LARGE_INTEGER AllocationSize;
442 AFSFileExtentCB FileExtents[ 1];
444 } AFSReleaseFileExtentsResultFileCB;
446 typedef struct _AFS_RELEASE_FILE_EXTENTS_RESULT_CB
454 AFSReleaseFileExtentsResultFileCB Files[ 1];
456 } AFSReleaseFileExtentsResultCB;
459 typedef struct _AFS_EXTENT_FAILURE_CB
466 } AFSExtentFailureCB;
472 typedef struct _AFS_FILE_UPDATE_CB
477 LARGE_INTEGER LastAccessTime;
479 LARGE_INTEGER LastWriteTime;
481 LARGE_INTEGER ChangeTime;
483 LARGE_INTEGER CreateTime;
485 LARGE_INTEGER AllocationSize;
487 ULONG FileAttributes;
496 // File update CB result
499 typedef struct _AFS_FILE_UPDATE_RESULT_CB
502 AFSDirEnumEntry DirEnum;
504 } AFSFileUpdateResultCB;
510 typedef struct _AFS_FILE_DELETE_CB
513 AFSFileID ParentId; /* Must be directory */
517 /* File Name and FileID in Common Request Block */
521 typedef struct _AFS_FILE_DELETE_RESULT_CB
524 LARGE_INTEGER ParentDataVersion;
526 } AFSFileDeleteResultCB;
532 typedef struct _AFS_FILE_RENAME_CB
535 AFSFileID SourceParentId; /* Must be directory */
537 AFSFileID TargetParentId; /* Must be directory */
539 /* Source Name and FileID in Common Request Block */
541 USHORT TargetNameLength;
543 WCHAR TargetName[ 1];
547 typedef struct _AFS_FILE_RENAME_RESULT_CB
550 LARGE_INTEGER SourceParentDataVersion;
552 LARGE_INTEGER TargetParentDataVersion;
554 AFSDirEnumEntry DirEnum;
556 } AFSFileRenameResultCB;
560 // Control structures for AFS_REQUEST_TYPE_EVAL_TARGET_BY_ID
561 // and AFS_REQUEST_TYPE_EVAL_TARGET_BY_NAME
563 // The response to these requests is a AFSDirEnumEntry
566 typedef struct _AFS_FILE_EVAL_TARGET_CB
575 // Control structure for read and write requests through the PIOCtl interface
577 // CommRequest FileId field contains the active directory
579 typedef struct _AFS_PIOCTL_IO_CB
589 } AFSPIOCtlIORequestCB;
592 // The returned information for the IO Request
595 typedef struct _AFS_PIOCTL_IO_RESULT_CB
598 ULONG BytesProcessed;
600 } AFSPIOCtlIOResultCB;
604 // Control structure for open and close requests through the PIOCtl interface
606 // CommRequest FileId field contains the active directory
608 // There is no return structure.
610 typedef struct _AFS_PIOCTL_OPEN_CLOSE_CB
617 } AFSPIOCtlOpenCloseRequestCB;
620 // Cache invalidation control block
623 typedef struct _AFS_INVALIDATE_CACHE_CB
634 } AFSInvalidateCacheCB;
637 // Network Status Control Block
640 typedef struct _AFS_NETWORK_STATUS_CB
645 } AFSNetworkStatusCB;
648 // Volume Status Control Block
651 typedef struct _AFS_VOLUME_STATUS_CB
654 AFSFileID FileID; // only cell and volume fields are set
661 typedef struct _AFS_SYSNAME
664 ULONG Length; /* bytes */
666 WCHAR String[AFS_MAX_SYSNAME_LENGTH];
671 // SysName Notification Control Block
672 // Sent as the buffer with IOCTL_AFS_SYSNAME_NOTIFICATION
673 // There is no response
676 typedef struct _AFS_SYSNAME_NOTIFICATION_CB
683 AFSSysName SysNames[1];
685 } AFSSysNameNotificationCB;
689 // File System Status Query Control Block
690 // Received as a response to IOCTL_AFS_STATUS_REQUEST
692 typedef struct _AFS_DRIVER_STATUS_RESPONSE_CB
695 ULONG Status; // bit flags - see below
697 } AFSDriverStatusRespCB;
700 #define AFS_DRIVER_STATUS_READY 0
701 #define AFS_DRIVER_STATUS_NOT_READY 1
702 #define AFS_DRIVER_STATUS_NO_SERVICE 2
705 // Byte Range Lock Request
707 typedef struct _AFS_BYTE_RANGE_LOCK_REQUEST
711 LARGE_INTEGER Offset;
713 LARGE_INTEGER Length;
715 } AFSByteRangeLockRequest;
717 #define AFS_BYTE_RANGE_LOCK_TYPE_SHARED 0
718 #define AFS_BYTE_RANGE_LOCK_TYPE_EXCL 1
722 // Byte Range Lock Request Control Block
724 // Set ProcessId and FileId in the Comm Request Block
726 typedef struct _AFS_BYTE_RANGE_LOCK_REQUEST_CB
733 AFSByteRangeLockRequest Request[1];
735 } AFSByteRangeLockRequestCB;
738 // Byte Range Lock Result
740 typedef struct _AFS_BYTE_RANGE_LOCK_RESULT
745 LARGE_INTEGER Offset;
747 LARGE_INTEGER Length;
751 } AFSByteRangeLockResult;
754 // Byte Range Lock Results Control Block
757 typedef struct _AFS_BYTE_RANGE_LOCK_RESULT_CB
764 AFSByteRangeLockResult Result[1];
766 } AFSByteRangeLockResultCB;
769 // Set Byte Range Lock Results Control Block
772 typedef struct _AFS_SET_BYTE_RANGE_LOCK_RESULT_CB
781 AFSByteRangeLockResult Result[1];
783 } AFSSetByteRangeLockResultCB;
787 // Byte Range Unlock Request Control Block
790 typedef struct _AFS_BYTE_RANGE_UNLOCK_CB
797 AFSByteRangeLockRequest Request[1];
799 } AFSByteRangeUnlockRequestCB;
803 // Byte Range Unlock Request Control Block
806 typedef struct _AFS_BYTE_RANGE_UNLOCK_RESULT_CB
811 AFSByteRangeLockResult Result[1];
813 } AFSByteRangeUnlockResultCB;
817 // Control structure for read and write requests through the PIPE interface
819 // CommRequest FileId field contains the active directory
821 typedef struct _AFS_PIPE_IO_CB
829 } AFSPipeIORequestCB; // For read requests the buffer is mapped in the request cb block.
830 // For write requests, the buffer immediately follows this structure
833 // The returned information for the Pipe IO Request. Note that this is
834 // only returned in the write request. Read request info is returned in
838 typedef struct _AFS_PIPE_IO_RESULT_CB
841 ULONG BytesProcessed;
846 // Control structure for set and query info requests through the PIPE interface
849 typedef struct _AFS_PIPE_INFO_CB
856 ULONG InformationClass;
860 } AFSPipeInfoRequestCB; // For query info requests the buffer is mapped in the request cb block.
861 // For set info requests, the buffer immediately follows this structure
864 // Control structure for open and close requests through the Pipe interface
866 // CommRequest FileId field contains the active directory
868 // There is no return structure.
870 typedef struct _AFS_PIPE_OPEN_CLOSE_CB
877 } AFSPipeOpenCloseRequestCB;
881 // Hold Fid Request Control Block
884 typedef struct _AFS_HOLD_FID_REQUEST_CB
889 AFSFileID FileID[ 1];
891 } AFSHoldFidRequestCB;
894 typedef struct _AFS_FID_RESULT
903 typedef struct _AFS_HOLD_FID_RESULT_CB
908 AFSFidResult Result[ 1];
910 } AFSHoldFidResultCB;
914 // Release Fid Request Control Block
917 typedef struct _AFS_RELEASE_FID_REQUEST_CB
922 AFSFileID FileID[ 1];
924 } AFSReleaseFidRequestCB;
926 typedef struct _AFS_RELEASE_FID_RESULT_CB
931 AFSFidResult Result[ 1];
933 } AFSReleaseFidResultCB;
940 typedef struct _AFS_FILE_CLEANUP_CB
945 LARGE_INTEGER LastAccessTime;
947 LARGE_INTEGER LastWriteTime;
949 LARGE_INTEGER ChangeTime;
951 LARGE_INTEGER CreateTime;
953 LARGE_INTEGER AllocationSize;
955 ULONG FileAttributes;
962 // Trace configuration cb
965 typedef struct _AFS_DEBUG_TRACE_CONFIG_CB
972 ULONG TraceBufferLength;
979 // Object Status Information request
982 typedef struct _AFS_REDIR_GET_OBJECT_STATUS_CB
987 USHORT FileNameLength;
991 } AFSGetStatusInfoCB;
993 typedef struct _AFS_REDIR_OBJECT_STATUS_CB
998 AFSFileID TargetFileId;
1000 LARGE_INTEGER Expiration; /* FILETIME */
1002 LARGE_INTEGER DataVersion;
1004 ULONG FileType; /* File, Dir, MountPoint, Symlink */
1008 LARGE_INTEGER CreationTime; /* FILETIME */
1010 LARGE_INTEGER LastAccessTime; /* FILETIME */
1012 LARGE_INTEGER LastWriteTime; /* FILETIME */
1014 LARGE_INTEGER ChangeTime; /* FILETIME */
1016 ULONG FileAttributes; /* NTFS FILE_ATTRIBUTE_xxxx see below */
1018 LARGE_INTEGER EndOfFile;
1020 LARGE_INTEGER AllocationSize;
1029 // Auth Group (Process and Thread) Processing
1031 // afsredir.sys implements a set of generic Authentication Group
1032 // operations that can be executed by processes. The model supports
1033 // one or more authentication groups per process. A process may switch
1034 // the active AuthGroup for any thread to any other AuthGroup the process
1035 // is a member of. However, processes cannot assign itself to an
1036 // AuthGroup that it is not presently a member of. A process can reset
1037 // its AuthGroup to the SID-AuthGroup or can create a new AuthGroup that
1038 // has not previously been used.
1040 // IOCTL_AFS_AUTHGROUP_CREATE_AND_SET
1041 // Creates a new AuthGroup and either activates it for
1042 // the process or the current thread. If set as the
1043 // new process AuthGroup, the prior AuthGroup list is
1046 // IOCTL_AFS_AUTHGROUP_QUERY
1047 // Returns a list of the AuthGroup GUIDS associated
1048 // with the current process, the current process GUID,
1049 // and the current thread GUID.
1051 // IOCTL_AFS_AUTHGROUP_SET
1052 // Permits the current AuthGroup for the process or
1053 // thread to be set to the specified GUID. The GUID
1054 // must be in the list of current values for the process.
1056 // IOCTL_AFS_AUTHGROUP_RESET
1057 // Resets the current AuthGroup for the process or
1058 // thread to the SID-AuthGroup
1060 // IOCTL_AFS_AUTHGROUP_SID_CREATE
1061 // Given a SID as input, assigns a new AuthGroup GUID.
1062 // (May only be executed by LOCAL_SYSTEM or the active SID)
1064 // IOCTL_AFS_AUTHGROUP_SID_QUERY
1065 // Given a SID as input, returns the associated AuthGroup GUID.
1067 // IOCTL_AFS_AUTHGROUP_LOGON_CREATE
1068 // Given a logon Session as input, assigns a new AuthGroup GUID.
1069 // (May only be executed by LOCAL_SYSTEM.)
1071 // New processes inherit only the active AuthGroup at the time of process
1072 // creation. Either that of the active thread (if set) or the process.
1073 // All of the other AuthGroups associated with a parent process are
1078 // Auth Group processing flags
1081 #define AFS_PAG_FLAGS_SET_AS_ACTIVE 0x00000001 // If set, the newly created authgroup is set to the active group
1082 #define AFS_PAG_FLAGS_THREAD_AUTH_GROUP 0x00000002 // If set, the request is targeted for the thread not the process
1084 typedef struct _AFS_AUTH_GROUP_REQUEST
1087 USHORT SIDLength; // If zero the SID of the caller is used
1089 ULONG SessionId; // If -1 the session id of the caller is used
1093 GUID AuthGroup; // The auth group for certain requests
1095 WCHAR SIDString[ 1];
1097 } AFSAuthGroupRequestCB;
1100 // Reparse tag AFS Specific information buffer
1103 #define OPENAFS_SUBTAG_MOUNTPOINT 1
1104 #define OPENAFS_SUBTAG_SYMLINK 2
1105 #define OPENAFS_SUBTAG_UNC 3
1107 #define OPENAFS_MOUNTPOINT_TYPE_NORMAL L'#'
1108 #define OPENAFS_MOUNTPOINT_TYPE_RW L'%'
1110 typedef struct _AFS_REPARSE_TAG_INFORMATION
1120 USHORT MountPointCellLength;
1121 USHORT MountPointVolumeLength;
1127 BOOLEAN RelativeLink;
1128 USHORT SymLinkTargetLength;
1134 USHORT UNCTargetLength;
1139 } AFSReparseTagInfo;
1141 #endif /* _AFS_USER_STRUCT_H */