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 ULONGLONG Identifier;
312 typedef struct _AFS_FILE_OPEN_RESULT_CB
319 } AFSFileOpenResultCB;
321 typedef struct _AFS_FILE_ACCESS_RELEASE_CB
328 ULONGLONG Identifier;
330 } AFSFileAccessReleaseCB;
333 // IO Interace control blocks for extent processing when performing
334 // queries via the AFS_REQUEST_TYPE_REQUEST_FILE_EXTENTS or synchronous
335 // results from the service
338 typedef struct _AFS_FILE_EXTENT_CB
345 LARGE_INTEGER FileOffset;
347 LARGE_INTEGER CacheOffset;
357 typedef struct _AFS_REQUEST_EXTENTS_CB
362 LARGE_INTEGER ByteOffset;
366 } AFSRequestExtentsCB;
369 // Extent processing when the file system calls the service to
370 // release extents through the AFS_REQUEST_TYPE_RELEASE_FILE_EXTENTS interface
373 typedef struct _AFS_RELEASE_EXTENTS_CB
380 LARGE_INTEGER LastAccessTime;
382 LARGE_INTEGER LastWriteTime;
384 LARGE_INTEGER ChangeTime;
386 LARGE_INTEGER CreateTime;
388 LARGE_INTEGER AllocationSize;
390 AFSFileExtentCB FileExtents[ 1];
392 } AFSReleaseExtentsCB;
395 // This is the control structure used when the service passes the extent
396 // information via the IOCTL_AFS_SET_FILE_EXTENTS interface
399 typedef struct _AFS_SET_FILE_EXTENTS_CB
408 AFSFileExtentCB FileExtents[ 1];
410 } AFSSetFileExtentsCB;
413 // This is the control structure used when the service passes the extent
414 // information via the IOCTL_AFS_RELEASE_FILE_EXTENTS interface
417 #define AFS_RELEASE_EXTENTS_FLAGS_RELEASE_ALL 0x00000001
419 typedef struct _AFS_RELEASE_FILE_EXTENTS_CB
428 LARGE_INTEGER HeldExtentCount;
430 AFSFileExtentCB FileExtents[ 1];
432 } AFSReleaseFileExtentsCB;
435 // These are the control structures that the filesystem returns from a
436 // IOCTL_AFS_RELEASE_FILE_EXTENTS
439 typedef struct _AFS_RELEASE_FILE_EXTENTS_RESULT_FILE_CB
445 GUID AuthGroup; /* Length: sizeof(GUID) */
449 LARGE_INTEGER LastAccessTime;
451 LARGE_INTEGER LastWriteTime;
453 LARGE_INTEGER ChangeTime;
455 LARGE_INTEGER CreateTime;
457 LARGE_INTEGER AllocationSize;
459 AFSFileExtentCB FileExtents[ 1];
461 } AFSReleaseFileExtentsResultFileCB;
463 typedef struct _AFS_RELEASE_FILE_EXTENTS_RESULT_CB
471 AFSReleaseFileExtentsResultFileCB Files[ 1];
473 } AFSReleaseFileExtentsResultCB;
476 typedef struct _AFS_EXTENT_FAILURE_CB
483 GUID AuthGroup; // Length: sizeof(GUID) */
485 } AFSExtentFailureCB;
491 typedef struct _AFS_FILE_UPDATE_CB
496 LARGE_INTEGER LastAccessTime;
498 LARGE_INTEGER LastWriteTime;
500 LARGE_INTEGER ChangeTime;
502 LARGE_INTEGER CreateTime;
504 LARGE_INTEGER AllocationSize;
506 ULONG FileAttributes;
515 // File update CB result
518 typedef struct _AFS_FILE_UPDATE_RESULT_CB
521 AFSDirEnumEntry DirEnum;
523 } AFSFileUpdateResultCB;
529 typedef struct _AFS_FILE_DELETE_CB
532 AFSFileID ParentId; /* Must be directory */
536 /* File Name and FileID in Common Request Block */
540 typedef struct _AFS_FILE_DELETE_RESULT_CB
543 LARGE_INTEGER ParentDataVersion;
545 } AFSFileDeleteResultCB;
551 typedef struct _AFS_FILE_RENAME_CB
554 AFSFileID SourceParentId; /* Must be directory */
556 AFSFileID TargetParentId; /* Must be directory */
558 /* Source Name and FileID in Common Request Block */
560 USHORT TargetNameLength;
562 WCHAR TargetName[ 1];
566 typedef struct _AFS_FILE_RENAME_RESULT_CB
569 LARGE_INTEGER SourceParentDataVersion;
571 LARGE_INTEGER TargetParentDataVersion;
573 AFSDirEnumEntry DirEnum;
575 } AFSFileRenameResultCB;
579 // Control structures for AFS_REQUEST_TYPE_EVAL_TARGET_BY_ID
580 // and AFS_REQUEST_TYPE_EVAL_TARGET_BY_NAME
582 // The response to these requests is a AFSDirEnumEntry
585 typedef struct _AFS_FILE_EVAL_TARGET_CB
594 // Control structure for read and write requests through the PIOCtl interface
596 // CommRequest FileId field contains the active directory
598 typedef struct _AFS_PIOCTL_IO_CB
608 } AFSPIOCtlIORequestCB;
611 // The returned information for the IO Request
614 typedef struct _AFS_PIOCTL_IO_RESULT_CB
617 ULONG BytesProcessed;
619 } AFSPIOCtlIOResultCB;
623 // Control structure for open and close requests through the PIOCtl interface
625 // CommRequest FileId field contains the active directory
627 // There is no return structure.
629 typedef struct _AFS_PIOCTL_OPEN_CLOSE_CB
636 } AFSPIOCtlOpenCloseRequestCB;
639 // Cache invalidation control block
642 typedef struct _AFS_INVALIDATE_CACHE_CB
653 } AFSInvalidateCacheCB;
656 // Network Status Control Block
659 typedef struct _AFS_NETWORK_STATUS_CB
664 } AFSNetworkStatusCB;
667 // Volume Status Control Block
670 typedef struct _AFS_VOLUME_STATUS_CB
673 AFSFileID FileID; // only cell and volume fields are set
680 typedef struct _AFS_SYSNAME
683 ULONG Length; /* bytes */
685 WCHAR String[AFS_MAX_SYSNAME_LENGTH];
690 // SysName Notification Control Block
691 // Sent as the buffer with IOCTL_AFS_SYSNAME_NOTIFICATION
692 // There is no response
695 typedef struct _AFS_SYSNAME_NOTIFICATION_CB
702 AFSSysName SysNames[1];
704 } AFSSysNameNotificationCB;
708 // File System Status Query Control Block
709 // Received as a response to IOCTL_AFS_STATUS_REQUEST
711 typedef struct _AFS_DRIVER_STATUS_RESPONSE_CB
714 ULONG Status; // bit flags - see below
716 } AFSDriverStatusRespCB;
719 #define AFS_DRIVER_STATUS_READY 0
720 #define AFS_DRIVER_STATUS_NOT_READY 1
721 #define AFS_DRIVER_STATUS_NO_SERVICE 2
724 // Byte Range Lock Request
726 typedef struct _AFS_BYTE_RANGE_LOCK_REQUEST
730 LARGE_INTEGER Offset;
732 LARGE_INTEGER Length;
734 } AFSByteRangeLockRequest;
736 #define AFS_BYTE_RANGE_LOCK_TYPE_SHARED 0
737 #define AFS_BYTE_RANGE_LOCK_TYPE_EXCL 1
741 // Byte Range Lock Request Control Block
743 // Set ProcessId and FileId in the Comm Request Block
745 typedef struct _AFS_BYTE_RANGE_LOCK_REQUEST_CB
752 AFSByteRangeLockRequest Request[1];
754 } AFSByteRangeLockRequestCB;
757 // Byte Range Lock Result
759 typedef struct _AFS_BYTE_RANGE_LOCK_RESULT
764 LARGE_INTEGER Offset;
766 LARGE_INTEGER Length;
770 } AFSByteRangeLockResult;
773 // Byte Range Lock Results Control Block
776 typedef struct _AFS_BYTE_RANGE_LOCK_RESULT_CB
783 AFSByteRangeLockResult Result[1];
785 } AFSByteRangeLockResultCB;
788 // Set Byte Range Lock Results Control Block
791 typedef struct _AFS_SET_BYTE_RANGE_LOCK_RESULT_CB
800 AFSByteRangeLockResult Result[1];
802 } AFSSetByteRangeLockResultCB;
806 // Byte Range Unlock Request Control Block
809 typedef struct _AFS_BYTE_RANGE_UNLOCK_CB
816 AFSByteRangeLockRequest Request[1];
818 } AFSByteRangeUnlockRequestCB;
822 // Byte Range Unlock Request Control Block
825 typedef struct _AFS_BYTE_RANGE_UNLOCK_RESULT_CB
830 AFSByteRangeLockResult Result[1];
832 } AFSByteRangeUnlockResultCB;
836 // Control structure for read and write requests through the PIPE interface
838 // CommRequest FileId field contains the active directory
840 typedef struct _AFS_PIPE_IO_CB
848 } AFSPipeIORequestCB; // For read requests the buffer is mapped in the request cb block.
849 // For write requests, the buffer immediately follows this structure
852 // The returned information for the Pipe IO Request. Note that this is
853 // only returned in the write request. Read request info is returned in
857 typedef struct _AFS_PIPE_IO_RESULT_CB
860 ULONG BytesProcessed;
865 // Control structure for set and query info requests through the PIPE interface
868 typedef struct _AFS_PIPE_INFO_CB
875 ULONG InformationClass;
879 } AFSPipeInfoRequestCB; // For query info requests the buffer is mapped in the request cb block.
880 // For set info requests, the buffer immediately follows this structure
883 // Control structure for open and close requests through the Pipe interface
885 // CommRequest FileId field contains the active directory
887 // There is no return structure.
889 typedef struct _AFS_PIPE_OPEN_CLOSE_CB
896 } AFSPipeOpenCloseRequestCB;
900 // Hold Fid Request Control Block
903 typedef struct _AFS_HOLD_FID_REQUEST_CB
908 AFSFileID FileID[ 1];
910 } AFSHoldFidRequestCB;
913 typedef struct _AFS_FID_RESULT
922 typedef struct _AFS_HOLD_FID_RESULT_CB
927 AFSFidResult Result[ 1];
929 } AFSHoldFidResultCB;
933 // Release Fid Request Control Block
936 typedef struct _AFS_RELEASE_FID_REQUEST_CB
941 AFSFileID FileID[ 1];
943 } AFSReleaseFidRequestCB;
945 typedef struct _AFS_RELEASE_FID_RESULT_CB
950 AFSFidResult Result[ 1];
952 } AFSReleaseFidResultCB;
959 typedef struct _AFS_FILE_CLEANUP_CB
964 LARGE_INTEGER LastAccessTime;
966 LARGE_INTEGER LastWriteTime;
968 LARGE_INTEGER ChangeTime;
970 LARGE_INTEGER CreateTime;
972 LARGE_INTEGER AllocationSize;
974 ULONG FileAttributes;
980 ULONGLONG Identifier;
984 typedef struct _AFS_FILE_CLEANUP_RESULT_CB
987 LARGE_INTEGER ParentDataVersion;
989 } AFSFileCleanupResultCB;
993 // Trace configuration cb
996 typedef struct _AFS_DEBUG_TRACE_CONFIG_CB
1003 ULONG TraceBufferLength;
1010 // Object Status Information request
1013 typedef struct _AFS_REDIR_GET_OBJECT_STATUS_CB
1018 USHORT FileNameLength;
1022 } AFSGetStatusInfoCB;
1024 typedef struct _AFS_REDIR_OBJECT_STATUS_CB
1029 AFSFileID TargetFileId;
1031 LARGE_INTEGER Expiration; /* FILETIME */
1033 LARGE_INTEGER DataVersion;
1035 ULONG FileType; /* File, Dir, MountPoint, Symlink */
1039 LARGE_INTEGER CreationTime; /* FILETIME */
1041 LARGE_INTEGER LastAccessTime; /* FILETIME */
1043 LARGE_INTEGER LastWriteTime; /* FILETIME */
1045 LARGE_INTEGER ChangeTime; /* FILETIME */
1047 ULONG FileAttributes; /* NTFS FILE_ATTRIBUTE_xxxx see below */
1049 LARGE_INTEGER EndOfFile;
1051 LARGE_INTEGER AllocationSize;
1060 // Auth Group (Process and Thread) Processing
1062 // afsredir.sys implements a set of generic Authentication Group
1063 // operations that can be executed by processes. The model supports
1064 // one or more authentication groups per process. A process may switch
1065 // the active AuthGroup for any thread to any other AuthGroup the process
1066 // is a member of. However, processes cannot assign itself to an
1067 // AuthGroup that it is not presently a member of. A process can reset
1068 // its AuthGroup to the SID-AuthGroup or can create a new AuthGroup that
1069 // has not previously been used.
1071 // IOCTL_AFS_AUTHGROUP_CREATE_AND_SET
1072 // Creates a new AuthGroup and either activates it for
1073 // the process or the current thread. If set as the
1074 // new process AuthGroup, the prior AuthGroup list is
1077 // IOCTL_AFS_AUTHGROUP_QUERY
1078 // Returns a list of the AuthGroup GUIDS associated
1079 // with the current process, the current process GUID,
1080 // and the current thread GUID.
1082 // IOCTL_AFS_AUTHGROUP_SET
1083 // Permits the current AuthGroup for the process or
1084 // thread to be set to the specified GUID. The GUID
1085 // must be in the list of current values for the process.
1087 // IOCTL_AFS_AUTHGROUP_RESET
1088 // Resets the current AuthGroup for the process or
1089 // thread to the SID-AuthGroup
1091 // IOCTL_AFS_AUTHGROUP_SID_CREATE
1092 // Given a SID as input, assigns a new AuthGroup GUID.
1093 // (May only be executed by LOCAL_SYSTEM or the active SID)
1095 // IOCTL_AFS_AUTHGROUP_SID_QUERY
1096 // Given a SID as input, returns the associated AuthGroup GUID.
1098 // IOCTL_AFS_AUTHGROUP_LOGON_CREATE
1099 // Given a logon Session as input, assigns a new AuthGroup GUID.
1100 // (May only be executed by LOCAL_SYSTEM.)
1102 // New processes inherit only the active AuthGroup at the time of process
1103 // creation. Either that of the active thread (if set) or the process.
1104 // All of the other AuthGroups associated with a parent process are
1109 // Auth Group processing flags
1112 #define AFS_PAG_FLAGS_SET_AS_ACTIVE 0x00000001 // If set, the newly created authgroup is set to the active group
1113 #define AFS_PAG_FLAGS_THREAD_AUTH_GROUP 0x00000002 // If set, the request is targeted for the thread not the process
1115 typedef struct _AFS_AUTH_GROUP_REQUEST
1118 USHORT SIDLength; // If zero the SID of the caller is used
1120 ULONG SessionId; // If -1 the session id of the caller is used
1124 GUID AuthGroup; // The auth group for certain requests
1126 WCHAR SIDString[ 1];
1128 } AFSAuthGroupRequestCB;
1131 // Reparse tag AFS Specific information buffer
1134 #define OPENAFS_SUBTAG_MOUNTPOINT 1
1135 #define OPENAFS_SUBTAG_SYMLINK 2
1136 #define OPENAFS_SUBTAG_UNC 3
1138 #define OPENAFS_MOUNTPOINT_TYPE_NORMAL L'#'
1139 #define OPENAFS_MOUNTPOINT_TYPE_RW L'%'
1141 typedef struct _AFS_REPARSE_TAG_INFORMATION
1151 USHORT MountPointCellLength;
1152 USHORT MountPointVolumeLength;
1158 BOOLEAN RelativeLink;
1159 USHORT SymLinkTargetLength;
1165 USHORT UNCTargetLength;
1170 } AFSReparseTagInfo;
1172 #endif /* _AFS_USER_STRUCT_H */