diff --git a/src/WINNT/afsrdr/common/AFSProvider.h b/src/WINNT/afsrdr/common/AFSProvider.h new file mode 100644 index 0000000000..5bc24ff9f4 --- /dev/null +++ b/src/WINNT/afsrdr/common/AFSProvider.h @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2008-2011 Kernel Drivers, LLC. + * Copyright (c) 2009-2011 Your File System, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, + * this list of conditions and the following disclaimer in the + * documentation + * and/or other materials provided with the distribution. + * - Neither the name of Kernel Drivers, LLC nor the names of its + * contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission from Kernel Drivers, LLC + * and Your File System, Inc. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _AFS_PROVIDER_H +#define _AFS_PROVIDER_H + + +// +// Network provider interface header +// + + +// +// Redirector device name +// + +#define AFS_RDR_DEVICE_NAME L"\\Device\\AFSRedirector" + +// +// Provider specific IOCtl requests +// + +#define IOCTL_AFS_ADD_CONNECTION CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x2001, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_AFS_CANCEL_CONNECTION CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x2002, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_AFS_GET_CONNECTION CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x2003, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_AFS_LIST_CONNECTIONS CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x2004, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_AFS_GET_CONNECTION_INFORMATION CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x2005, METHOD_BUFFERED, FILE_ANY_ACCESS) + +// +// Versions for the following structures +// + +#define AFS_NETWORKPROVIDER_INTERFACE_VERSION_1 0x00000001 + +#pragma pack(push, 1) +typedef struct _AFS_NETWORKPROVIDER_CONNECTION_CB +{ + + ULONG Version; + + ULONG CurrentIndex; + + ULONG Type; + + ULONG Scope; + + ULONG DisplayType; + + ULONG Usage; + + ULONG CommentOffset; // From the beginning of this structure + + ULONG CommentLength; + + ULONG RemainingPathOffset; // From the beginning of this structure + + ULONG RemainingPathLength; + + ULONG RemoteNameLength; + + LARGE_INTEGER AuthenticationId; + + WCHAR LocalName; + + WCHAR RemoteName[ 1]; + +} AFSNetworkProviderConnectionCB; + +typedef struct _AFS_CANCEL_CONNECTION_RESULT_CB +{ + + ULONG Version; + + ULONG Status; + + WCHAR LocalName; + +} AFSCancelConnectionResultCB; +#pragma pack(pop) + +#endif diff --git a/src/WINNT/afsrdr/common/AFSRedirCommonDefines.h b/src/WINNT/afsrdr/common/AFSRedirCommonDefines.h new file mode 100644 index 0000000000..dbc10e6556 --- /dev/null +++ b/src/WINNT/afsrdr/common/AFSRedirCommonDefines.h @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2008-2011 Kernel Drivers, LLC. + * Copyright (c) 2009-2011 Your File System, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, + * this list of conditions and the following disclaimer in the + * documentation + * and/or other materials provided with the distribution. + * - Neither the name of Kernel Drivers, LLC nor the names of its + * contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission from Kernel Drivers, LLC + * and Your File System, Inc. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _AFS_REDIR_COMMON_DEFINES_H +#define _AFS_REDIR_COMMON_DEFINES_H + +// +// Allocation defines +// + +#define AFS_GENERIC_MEMORY_1_TAG '1GFA' +#define AFS_GENERIC_MEMORY_2_TAG '2GFA' +#define AFS_GENERIC_MEMORY_3_TAG '3GFA' +#define AFS_GENERIC_MEMORY_4_TAG '4GFA' +#define AFS_GENERIC_MEMORY_5_TAG '5GFA' +#define AFS_GENERIC_MEMORY_6_TAG '6GFA' +#define AFS_GENERIC_MEMORY_7_TAG '7GFA' +#define AFS_GENERIC_MEMORY_8_TAG '8GFA' +#define AFS_GENERIC_MEMORY_9_TAG '9GFA' +#define AFS_GENERIC_MEMORY_10_TAG 'AGFA' +#define AFS_GENERIC_MEMORY_11_TAG 'BGFA' +#define AFS_GENERIC_MEMORY_12_TAG 'CGFA' +#define AFS_GENERIC_MEMORY_13_TAG 'DGFA' +#define AFS_GENERIC_MEMORY_14_TAG 'EGFA' +#define AFS_GENERIC_MEMORY_15_TAG 'FGFA' +#define AFS_GENERIC_MEMORY_16_TAG 'GGFA' +#define AFS_GENERIC_MEMORY_17_TAG 'HGFA' +#define AFS_GENERIC_MEMORY_18_TAG 'IGFA' +#define AFS_GENERIC_MEMORY_19_TAG 'JGFA' +#define AFS_GENERIC_MEMORY_20_TAG 'KGFA' +#define AFS_GENERIC_MEMORY_21_TAG 'LGFA' +#define AFS_GENERIC_MEMORY_22_TAG 'MGFA' +#define AFS_GENERIC_MEMORY_23_TAG 'NGFA' +#define AFS_GENERIC_MEMORY_24_TAG 'OGFA' +#define AFS_GENERIC_MEMORY_25_TAG 'PGFA' +#define AFS_GENERIC_MEMORY_26_TAG 'QGFA' +#define AFS_GENERIC_MEMORY_27_TAG 'RGFA' +#define AFS_GENERIC_MEMORY_28_TAG 'SGFA' +#define AFS_GENERIC_MEMORY_29_TAG 'TGFA' +#define AFS_FCB_ALLOCATION_TAG 'AFFA' +#define AFS_FCB_NP_ALLOCATION_TAG 'NFFA' +#define AFS_VCB_ALLOCATION_TAG 'CVFA' +#define AFS_VCB_NP_ALLOCATION_TAG 'NVFA' +#define AFS_CCB_ALLOCATION_TAG 'CCFA' +#define AFS_WORKER_CB_TAG 'CWFA' +#define AFS_WORK_ITEM_TAG 'IWFA' +#define AFS_POOL_ENTRY_TAG 'EPFA' +#define AFS_PROCESS_CB_TAG 'CPFA' +#define AFS_DIR_BUFFER_TAG 'BDFA' +#define AFS_DIR_ENTRY_TAG 'EDFA' +#define AFS_NAME_BUFFER_ONE_TAG '1NFA' +#define AFS_NAME_BUFFER_TWO_TAG '2NFA' +#define AFS_NAME_BUFFER_THREE_TAG '3NFA' +#define AFS_NAME_BUFFER_FOUR_TAG '4NFA' +#define AFS_NAME_BUFFER_FIVE_TAG '5NFA' +#define AFS_NAME_BUFFER_SIX_TAG '6NFA' +#define AFS_NAME_BUFFER_SEVEN_TAG '7NFA' +#define AFS_NAME_BUFFER_EIGHT_TAG '8NFA' +#define AFS_NAME_BUFFER_NINE_TAG '9NFA' +#define AFS_NAME_BUFFER_TEN_TAG 'ANFA' +#define AFS_SUBST_BUFFER_TAG 'SBFA' +#define AFS_FILE_CREATE_BUFFER_TAG 'CFFA' +#define AFS_RENAME_REQUEST_TAG 'RFFA' +#define AFS_DIR_ENTRY_NP_TAG 'NDFA' +#define AFS_PROVIDER_CB 'PNFA' +#define AFS_EXTENT_TAG 'xSFA' +#define AFS_EXTENT_REQUEST_TAG 'XSFA' +#define AFS_EXTENT_RELEASE_TAG 'LSFA' +#define AFS_IO_RUN_TAG 'iSFA' +#define AFS_GATHER_TAG 'gSFA' +#define AFS_UPDATE_RESULT_TAG 'RUFA' +#define AFS_EXTENTS_RESULT_TAG 'XEFA' +#define AFS_SYS_NAME_NODE_TAG 'NSFA' +#define AFS_REPARSE_NAME_TAG 'NRFA' +#define AFS_NAME_ARRAY_TAG 'ANFA' +#define AFS_OBJECT_INFO_TAG 'IOFA' +#define AFS_NP_OBJECT_INFO_TAG 'ONFA' +#define AFS_DIR_SNAPSHOT_TAG 'SSFA' +#define AFS_LIBRARY_QUEUE_TAG 'QLFA' +#define AFS_NETWORK_PROVIDER_1_TAG '1ZFA' +#define AFS_NETWORK_PROVIDER_2_TAG '2ZFA' +#define AFS_NETWORK_PROVIDER_3_TAG '3ZFA' +#define AFS_NETWORK_PROVIDER_4_TAG '4ZFA' +#define AFS_NETWORK_PROVIDER_5_TAG '5ZFA' +#define AFS_NETWORK_PROVIDER_6_TAG '6ZFA' +#define AFS_NETWORK_PROVIDER_7_TAG '7ZFA' +#define AFS_NETWORK_PROVIDER_8_TAG '8ZFA' +#define AFS_NETWORK_PROVIDER_9_TAG '9ZFA' +#define AFS_NETWORK_PROVIDER_10_TAG 'AZFA' +#define AFS_NETWORK_PROVIDER_11_TAG 'BZFA' +#define AFS_AG_ENTRY_CB_TAG 'GAFA' +#define AFS_PROCESS_AG_CB_TAG 'APFA' + +#define __Enter + +#define try_return(S) { S; goto try_exit; } + +// +// Object types allocated +// + +#define AFS_FILE_FCB 0x0001 +#define AFS_DIRECTORY_FCB 0x0002 +#define AFS_NON_PAGED_FCB 0x0003 +#define AFS_CCB 0x0004 +#define AFS_ROOT_FCB 0x0006 +#define AFS_VCB 0x0007 +#define AFS_NON_PAGED_VCB 0x0008 +#define AFS_ROOT_ALL 0x0009 +#define AFS_IOCTL_FCB 0x000A +#define AFS_MOUNT_POINT_FCB 0x000B +#define AFS_SYMBOLIC_LINK_FCB 0x000C +#define AFS_SPECIAL_SHARE_FCB 0x000D +#define AFS_DFS_LINK_FCB 0x000E + +#define AFS_INVALID_FCB 0x00FF + +// +// Debug information +// + +#define AFS_DBG_FLAG_BREAK_ON_ENTRY 0x00000001 // Only enabled in checked build +#define AFS_DBG_TRACE_TO_DEBUGGER 0x00000002 +#define AFS_DBG_FLAG_ENABLE_FORCE_CRASH 0x00000004 // Only enabled in checked build +#define AFS_DBG_BUGCHECK_EXCEPTION 0x00000008 +#define AFS_DBG_CLEAN_SHUTDOWN 0x00000010 +#define AFS_DBG_REQUIRE_CLEAN_SHUTDOWN 0x00000020 + +// +// Pool state +// + +#define POOL_UNKNOWN 0 +#define POOL_INACTIVE 1 +#define POOL_ACTIVE 2 + +// +// Volume flags +// + +#define AFS_VOLUME_FLAGS_OFFLINE 0x00000001 +#define AFS_VOLUME_PRIVATE_WOKER_INITIALIZED 0x00000002 +#define AFS_VOLUME_INSERTED_HASH_TREE 0x00000004 +#define AFS_VOLUME_ACTIVE_GLOBAL_ROOT 0x00000008 + +// +// Need this to handle the break point definition +// + +typedef +void +(*PAFSDumpTraceFiles)( void); + +extern PAFSDumpTraceFiles AFSDumpTraceFilesFnc; + +// +// Debug information +// + +static inline void AFS_ASSERT() { + AFSDumpTraceFilesFnc(); +} + +#if DBG + +//#define AFS_VALIDATE_EXTENTS 0 + +static inline void AFSBreakPoint() { + AFSDumpTraceFilesFnc(); +#if !defined(KD_DEBUGGER_ENABLED) +#define KD_DEBUGGER_ENABLED DBG +#endif // KD_DEBUGGER_ENABLED + +#if (NTDDI_VERSION >= NTDDI_WS03) + KdRefreshDebuggerNotPresent(); +#endif + +#if defined(KD_DEBUGGER_NOT_PRESENT) + if (KD_DEBUGGER_NOT_PRESENT == FALSE) + DbgBreakPoint(); +#endif // KD_DEBUGGER_NOT_PRESENT +} + +#define AFSPrint DbgPrint + +#else + +static inline void AFSBreakPoint() { + AFSDumpTraceFilesFnc(); +} + +#define AFSPrint + +#endif + +// +// Library control device name +// + +#define AFS_LIBRARY_CONTROL_DEVICE_NAME L"\\Device\\AFSLibraryControlDevice" + +#define AFS_REDIR_LIBRARY_SERVICE_ENTRY L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\AFSLibrary" + +#endif + diff --git a/src/WINNT/afsrdr/common/AFSRedirCommonStructs.h b/src/WINNT/afsrdr/common/AFSRedirCommonStructs.h new file mode 100644 index 0000000000..7219ab7711 --- /dev/null +++ b/src/WINNT/afsrdr/common/AFSRedirCommonStructs.h @@ -0,0 +1,813 @@ +/* + * Copyright (c) 2008-2011 Kernel Drivers, LLC. + * Copyright (c) 2009-2011 Your File System, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, + * this list of conditions and the following disclaimer in the + * documentation + * and/or other materials provided with the distribution. + * - Neither the name of Kernel Drivers, LLC nor the names of its + * contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission from Kernel Drivers, LLC + * and Your File System, Inc. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _AFS_REDIR_COMMON_STRUCTS_H +#define _AFS_REDIR_COMMON_STRUCTS_H + +// +// BTree Entry +// + +typedef struct AFS_BTREE_ENTRY +{ + + void *parentLink; + + void *leftLink; + + void *rightLink; + + ULONGLONG HashIndex; + +} AFSBTreeEntry, *PAFSBTreeEntry; + +typedef struct AFS_LIST_ENTRY +{ + + void *fLink; + + void *bLink; + +} AFSListEntry; + +typedef struct _AFS_TREE_HDR +{ + + AFSBTreeEntry *TreeHead; + + ERESOURCE *TreeLock; + +} AFSTreeHdr; + +// +// Sys Name Information CB +// + +typedef struct _AFS_SYS_NAME_CB +{ + + struct _AFS_SYS_NAME_CB *fLink; + + UNICODE_STRING SysName; + +} AFSSysNameCB; + +// +// Communication service control structures +// + +typedef struct _AFSFSD_SRVC_CONTROL_BLOCK +{ + + ULONG IrpPoolRequestIndex; + + struct _POOL_ENTRY *RequestPoolHead; + + struct _POOL_ENTRY *RequestPoolTail; + + ERESOURCE IrpPoolLock; + + struct _POOL_ENTRY *ResultPoolHead; + + struct _POOL_ENTRY *ResultPoolTail; + + ERESOURCE ResultPoolLock; + + KEVENT IrpPoolHasEntries; + + KEVENT IrpPoolHasReleaseEntries; + + ULONG IrpPoolControlFlag; + + LONG QueueCount; + +} AFSCommSrvcCB, *PAFSCommSrvcCB; + +// +// Irp Pool entry +// + +typedef struct _POOL_ENTRY +{ + + struct _POOL_ENTRY *fLink; + + struct _POOL_ENTRY *bLink; + + KEVENT Event; + + GUID AuthGroup; + + AFSFileID FileId; + + UNICODE_STRING FileName; + + ULONG RequestType; + + ULONG RequestIndex; + + ULONG RequestFlags; + + ULONG DataLength; + + void *Data; + + ULONG ResultStatus; + + void *ResultBuffer; + + ULONG *ResultBufferLength; + +} AFSPoolEntry; + +// +// The first portion is the non-paged section of the Fcb +// + +typedef struct _AFS_NONPAGED_FCB +{ + + USHORT Size; + USHORT Type; + + // + // Ranking - File Resource first, then Paging Resource + // + + ERESOURCE Resource; + + ERESOURCE PagingResource; + + // + // The section object pointer + // + + SECTION_OBJECT_POINTERS SectionObjectPointers; + + FAST_MUTEX AdvancedHdrMutex; + + union + { + + struct + { + + ERESOURCE ExtentsResource; + + // + // This is set when an Extents Request completes. Do not wait for this + // with the Extents resource held! + // + KEVENT ExtentsRequestComplete; + + NTSTATUS ExtentsRequestStatus; + + struct _AFS_FSD_EXTENT *DirtyListHead; + + struct _AFS_FSD_EXTENT *DirtyListTail; + + ERESOURCE DirtyExtentsListLock; + + KEVENT FlushEvent; + + // + // Queued Flush event. This event is set when the queued flush count + // is zero, cleared otherwise. + + KEVENT QueuedFlushEvent; + + } File; + + struct + { + + KEVENT DirectoryEnumEvent; + + LONG DirectoryEnumCount; + + } Directory; + + } Specific; + +} AFSNonPagedFcb, *PAFSNonPagedFcb; + +typedef struct _AFS_FSD_EXTENT +{ + // + // Linked list first - the extents and then the skip list + // + + LIST_ENTRY Lists[AFS_NUM_EXTENT_LISTS]; + + AFSListEntry DirtyList; + + // + // And the extent itself + // + + LARGE_INTEGER FileOffset; + + LARGE_INTEGER CacheOffset; + + ULONG Size; + + ULONG Flags; + + LONG ActiveCount; + +#if GEN_MD5 + UCHAR MD5[16]; +#endif + +} AFSExtent, *PAFSExtent; + +typedef struct AFS_FCB +{ + + FSRTL_ADVANCED_FCB_HEADER Header; + + // + // This is the linked list of nodes processed asynchronously by the respective worker thread + // + + AFSListEntry ListEntry; + + // + // The NP portion of the Fcb + // + + AFSNonPagedFcb *NPFcb; + + // + // Fcb flags + // + + ULONG Flags; + + // + // Share access mapping + // + + SHARE_ACCESS ShareAccess; + + // + // Open pointer count on this file + // + + LONG OpenReferenceCount; + + // + // Open handle count on this file + // + + LONG OpenHandleCount; + + // + // Object info block + // + + struct _AFS_OBJECT_INFORMATION_CB *ObjectInformation; + + // + // Authentication group GUID + // + + GUID AuthGroup; + + // + // Union for node type specific information + // + + union + { + + struct + { + // + // We set this when a flush has been sent to the + // server sucessfully. We use this to influence when we + // write the flush. + // + LARGE_INTEGER LastServerFlush; + + // + // We set this when the extent ref count goes to zero. + // we use this to influence which files to purge + // + LARGE_INTEGER LastExtentAccess; + + // + // If there has been a RELEASE_FILE_EXTENTS - this is + // where we stopped last time this stops us from + // constantly refreeing the same extents and then grabbing + // them again. + // + LARGE_INTEGER LastPurgePoint; + + // + // File lock + // + + FILE_LOCK FileLock; + + // + // The extents + // + + LIST_ENTRY ExtentsLists[AFS_NUM_EXTENT_LISTS]; + + // + // There is only ever one request active, so we embed it + // + + AFSRequestExtentsCB ExtentsRequest; + + // + // Last PID that requested extents, NOT the system process + // + + ULONGLONG ExtentRequestProcessId; + + // + // Dirty extent count + // + + LONG ExtentsDirtyCount; + + // + // Extent count for this file + // + + LONG ExtentCount; + + // + // The Lazy writer thread + // + + PETHREAD LazyWriterThread; + + // + // Current count of queued flush items for the file + // + + LONG QueuedFlushCount; + + // + // Cache space currently held by extents for the file + // + + LONG ExtentLength; // in KBs + + } File; + + struct + { + + ULONG Reserved; + + } Directory; + + } Specific; + +} AFSFcb, *PAFSFcb; + +typedef struct _AFS_DEVICE_EXTENSION +{ + + // + // Self pointer + // + + PDEVICE_OBJECT Self; + + // + // List of device isntances + // + + struct _AFS_DEVICE_EXTENSION *DeviceLink; + + // + // Device flags + // + + ULONG DeviceFlags; + + union + { + + struct + { + + // + // Volume worker tracking information + // + + KEVENT VolumeWorkerCloseEvent; + + LONG VolumeWorkerThreadCount; + + // + // Fcb lifetime & flush time tickcount. This is calculated + // in DriverEntry() for the control device. + // + + LARGE_INTEGER ObjectLifeTimeCount; + LARGE_INTEGER FcbFlushTimeCount; + LARGE_INTEGER FcbPurgeTimeCount; + LARGE_INTEGER ExtentRequestTimeCount; + + // + // Comm interface + // + + AFSCommSrvcCB CommServiceCB; + + // + // Extent Release Interface + // + + ERESOURCE ExtentReleaseResource; + + KEVENT ExtentReleaseEvent; + + ULONG ExtentReleaseSequence; + + PKPROCESS ServiceProcess; + + // + // SysName information control block + // + + ERESOURCE SysName32ListLock; + + AFSSysNameCB *SysName32ListHead; + + AFSSysNameCB *SysName32ListTail; + + ERESOURCE SysName64ListLock; + + AFSSysNameCB *SysName64ListHead; + + AFSSysNameCB *SysName64ListTail; + + // + // Our process tree information + // + + AFSTreeHdr ProcessTree; + + ERESOURCE ProcessTreeLock; + + // + // SID Entry tree + // + + AFSTreeHdr AuthGroupTree; + + ERESOURCE AuthGroupTreeLock; + + // + // Notificaiton information. This is used for change notification + // + + LIST_ENTRY DirNotifyList; + + PNOTIFY_SYNC NotifySync; + + // + // Library load information + // + + KEVENT LoadLibraryEvent; + + ULONG LibraryState; + + ERESOURCE LibraryStateLock; + + LONG InflightLibraryRequests; + + KEVENT InflightLibraryEvent; + + ERESOURCE LibraryQueueLock; + + struct _AFS_LIBRARY_QUEUE_REQUEST_CB *LibraryQueueHead; + + struct _AFS_LIBRARY_QUEUE_REQUEST_CB *LibraryQueueTail; + + UNICODE_STRING LibraryServicePath; + + DEVICE_OBJECT *LibraryDeviceObject; + + FILE_OBJECT *LibraryFileObject; + + // + // Extent processing information within the library + // + + LONG ExtentCount; + + LONG ExtentsHeldLength; + + KEVENT ExtentsHeldEvent; + + // + // Outstanding service request information + // + + LONG OutstandingServiceRequestCount; + + KEVENT OutstandingServiceRequestEvent; + + } Control; + + struct + { + + // + // Cache file information + // + + HANDLE CacheFileHandle; + + PFILE_OBJECT CacheFileObject; + + ULONG CacheBlockSize; + + UNICODE_STRING CacheFile; + + LARGE_INTEGER CacheBlockCount; // Total number of cache blocks in the cache file + + void *CacheBaseAddress; + + LARGE_INTEGER CacheLength; + + PMDL CacheMdl; + + // + // Throttles on behavior + // + LARGE_INTEGER MaxIo; + + LARGE_INTEGER MaxDirty; + + // + // Maximum RPC length that is issued by the service. We should limit our + // data requests such as for extents to thsi length + // + + ULONG MaximumRPCLength; + + // + // Volume tree + // + + AFSTreeHdr VolumeTree; + + ERESOURCE VolumeTreeLock; + + struct _AFS_VOLUME_CB *VolumeListHead; + + struct _AFS_VOLUME_CB *VolumeListTail; + + ERESOURCE VolumeListLock; + + // + // Queued extent release count and event + // + + LONG QueuedReleaseExtentCount; + + KEVENT QueuedReleaseExtentEvent; + + // + // Name array related information + // + + ULONG NameArrayLength; + + ULONG MaxLinkCount; + + // + // Our root cell tree + // + + AFSTreeHdr RootCellTree; + + ERESOURCE RootCellTreeLock; + + // + // Cache file object access + // + + ERESOURCE CacheFileLock; + + // + // NP Connection list information + // + + ERESOURCE ProviderListLock; + + struct _AFSFSD_PROVIDER_CONNECTION_CB *ProviderConnectionList; + + struct _AFSFSD_PROVIDER_CONNECTION_CB *ProviderEnumerationList; + + } RDR; + + struct + { + + // + // Worker pool information + // + + ULONG WorkerCount; + + struct _AFS_WORKER_QUEUE_HDR *PoolHead; + + ERESOURCE QueueLock; + + struct _AFS_WORK_ITEM *QueueHead; + + struct _AFS_WORK_ITEM *QueueTail; + + KEVENT WorkerQueueHasItems; + + LONG QueueItemCount; + + // + // IO Worker queue + // + + ULONG IOWorkerCount; + + struct _AFS_WORKER_QUEUE_HDR *IOPoolHead; + + ERESOURCE IOQueueLock; + + struct _AFS_WORK_ITEM *IOQueueHead; + + struct _AFS_WORK_ITEM *IOQueueTail; + + KEVENT IOWorkerQueueHasItems; + + LONG IOQueueItemCount; + + } Library; + + } Specific; + +} AFSDeviceExt, *PAFSDeviceExt; + +// +// Network provider connection cb +// +#pragma pack(push, 1) +typedef struct _AFSFSD_PROVIDER_CONNECTION_CB +{ + + struct _AFSFSD_PROVIDER_CONNECTION_CB *fLink; + + struct _AFSFSD_PROVIDER_CONNECTION_CB *EnumerationList; + + ULONG Flags; + + ULONG Type; + + ULONG Scope; + + ULONG DisplayType; + + ULONG Usage; + + LARGE_INTEGER AuthenticationId; + + WCHAR LocalName; + + UNICODE_STRING RemoteName; + + UNICODE_STRING ComponentName; + + UNICODE_STRING Comment; + +} AFSProviderConnectionCB; +#pragma pack(pop) + +// +// Callbacks defined in the framework +// + +typedef +NTSTATUS +(*PAFSProcessRequest)( IN ULONG RequestType, + IN ULONG RequestFlags, + IN GUID *AuthGroup, + IN PUNICODE_STRING FileName, + IN AFSFileID *FileId, + IN void *Data, + IN ULONG DataLength, + IN OUT void *ResultBuffer, + IN OUT PULONG ResultBufferLength); + +typedef +NTSTATUS +(*PAFSDbgLogMsg)( IN ULONG Subsystem, + IN ULONG Level, + IN PCCH Format, + ...); + +typedef +NTSTATUS +(*PAFSAddConnectionEx)( IN UNICODE_STRING *RemoteName, + IN ULONG DisplayType, + IN ULONG Flags); + +typedef +void * +(*PAFSExAllocatePoolWithTag)( IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag); + +typedef +void +(*PAFSExFreePool)( IN void *Pointer); + +typedef +void +(*PAFSRetrieveAuthGroup)( IN ULONGLONG ProcessId, + IN ULONGLONG ThreadId, + OUT GUID *AuthGroup); + +typedef struct _AFS_LIBRARY_INIT_CB +{ + + PDEVICE_OBJECT AFSControlDeviceObject; + + PDEVICE_OBJECT AFSRDRDeviceObject; + + UNICODE_STRING AFSServerName; + + ULONG AFSDebugFlags; + + AFSFileID GlobalRootFid; + + CACHE_MANAGER_CALLBACKS *AFSCacheManagerCallbacks; + + void *AFSCacheBaseAddress; + + LARGE_INTEGER AFSCacheLength; + + // + // Callbacks in the framework + // + + PAFSProcessRequest AFSProcessRequest; + + PAFSDbgLogMsg AFSDbgLogMsg; + + PAFSAddConnectionEx AFSAddConnectionEx; + + PAFSExAllocatePoolWithTag AFSExAllocatePoolWithTag; + + PAFSExFreePool AFSExFreePool; + + PAFSDumpTraceFiles AFSDumpTraceFiles; + + PAFSRetrieveAuthGroup AFSRetrieveAuthGroup; + +} AFSLibraryInitCB; + + +#endif + diff --git a/src/WINNT/afsrdr/common/AFSUserDefines.h b/src/WINNT/afsrdr/common/AFSUserDefines.h new file mode 100644 index 0000000000..a39a24c3a4 --- /dev/null +++ b/src/WINNT/afsrdr/common/AFSUserDefines.h @@ -0,0 +1,304 @@ +/* + * Copyright (c) 2008-2011 Kernel Drivers, LLC. + * Copyright (c) 2009-2011 Your File System, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, + * this list of conditions and the following disclaimer in the + * documentation + * and/or other materials provided with the distribution. + * - Neither the name of Kernel Drivers, LLC nor the names of its + * contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission from Kernel Drivers, LLC + * and Your File System, Inc. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _AFS_USER_DEFINE_H +#define _AFS_USER_DEFINE_H + +// +// Symbolic link name +// + +#define AFS_SYMLINK "\\\\.\\AFSRedirector" +#define AFS_SYMLINK_W L"\\\\.\\AFSRedirector" + +#define AFS_PIOCTL_FILE_INTERFACE_NAME L"_._AFS_IOCTL_._" +#define AFS_GLOBAL_ROOT_SHARE_NAME L"ALL" + +// +// Payload buffer length +// + +#define AFS_PAYLOAD_BUFFER_SIZE (16 * 1024) + + +// +// Request types +// + +#define AFS_REQUEST_TYPE_DIR_ENUM 0x00000001 +#define AFS_REQUEST_TYPE_CREATE_FILE 0x00000002 +#define AFS_REQUEST_TYPE_REQUEST_FILE_EXTENTS 0x00000003 +#define AFS_REQUEST_TYPE_RELEASE_FILE_EXTENTS 0x00000004 +#define AFS_REQUEST_TYPE_UPDATE_FILE 0x00000005 +#define AFS_REQUEST_TYPE_DELETE_FILE 0x00000006 +#define AFS_REQUEST_TYPE_RENAME_FILE 0x00000007 +#define AFS_REQUEST_TYPE_FLUSH_FILE 0x00000008 +#define AFS_REQUEST_TYPE_OPEN_FILE 0x00000009 +#define AFS_REQUEST_TYPE_EVAL_TARGET_BY_ID 0x0000000A +#define AFS_REQUEST_TYPE_EVAL_TARGET_BY_NAME 0x0000000B +#define AFS_REQUEST_TYPE_PIOCTL_READ 0x0000000C +#define AFS_REQUEST_TYPE_PIOCTL_WRITE 0x0000000D +#define AFS_REQUEST_TYPE_PIOCTL_OPEN 0x0000000E +#define AFS_REQUEST_TYPE_PIOCTL_CLOSE 0x0000000F +#define AFS_REQUEST_TYPE_BYTE_RANGE_LOCK 0x00000010 // Takes AFSByteRangeLockRequestCB as INPUT +#define AFS_REQUEST_TYPE_BYTE_RANGE_UNLOCK 0x00000011 // Takes AFSByteRangeUnlockRequestCB as INPUT +#define AFS_REQUEST_TYPE_BYTE_RANGE_UNLOCK_ALL 0x00000012 // Takes AFSByteRangeUnlockRequestCB as INPUT +#define AFS_REQUEST_TYPE_GET_VOLUME_INFO 0x00000013 +#define AFS_REQUEST_TYPE_HOLD_FID 0x00000014 +#define AFS_REQUEST_TYPE_RELEASE_FID 0x00000015 +#define AFS_REQUEST_TYPE_PIPE_TRANSCEIVE 0x00000016 +#define AFS_REQUEST_TYPE_PIPE_READ 0x00000017 +#define AFS_REQUEST_TYPE_PIPE_WRITE 0x00000018 +#define AFS_REQUEST_TYPE_PIPE_OPEN 0x00000019 +#define AFS_REQUEST_TYPE_PIPE_CLOSE 0x0000001A +#define AFS_REQUEST_TYPE_PIPE_QUERY_INFO 0x0000001B +#define AFS_REQUEST_TYPE_PIPE_SET_INFO 0x0000001C +#define AFS_REQUEST_TYPE_CLEANUP_PROCESSING 0x0000001D +#define AFS_REQUEST_TYPE_CREATE_LINK 0x0000001E +#define AFS_REQUEST_TYPE_CREATE_MOUNTPOINT 0x0000001F +#define AFS_REQUEST_TYPE_CREATE_SYMLINK 0x00000020 + +// +// Request Flags, these are passed up from the file system +// + +#define AFS_REQUEST_FLAG_SYNCHRONOUS 0x00000001 // The service must call back through the + // IOCTL_AFS_PROCESS_IRP_RESULT IOCtl to ack + // the request with a response. The absense of + // this flag indicates no call should be made to + // the IOCTL_AFS_PROCESS_IRP_RESULT IOCtl and if a + // response is required for the call it is to be made + // through an IOCtl call + +#define AFS_REQUEST_FLAG_CASE_SENSITIVE 0x00000002 + +#define AFS_REQUEST_FLAG_WOW64 0x00000004 // On 64-bit systems, set if the request + // originated from a WOW64 process + +#define AFS_REQUEST_FLAG_FAST_REQUEST 0x00000008 // if this flag is set, the cache manager + // responds to the request using a minimum + // of file server interaction + +#define AFS_REQUEST_FLAG_HOLD_FID 0x00000010 // if this flag is set, the cache manager + // maintains a reference count on the + // evaluated file object just as if + // AFS_REQUEST_TYPE_HOLD_FID was issued. + // The reference count must be released + // using AFS_REQUEST_TYPE_RELEASE_FID. + // This flag is only valid on + // AFS_REQUEST_TYPE_EVALUATE_BY_NAME, + // AFS_REQUEST_TYPE_EVALUATE_BY_ID, + // AFS_REQUEST_TYPE_CREATE_FILE, and + // AFS_REQUEST_TYPE_OPEN_FILE. + +#define AFS_REQUEST_FLAG_FLUSH_FILE 0x00000020 // Passed as a flag to the AFS_REQUEST_TYPE_CLEANUP_PROCESSING + // request when the last handle is closed. This flag tells the + // to flush all dirty data before returning. + +#define AFS_REQUEST_FLAG_FILE_DELETED 0x00000040 // Passed as a flag to the AFS_REQUEST_TYPE_CLEANUP_PROCESSING + // request to indicate the file has been marked for deletion. + +#define AFS_REQUEST_FLAG_BYTE_RANGE_UNLOCK_ALL 0x00000080 // Passed as a flag to the AFS_REQUEST_TYPE_CLEANUP_PROCESSING + // request to indicate to release all BR locks on the file for the + // given process. + +#define AFS_REQUEST_FLAG_CHECK_ONLY 0x00000100 // Do not perform the action, just check if the action is possible + // Only used with AFS_REQUEST_TYPE_DELETE_FILE. + +#define AFS_REQUEST_LOCAL_SYSTEM_PAG 0x00000200 // Indicates that the caller is or was at some point a system + // process + +// +// Request Flags, these are passed down from the sevice +// + +#define AFS_REQUEST_RELEASE_THREAD 0x00000001 // Set on threads which are dedicated extent release threads + +// +// Status codes that can returned for various requests +// + +#if !defined(AFS_KERNEL_MODE) && !defined(STATUS_SUCCESS) + +#define STATUS_SUCCESS 0x00000000 +#define STATUS_MORE_ENTRIES 0x00000105 +#define STATUS_NO_MORE_FILES 0x80000006 + +#endif + +// +// Trace Levels +// + +#define AFS_TRACE_LEVEL_ERROR 0x00000001 +#define AFS_TRACE_LEVEL_WARNING 0x00000002 +#define AFS_TRACE_LEVEL_VERBOSE 0x00000003 +#define AFS_TRACE_LEVEL_VERBOSE_2 0x00000004 +#define AFS_TRACE_LEVEL_MAXIMUM 0x00000004 + +// +// Trace Subsystem Classes +// + +#define AFS_SUBSYSTEM_IO_PROCESSING 0x00000001 // Includes IO subsystem +#define AFS_SUBSYSTEM_FILE_PROCESSING 0x00000002 // Includes Fcb and name processing +#define AFS_SUBSYSTEM_LOCK_PROCESSING 0x00000004 // All lock processing, level must be set to VERBOSE +#define AFS_SUBSYSTEM_EXTENT_PROCESSING 0x00000008 // Specific extent processing +#define AFS_SUBSYSTEM_WORKER_PROCESSING 0x00000010 // All worker processing +#define AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING 0x00000020 // Reference counting directory entries +#define AFS_SUBSYSTEM_OBJECT_REF_COUNTING 0x00000040 // Reference counting objects +#define AFS_SUBSYSTEM_VOLUME_REF_COUNTING 0x00000080 // Reference counting volumes +#define AFS_SUBSYSTEM_FCB_REF_COUNTING 0x00000100 // Reference counting fcbs +#define AFS_SUBSYSTEM_CLEANUP_PROCESSING 0x00000200 // Garbage collection of objects, dir entries, fcbs, etc. +#define AFS_SUBSYSTEM_PIPE_PROCESSING 0x00000400 // Pipe and share processing +#define AFS_SUBSYSTEM_DIR_NOTIF_PROCESSING 0x00000800 // Directory notification interface +#define AFS_SUBSYSTEM_NETWORK_PROVIDER 0x00001000 // Network provier interactions +#define AFS_SUBSYSTEM_DIR_NODE_COUNT 0x00002000 // Dir node count processing +#define AFS_SUBSYSTEM_PIOCTL_PROCESSING 0x00004000 // PIOCtl processing +#define AFS_SUBSYSTEM_AUTHGROUP_PROCESSING 0x00008000 // Auth group creation/assignment +#define AFS_SUBSYSTEM_LOAD_LIBRARY 0x00010000 // Library load and unload, request queuing +#define AFS_SUBSYSTEM_PROCESS_PROCESSING 0x00010000 // Process creation and destruction +#define AFS_SUBSYSTEM_EXTENT_ACTIVE_COUNTING 0x00020000 // Extent Active Counts +#define AFS_SUBSYSTEM_INIT_PROCESSING 0x00040000 // Redirector Initialization + +// +// Invalidation Reasons +// + +#define AFS_INVALIDATE_EXPIRED 1 /* Set RE_VALIDATE */ +#define AFS_INVALIDATE_FLUSHED 2 /* Set RE-VALIDATE */ +#define AFS_INVALIDATE_CALLBACK 3 /* Set VERIFY Reset dir enumeration */ +#define AFS_INVALIDATE_SMB 4 /* Set VERIFY Reset dir enumeration */ +#define AFS_INVALIDATE_CREDS 5 /* Set VERIFY - User credentials changed */ +#define AFS_INVALIDATE_DATA_VERSION 6 /* Set VERIFY */ +#define AFS_INVALIDATE_DELETED 7 /* Requires top level locks */ + +// +// Flags which can be specified for each extent in the AFSFileExtentCB structure +// + +#define AFS_EXTENT_FLAG_DIRTY 1 // The specified extent requires flushing, this can be + // specified by the file system during a release of the + // extent + +#define AFS_EXTENT_FLAG_RELEASE 2 // The presence of this flag during a AFS_REQUEST_TYPE_RELEASE_FILE_EXTENTS + // call from the file system indicates to the service that the file system + // no longer requires the extents and they can be completely released. The + // absense of this flag tells the service that the extent should not be + // dereferenced; this is usually the case when the file system tells the + // service to flush a range of exents but do not release them + +#define AFS_EXTENT_FLAG_CLEAN 4 // The presence of this flag during a AFS_REQUEST_TYPE_REQUEST_FILE_EXTENTS + // call from the file system indicates to the server that the file system + // is going to completely overwrite the contents of the extent and the + // service should therefore not bother to obtain the current version + // from the file server. + +#define AFS_EXTENT_FLAG_FLUSH 8 // The presence of this flag indicates that the service should perform + // the equivalent of a FLUSH ioctl on the file after processing the + // extents. + +#define AFS_EXTENT_FLAG_IN_USE 0x10 // The extent is currenty in use by the fs and cannot be released + +#define AFS_EXTENT_FLAG_UNKNOWN 0x20 // The extent is unknown to the fs + +#define AFS_EXTENT_FLAG_MD5_SET 0x40 // The extent MD5 field has been set + +// +// Volume Information Characteristics +// + +#ifndef AFS_KERNEL_MODE + +#define FILE_REMOVABLE_MEDIA 0x00000001 +#define FILE_READ_ONLY_DEVICE 0x00000002 +#define FILE_REMOTE_DEVICE 0x00000010 + +// +// File attributes +// + +#define FILE_ATTRIBUTE_READONLY 0x00000001 // winnt +#define FILE_ATTRIBUTE_HIDDEN 0x00000002 // winnt +#define FILE_ATTRIBUTE_SYSTEM 0x00000004 // winnt + +#define FILE_ATTRIBUTE_DIRECTORY 0x00000010 // winnt +#define FILE_ATTRIBUTE_ARCHIVE 0x00000020 // winnt +#define FILE_ATTRIBUTE_DEVICE 0x00000040 // winnt +#define FILE_ATTRIBUTE_NORMAL 0x00000080 // winnt + +// +// Filesystem attributes +// + +#define FILE_CASE_PRESERVED_NAMES 0x00000002 // winnt +#define FILE_UNICODE_ON_DISK 0x00000004 // winnt +#define FILE_PERSISTENT_ACLS 0x00000008 // winnt +#define FILE_VOLUME_QUOTAS 0x00000020 // winnt +#define FILE_SUPPORTS_REPARSE_POINTS 0x00000080 // winnt +#define FILE_SUPPORTS_OBJECT_IDS 0x00010000 // winnt + +#endif + +// +// AFS File Types +// + +#define AFS_FILE_TYPE_UNKNOWN 0 /* an unknown object */ +#define AFS_FILE_TYPE_FILE 1 /* a file */ +#define AFS_FILE_TYPE_DIRECTORY 2 /* a dir */ +#define AFS_FILE_TYPE_SYMLINK 3 /* a symbolic link */ +#define AFS_FILE_TYPE_MOUNTPOINT 4 /* a mount point */ +#define AFS_FILE_TYPE_DFSLINK 5 /* a Microsoft Dfs link */ +#define AFS_FILE_TYPE_INVALID 99 /* an invalid link */ + +// +// AFS File types specific to Windows +// + +#define AFS_FILE_TYPE_SPECIAL_SHARE_NAME -1 +#define AFS_FILE_TYPE_PIOCTL -2 +#define AFS_FILE_TYPE_PIPE -3 + +// +// AFS SysName Constants +// + +#define AFS_MAX_SYSNAME_LENGTH 128 +#define AFS_SYSNAME_ARCH_32BIT 0 +#define AFS_SYSNAME_ARCH_64BIT 1 + + +#endif /* _AFS_USER_DEFINE_H */ diff --git a/src/WINNT/afsrdr/common/AFSUserIoctl.h b/src/WINNT/afsrdr/common/AFSUserIoctl.h new file mode 100644 index 0000000000..dd5a7e3235 --- /dev/null +++ b/src/WINNT/afsrdr/common/AFSUserIoctl.h @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2008-2011 Kernel Drivers, LLC. + * Copyright (c) 2009-2011 Your File System, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, + * this list of conditions and the following disclaimer in the + * documentation + * and/or other materials provided with the distribution. + * - Neither the name of Kernel Drivers, LLC nor the names of its + * contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission from Kernel Drivers, LLC + * and Your File System, Inc. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _AFS_USER_IOCTL_H +#define _AFS_USER_IOCTL_H + +// +// IOCtl definitions +// + +#define IOCTL_AFS_INITIALIZE_CONTROL_DEVICE CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1001, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_INITIALIZE_REDIRECTOR_DEVICE CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1002, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_PROCESS_IRP_REQUEST CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1003, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_PROCESS_IRP_RESULT CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1004, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_SET_FILE_EXTENTS CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1005, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_RELEASE_FILE_EXTENTS CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1006, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_INVALIDATE_CACHE CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1007, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_SET_FILE_EXTENT_FAILURE CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1008, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_NETWORK_STATUS CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1009, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_VOLUME_STATUS CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x100A, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_SHUTDOWN CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x100B, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_SYSNAME_NOTIFICATION CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x100C, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_STATUS_REQUEST CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x100D, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_SET_BYTE_RANGE_LOCKS CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x100E, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_CONFIGURE_DEBUG_TRACE CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x100F, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_GET_TRACE_BUFFER CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1010, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_FORCE_CRASH CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1011, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_INITIALIZE_LIBRARY_DEVICE CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1012, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_GET_OBJECT_INFORMATION CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1013, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_AUTHGROUP_CREATE_AND_SET CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1014, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_AUTHGROUP_QUERY CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1015, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_AUTHGROUP_SET CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1016, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_AUTHGROUP_RESET CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1017, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_AUTHGROUP_SID_CREATE CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1018, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_AUTHGROUP_SID_QUERY CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x1019, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_AFS_AUTHGROUP_LOGON_CREATE CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x101A, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#endif /* _AFS_USER_IOCTL_H */ \ No newline at end of file diff --git a/src/WINNT/afsrdr/common/AFSUserPrototypes.h b/src/WINNT/afsrdr/common/AFSUserPrototypes.h new file mode 100644 index 0000000000..d3a26685aa --- /dev/null +++ b/src/WINNT/afsrdr/common/AFSUserPrototypes.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2008-2011 Kernel Drivers, LLC. + * Copyright (c) 2009-2011 Your File System, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, + * this list of conditions and the following disclaimer in the + * documentation + * and/or other materials provided with the distribution. + * - Neither the name of Kernel Drivers, LLC nor the names of its + * contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission from Kernel Drivers, LLC + * and Your File System, Inc. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +extern DWORD RDR_RequestExtentRelease(cm_fid_t *fidp, LARGE_INTEGER numOfHeldExtents, + DWORD numOfExtents, AFSFileExtentCB *extentList); + +extern DWORD RDR_Initialize( void); + +extern DWORD RDR_ShutdownNotify( void); + +extern DWORD RDR_ShutdownFinal( void); + +extern DWORD RDR_NetworkStatus( IN BOOLEAN status); + +extern DWORD RDR_VolumeStatus( IN ULONG cellID, IN ULONG volID, IN BOOLEAN online); + +extern DWORD RDR_NetworkAddrChange(void); + +extern DWORD RDR_InvalidateVolume( IN ULONG cellID, IN ULONG volID, IN ULONG reason); + +extern DWORD RDR_SetFileStatus( IN cm_fid_t *pFileId, IN DWORD dwStatus); + +extern DWORD +RDR_InvalidateObject( IN ULONG cellID, IN ULONG volID, IN ULONG vnode, + IN ULONG uniq, IN ULONG hash, IN ULONG filetype, IN ULONG reason); + +extern DWORD +RDR_SysName(ULONG Architecture, ULONG Count, WCHAR **NameList); + +extern afs_int32 +RDR_BkgFetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, afs_uint32 p4, + cm_user_t *userp, cm_req_t *reqp); diff --git a/src/WINNT/afsrdr/common/AFSUserStructs.h b/src/WINNT/afsrdr/common/AFSUserStructs.h new file mode 100644 index 0000000000..4c1cd8771f --- /dev/null +++ b/src/WINNT/afsrdr/common/AFSUserStructs.h @@ -0,0 +1,1142 @@ +/* + * Copyright (c) 2008-2011 Kernel Drivers, LLC. + * Copyright (c) 2009-2011 Your File System, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, + * this list of conditions and the following disclaimer in the + * documentation + * and/or other materials provided with the distribution. + * - Neither the name of Kernel Drivers, LLC nor the names of its + * contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission from Kernel Drivers, LLC + * and Your File System, Inc. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _AFS_USER_STRUCT_H +#define _AFS_USER_STRUCT_H + +typedef struct _AFS_FILE_ID +{ + + ULONG Hash; + + ULONG Cell; + + ULONG Volume; + + ULONG Vnode; + + ULONG Unique; + +} AFSFileID; + +// +// This control structure is the request block passed to the filter. The filter will populate the structure +// when it requires a request to be handled by the service. +// + +typedef struct _AFS_COMM_REQUEST_BLOCK +{ + + AFSFileID FileId; /* Initialize unused elements to 0 */ + + ULONG RequestType; + + ULONG RequestIndex; /* Must return to caller */ + + ULONG RequestFlags; /* AFS_REQUEST_FLAG_xxxx */ + + ULONG NameLength; // Length of the name in bytes + + ULONG DataOffset; // This offset is from the end of the structure, including the name + + ULONG DataLength; + + GUID AuthGroup; // Length: sizeof(GUID) */ + + ULONG ResultBufferLength; /* Do not exceed this length in response */ + + LONG QueueCount; // Current outstanding requests in the queue + + WCHAR Name[ 1]; + +} AFSCommRequest; + + +// +// This is the result block passed back to the redirector after a request has been handled +// + +typedef struct _AFS_COMM_RESULT_BLOCK +{ + + ULONG RequestIndex; /* Must match the AFSCommRequest value */ + + ULONG ResultStatus; /* NTSTATUS_xxx */ + + ULONG ResultBufferLength; /* Not to exceed AFSCommRequest ResultBufferLength */ + + ULONG Reserved; /* To ease Quad Alignment */ + + char ResultData[ 1]; + +} AFSCommResult; + +// +// Control block passed to IOCTL_AFS_INITIALIZE_REDIRECTOR_DEVICE +// + +#define AFS_REDIR_INIT_FLAG_HIDE_DOT_FILES 0x00000001 + +#define AFS_REDIR_INIT_NO_PAGING_FILE 0x00000002 + +typedef struct _AFS_REDIR_INIT_INFO_CB +{ + + ULONG Flags; + + ULONG MaximumChunkLength; // Maximum RPC length issued so we should limit + // requests for data to this length + + AFSFileID GlobalFileId; // AFS FID of the Global root.afs volume + + LARGE_INTEGER ExtentCount; // Number of extents in the current data cache + + ULONG CacheBlockSize; // Size, in bytes, of the current cache block + + ULONG MaxPathLinkCount; // Number of symlinks / mountpoints that may + // be cross during the evaluation of any path + + ULONG NameArrayLength; // Number of components that should be allocated + // in each name array chunk. Name arrays are + // dynamic and will be increased in size as + // needed by this amount + + LARGE_INTEGER MemoryCacheOffset; // The offset in the afsd_service process memory + // space at which the extents are allocated + LARGE_INTEGER MemoryCacheLength; // and the length of the allocated region + + ULONG DumpFileLocationOffset; // Offset from the beginning of this structure to + // the start of the directory where dump files + // are to be stored. The path must be fully + // qualified such as C:\Windows\Temp + + ULONG DumpFileLocationLength; // Length, in bytes, of the DumpFileLocation path + + ULONG CacheFileNameLength; // size, in bytes, of the cache file name + + WCHAR CacheFileName[ 1]; // Fully qualified cache file name in the form + // C:\OPenAFSDir\CacheFile.dat + +} AFSRedirectorInitInfo; + +// +// Directory query CB +// + +typedef struct _AFS_DIR_QUERY_CB +{ + + ULONG_PTR EnumHandle; // If this is 0 then it is a new query, + // otherwise it is the FileIndex of the last + // entry processed. + +} AFSDirQueryCB; + +// +// Directory enumeration control block +// Entries are aligned on a QuadWord boundary +// + +typedef struct _AFS_DIR_ENUM_ENTRY +{ + + AFSFileID FileId; + + ULONG FileIndex; /* Incremented */ + + LARGE_INTEGER Expiration; /* FILETIME */ + + LARGE_INTEGER DataVersion; + + ULONG FileType; /* File, Dir, MountPoint, Symlink */ + + LARGE_INTEGER CreationTime; /* FILETIME */ + + LARGE_INTEGER LastAccessTime; /* FILETIME */ + + LARGE_INTEGER LastWriteTime; /* FILETIME */ + + LARGE_INTEGER ChangeTime; /* FILETIME */ + + LARGE_INTEGER EndOfFile; + + LARGE_INTEGER AllocationSize; + + ULONG FileAttributes; /* NTFS FILE_ATTRIBUTE_xxxx see below */ + + ULONG FileNameLength; + + ULONG EaSize; + + ULONG Links; + + ULONG FileNameOffset; /* From beginning of this structure */ + + ULONG TargetNameOffset; /* From beginning of this structure */ + + ULONG TargetNameLength; + + AFSFileID TargetFileId; /* Target fid for mp's and symlinks */ + + CCHAR ShortNameLength; + + WCHAR ShortName[12]; + + /* Long Filename and Target (Symlink and MountPoint only) to follow without NULs */ + +} AFSDirEnumEntry; + + +typedef struct _AFS_DIR_ENUM_RESP +{ + + ULONG_PTR EnumHandle; + + AFSDirEnumEntry Entry[ 1]; /* Each entry is Quad aligned */ + +} AFSDirEnumResp; + +// +// Volume information CB passed in the create request +// + +typedef struct _AFS_VOLUME_INFORMATION +{ + + LARGE_INTEGER TotalAllocationUnits; /* Partition Max Blocks */ + + LARGE_INTEGER AvailableAllocationUnits; /* Partition Blocks Avail */ + + LARGE_INTEGER VolumeCreationTime; /* AFS Last Update - Not Creation */ + + ULONG Characteristics; /* FILE_READ_ONLY_DEVICE (if readonly) + * FILE_REMOTE_DEVICE (always) + */ + + ULONG FileSystemAttributes; /* FILE_CASE_PRESERVED_NAMES (always) + FILE_UNICODE_ON_DISK (always) */ + + ULONG SectorsPerAllocationUnit; /* = 1 */ + + ULONG BytesPerSector; /* = 1024 */ + + ULONG CellID; /* AFS Cell ID */ + + ULONG VolumeID; /* AFS Volume ID */ + + ULONG VolumeLabelLength; + + WCHAR VolumeLabel[20]; /* Volume:Cell */ + +} AFSVolumeInfoCB; + +// +// File create CB +// + +typedef struct _AFS_FILE_CREATE_CB +{ + + AFSFileID ParentId; + + LARGE_INTEGER AllocationSize; + + ULONG FileAttributes; + + ULONG EaSize; + + char EaBuffer[ 1]; + +} AFSFileCreateCB; + +typedef struct _AFS_FILE_CREATE_RESULT_CB +{ + + LARGE_INTEGER ParentDataVersion; + + AFSDirEnumEntry DirEnum; + +} AFSFileCreateResultCB; + +// +// File open CB +// + +typedef struct _AFS_FILE_OPEN_CB +{ + + AFSFileID ParentId; + + ULONG DesiredAccess; + + ULONG ShareAccess; + +} AFSFileOpenCB; + +typedef struct _AFS_FILE_OPEN_RESULT_CB +{ + + ULONG GrantedAccess; + +} AFSFileOpenResultCB; + +// +// IO Interace control blocks for extent processing when performing +// queries via the AFS_REQUEST_TYPE_REQUEST_FILE_EXTENTS or synchronous +// results from the service +// + +typedef struct _AFS_FILE_EXTENT_CB +{ + + ULONG Flags; + + ULONG Length; + + LARGE_INTEGER FileOffset; + + LARGE_INTEGER CacheOffset; + + UCHAR MD5[16]; + + ULONG DirtyOffset; + + ULONG DirtyLength; + +} AFSFileExtentCB; + +typedef struct _AFS_REQUEST_EXTENTS_CB +{ + + ULONG Flags; + + LARGE_INTEGER ByteOffset; + + ULONG Length; + +} AFSRequestExtentsCB; + +// +// Extent processing when the file system calls the service to +// release extents through the AFS_REQUEST_TYPE_RELEASE_FILE_EXTENTS interface +// + +typedef struct _AFS_RELEASE_EXTENTS_CB +{ + + ULONG Flags; + + ULONG ExtentCount; + + LARGE_INTEGER LastAccessTime; + + LARGE_INTEGER LastWriteTime; + + LARGE_INTEGER ChangeTime; + + LARGE_INTEGER CreateTime; + + LARGE_INTEGER AllocationSize; + + AFSFileExtentCB FileExtents[ 1]; + +} AFSReleaseExtentsCB; + +// +// This is the control structure used when the service passes the extent +// information via the IOCTL_AFS_SET_FILE_EXTENTS interface +// + +typedef struct _AFS_SET_FILE_EXTENTS_CB +{ + + AFSFileID FileId; + + ULONG ExtentCount; + + ULONG ResultStatus; + + AFSFileExtentCB FileExtents[ 1]; + +} AFSSetFileExtentsCB; + +// +// This is the control structure used when the service passes the extent +// information via the IOCTL_AFS_RELEASE_FILE_EXTENTS interface +// + +#define AFS_RELEASE_EXTENTS_FLAGS_RELEASE_ALL 0x00000001 + +typedef struct _AFS_RELEASE_FILE_EXTENTS_CB +{ + + ULONG Flags; + + AFSFileID FileId; + + ULONG ExtentCount; + + LARGE_INTEGER HeldExtentCount; + + AFSFileExtentCB FileExtents[ 1]; + +} AFSReleaseFileExtentsCB; + +// +// These are the control structures that the filesystem returns from a +// IOCTL_AFS_RELEASE_FILE_EXTENTS +// + +typedef struct _AFS_RELEASE_FILE_EXTENTS_RESULT_FILE_CB +{ + AFSFileID FileId; + + ULONG Flags; + + GUID AuthGroup; /* Length: sizeof(GUID) */ + + ULONG ExtentCount; + + LARGE_INTEGER LastAccessTime; + + LARGE_INTEGER LastWriteTime; + + LARGE_INTEGER ChangeTime; + + LARGE_INTEGER CreateTime; + + LARGE_INTEGER AllocationSize; + + AFSFileExtentCB FileExtents[ 1]; + +} AFSReleaseFileExtentsResultFileCB; + +typedef struct _AFS_RELEASE_FILE_EXTENTS_RESULT_CB +{ + ULONG SerialNumber; + + ULONG Flags; + + ULONG FileCount; + + AFSReleaseFileExtentsResultFileCB Files[ 1]; + +} AFSReleaseFileExtentsResultCB; + + +typedef struct _AFS_EXTENT_FAILURE_CB +{ + + AFSFileID FileId; + + ULONG FailureStatus; + +} AFSExtentFailureCB; + +// +// File update CB +// + +typedef struct _AFS_FILE_UPDATE_CB +{ + + AFSFileID ParentId; + + LARGE_INTEGER LastAccessTime; + + LARGE_INTEGER LastWriteTime; + + LARGE_INTEGER ChangeTime; + + LARGE_INTEGER CreateTime; + + LARGE_INTEGER AllocationSize; + + ULONG FileAttributes; + + ULONG EaSize; + + char EaBuffer[ 1]; + +} AFSFileUpdateCB; + +// +// File update CB result +// + +typedef struct _AFS_FILE_UPDATE_RESULT_CB +{ + + AFSDirEnumEntry DirEnum; + +} AFSFileUpdateResultCB; + +// +// File delete CB +// + +typedef struct _AFS_FILE_DELETE_CB +{ + + AFSFileID ParentId; /* Must be directory */ + + ULONGLONG ProcessId; + + /* File Name and FileID in Common Request Block */ + +} AFSFileDeleteCB; + +typedef struct _AFS_FILE_DELETE_RESULT_CB +{ + + LARGE_INTEGER ParentDataVersion; + +} AFSFileDeleteResultCB; + +// +// File rename CB +// + +typedef struct _AFS_FILE_RENAME_CB +{ + + AFSFileID SourceParentId; /* Must be directory */ + + AFSFileID TargetParentId; /* Must be directory */ + + /* Source Name and FileID in Common Request Block */ + + USHORT TargetNameLength; + + WCHAR TargetName[ 1]; + +} AFSFileRenameCB; + +typedef struct _AFS_FILE_RENAME_RESULT_CB +{ + + LARGE_INTEGER SourceParentDataVersion; + + LARGE_INTEGER TargetParentDataVersion; + + AFSDirEnumEntry DirEnum; + +} AFSFileRenameResultCB; + + +// +// Control structures for AFS_REQUEST_TYPE_EVAL_TARGET_BY_ID +// and AFS_REQUEST_TYPE_EVAL_TARGET_BY_NAME +// +// The response to these requests is a AFSDirEnumEntry +// + +typedef struct _AFS_FILE_EVAL_TARGET_CB +{ + + AFSFileID ParentId; + +} AFSEvalTargetCB; + + +// +// Control structure for read and write requests through the PIOCtl interface +// +// CommRequest FileId field contains the active directory + +typedef struct _AFS_PIOCTL_IO_CB +{ + ULONG RequestId; + + AFSFileID RootId; + + ULONG BufferLength; + + void *MappedBuffer; + +} AFSPIOCtlIORequestCB; + +// +// The returned information for the IO Request +// + +typedef struct _AFS_PIOCTL_IO_RESULT_CB +{ + + ULONG BytesProcessed; + +} AFSPIOCtlIOResultCB; + + +// +// Control structure for open and close requests through the PIOCtl interface +// +// CommRequest FileId field contains the active directory +// +// There is no return structure. +// +typedef struct _AFS_PIOCTL_OPEN_CLOSE_CB +{ + + ULONG RequestId; + + AFSFileID RootId; + +} AFSPIOCtlOpenCloseRequestCB; + +// +// Cache invalidation control block +// + +typedef struct _AFS_INVALIDATE_CACHE_CB +{ + + AFSFileID FileID; + + ULONG FileType; + + BOOLEAN WholeVolume; + + ULONG Reason; + +} AFSInvalidateCacheCB; + +// +// Network Status Control Block +// + +typedef struct _AFS_NETWORK_STATUS_CB +{ + + BOOLEAN Online; + +} AFSNetworkStatusCB; + +// +// Volume Status Control Block +// + +typedef struct _AFS_VOLUME_STATUS_CB +{ + + AFSFileID FileID; // only cell and volume fields are set + + BOOLEAN Online; + +} AFSVolumeStatusCB; + + +typedef struct _AFS_SYSNAME +{ + + ULONG Length; /* bytes */ + + WCHAR String[AFS_MAX_SYSNAME_LENGTH]; + +} AFSSysName; + +// +// SysName Notification Control Block +// Sent as the buffer with IOCTL_AFS_SYSNAME_NOTIFICATION +// There is no response +// + +typedef struct _AFS_SYSNAME_NOTIFICATION_CB +{ + + ULONG Architecture; + + ULONG NumberOfNames; + + AFSSysName SysNames[1]; + +} AFSSysNameNotificationCB; + + +// +// File System Status Query Control Block +// Received as a response to IOCTL_AFS_STATUS_REQUEST +// +typedef struct _AFS_DRIVER_STATUS_RESPONSE_CB +{ + + ULONG Status; // bit flags - see below + +} AFSDriverStatusRespCB; + +// Bit flags +#define AFS_DRIVER_STATUS_READY 0 +#define AFS_DRIVER_STATUS_NOT_READY 1 +#define AFS_DRIVER_STATUS_NO_SERVICE 2 + +// +// Byte Range Lock Request +// +typedef struct _AFS_BYTE_RANGE_LOCK_REQUEST +{ + ULONG LockType; + + LARGE_INTEGER Offset; + + LARGE_INTEGER Length; + +} AFSByteRangeLockRequest; + +#define AFS_BYTE_RANGE_LOCK_TYPE_SHARED 0 +#define AFS_BYTE_RANGE_LOCK_TYPE_EXCL 1 + + +// +// Byte Range Lock Request Control Block +// +// Set ProcessId and FileId in the Comm Request Block +// +typedef struct _AFS_BYTE_RANGE_LOCK_REQUEST_CB +{ + + ULONG Count; + + ULONGLONG ProcessId; + + AFSByteRangeLockRequest Request[1]; + +} AFSByteRangeLockRequestCB; + +// +// Byte Range Lock Result +// +typedef struct _AFS_BYTE_RANGE_LOCK_RESULT +{ + + ULONG LockType; + + LARGE_INTEGER Offset; + + LARGE_INTEGER Length; + + ULONG Status; + +} AFSByteRangeLockResult; + +// +// Byte Range Lock Results Control Block +// + +typedef struct _AFS_BYTE_RANGE_LOCK_RESULT_CB +{ + + AFSFileID FileId; + + ULONG Count; + + AFSByteRangeLockResult Result[1]; + +} AFSByteRangeLockResultCB; + +// +// Set Byte Range Lock Results Control Block +// + +typedef struct _AFS_SET_BYTE_RANGE_LOCK_RESULT_CB +{ + + ULONG SerialNumber; + + AFSFileID FileId; + + ULONG Count; + + AFSByteRangeLockResult Result[1]; + +} AFSSetByteRangeLockResultCB; + + +// +// Byte Range Unlock Request Control Block +// + +typedef struct _AFS_BYTE_RANGE_UNLOCK_CB +{ + + ULONG Count; + + ULONGLONG ProcessId; + + AFSByteRangeLockRequest Request[1]; + +} AFSByteRangeUnlockRequestCB; + + +// +// Byte Range Unlock Request Control Block +// + +typedef struct _AFS_BYTE_RANGE_UNLOCK_RESULT_CB +{ + + ULONG Count; + + AFSByteRangeLockResult Result[1]; + +} AFSByteRangeUnlockResultCB; + + +// +// Control structure for read and write requests through the PIPE interface +// +// CommRequest FileId field contains the active directory + +typedef struct _AFS_PIPE_IO_CB +{ + ULONG RequestId; + + AFSFileID RootId; + + ULONG BufferLength; + +} AFSPipeIORequestCB; // For read requests the buffer is mapped in the request cb block. + // For write requests, the buffer immediately follows this structure + +// +// The returned information for the Pipe IO Request. Note that this is +// only returned in the write request. Read request info is returned in +// the request cb +// + +typedef struct _AFS_PIPE_IO_RESULT_CB +{ + + ULONG BytesProcessed; + +} AFSPipeIOResultCB; + +// +// Control structure for set and query info requests through the PIPE interface +// + +typedef struct _AFS_PIPE_INFO_CB +{ + + ULONG RequestId; + + AFSFileID RootId; + + ULONG InformationClass; + + ULONG BufferLength; + +} AFSPipeInfoRequestCB; // For query info requests the buffer is mapped in the request cb block. + // For set info requests, the buffer immediately follows this structure + +// +// Control structure for open and close requests through the Pipe interface +// +// CommRequest FileId field contains the active directory +// +// There is no return structure. +// +typedef struct _AFS_PIPE_OPEN_CLOSE_CB +{ + + ULONG RequestId; + + AFSFileID RootId; + +} AFSPipeOpenCloseRequestCB; + + +// +// Hold Fid Request Control Block +// + +typedef struct _AFS_HOLD_FID_REQUEST_CB +{ + + ULONG Count; + + AFSFileID FileID[ 1]; + +} AFSHoldFidRequestCB; + + +typedef struct _AFS_FID_RESULT +{ + + AFSFileID FileID; + + ULONG Status; + +} AFSFidResult; + +typedef struct _AFS_HOLD_FID_RESULT_CB +{ + + ULONG Count; + + AFSFidResult Result[ 1]; + +} AFSHoldFidResultCB; + + +// +// Release Fid Request Control Block +// + +typedef struct _AFS_RELEASE_FID_REQUEST_CB +{ + + ULONG Count; + + AFSFileID FileID[ 1]; + +} AFSReleaseFidRequestCB; + +typedef struct _AFS_RELEASE_FID_RESULT_CB +{ + + ULONG Count; + + AFSFidResult Result[ 1]; + +} AFSReleaseFidResultCB; + + +// +// File cleanup CB +// + +typedef struct _AFS_FILE_CLEANUP_CB +{ + + AFSFileID ParentId; + + LARGE_INTEGER LastAccessTime; + + LARGE_INTEGER LastWriteTime; + + LARGE_INTEGER ChangeTime; + + LARGE_INTEGER CreateTime; + + LARGE_INTEGER AllocationSize; + + ULONG FileAttributes; + + ULONGLONG ProcessId; + +} AFSFileCleanupCB; + +// +// Trace configuration cb +// + +typedef struct _AFS_DEBUG_TRACE_CONFIG_CB +{ + + ULONG TraceLevel; + + ULONG Subsystem; + + ULONG TraceBufferLength; + + ULONG DebugFlags; + +} AFSTraceConfigCB; + +// +// Object Status Information request +// + +typedef struct _AFS_REDIR_GET_OBJECT_STATUS_CB +{ + + AFSFileID FileID; + + USHORT FileNameLength; + + WCHAR FileName[ 1]; + +} AFSGetStatusInfoCB; + +typedef struct _AFS_REDIR_OBJECT_STATUS_CB +{ + + AFSFileID FileId; + + AFSFileID TargetFileId; + + LARGE_INTEGER Expiration; /* FILETIME */ + + LARGE_INTEGER DataVersion; + + ULONG FileType; /* File, Dir, MountPoint, Symlink */ + + ULONG ObjectFlags; + + LARGE_INTEGER CreationTime; /* FILETIME */ + + LARGE_INTEGER LastAccessTime; /* FILETIME */ + + LARGE_INTEGER LastWriteTime; /* FILETIME */ + + LARGE_INTEGER ChangeTime; /* FILETIME */ + + ULONG FileAttributes; /* NTFS FILE_ATTRIBUTE_xxxx see below */ + + LARGE_INTEGER EndOfFile; + + LARGE_INTEGER AllocationSize; + + ULONG EaSize; + + ULONG Links; + +} AFSStatusInfoCB; + +// +// Auth Group (Process and Thread) Processing +// +// afsredir.sys implements a set of generic Authentication Group +// operations that can be executed by processes. The model supports +// one or more authentication groups per process. A process may switch +// the active AuthGroup for any thread to any other AuthGroup the process +// is a member of. However, processes cannot assign itself to an +// AuthGroup that it is not presently a member of. A process can reset +// its AuthGroup to the SID-AuthGroup or can create a new AuthGroup that +// has not previously been used. +// +// IOCTL_AFS_AUTHGROUP_CREATE_AND_SET +// Creates a new AuthGroup and either activates it for +// the process or the current thread. If set as the +// new process AuthGroup, the prior AuthGroup list is +// cleared. +// +// IOCTL_AFS_AUTHGROUP_QUERY +// Returns a list of the AuthGroup GUIDS associated +// with the current process, the current process GUID, +// and the current thread GUID. +// +// IOCTL_AFS_AUTHGROUP_SET +// Permits the current AuthGroup for the process or +// thread to be set to the specified GUID. The GUID +// must be in the list of current values for the process. +// +// IOCTL_AFS_AUTHGROUP_RESET +// Resets the current AuthGroup for the process or +// thread to the SID-AuthGroup +// +// IOCTL_AFS_AUTHGROUP_SID_CREATE +// Given a SID as input, assigns a new AuthGroup GUID. +// (May only be executed by LOCAL_SYSTEM or the active SID) +// +// IOCTL_AFS_AUTHGROUP_SID_QUERY +// Given a SID as input, returns the associated AuthGroup GUID. +// +// IOCTL_AFS_AUTHGROUP_LOGON_CREATE +// Given a logon Session as input, assigns a new AuthGroup GUID. +// (May only be executed by LOCAL_SYSTEM.) +// +// New processes inherit only the active AuthGroup at the time of process +// creation. Either that of the active thread (if set) or the process. +// All of the other AuthGroups associated with a parent process are +// off-limits. +// + +// +// Auth Group processing flags +// + +#define AFS_PAG_FLAGS_SET_AS_ACTIVE 0x00000001 // If set, the newly created authgroup is set to the active group +#define AFS_PAG_FLAGS_THREAD_AUTH_GROUP 0x00000002 // If set, the request is targeted for the thread not the process + +typedef struct _AFS_AUTH_GROUP_REQUEST +{ + + USHORT SIDLength; // If zero the SID of the caller is used + + ULONG SessionId; // If -1 the session id of the caller is used + + ULONG Flags; + + GUID AuthGroup; // The auth group for certain requests + + WCHAR SIDString[ 1]; + +} AFSAuthGroupRequestCB; + +// +// Reparse tag AFS Specific information buffer +// + +#define OPENAFS_SUBTAG_MOUNTPOINT 1 +#define OPENAFS_SUBTAG_SYMLINK 2 +#define OPENAFS_SUBTAG_UNC 3 + +#define OPENAFS_MOUNTPOINT_TYPE_NORMAL L'#' +#define OPENAFS_MOUNTPOINT_TYPE_RW L'%' + +typedef struct _AFS_REPARSE_TAG_INFORMATION +{ + + ULONG SubTag; + + union + { + struct + { + ULONG Type; + USHORT MountPointCellLength; + USHORT MountPointVolumeLength; + WCHAR Buffer[1]; + } AFSMountPoint; + + struct + { + BOOLEAN RelativeLink; + USHORT SymLinkTargetLength; + WCHAR Buffer[1]; + } AFSSymLink; + + struct + { + USHORT UNCTargetLength; + WCHAR Buffer[1]; + } UNCReferral; + }; + +} AFSReparseTagInfo; + +#endif /* _AFS_USER_STRUCT_H */ +