162306a36Sopenharmony_ci/* SPDX-License-Identifier: LGPL-2.1+ */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * SMB, CIFS, SMB2 FSCTL definitions 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (c) International Business Machines Corp., 2002,2013 662306a36Sopenharmony_ci * Author(s): Steve French (sfrench@us.ibm.com) 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci/* IOCTL information */ 1162306a36Sopenharmony_ci/* 1262306a36Sopenharmony_ci * List of ioctl/fsctl function codes that are or could be useful in the 1362306a36Sopenharmony_ci * future to remote clients like cifs or SMB2/SMB3 client. This is probably 1462306a36Sopenharmony_ci * a slightly larger set of fsctls that NTFS local filesystem could handle, 1562306a36Sopenharmony_ci * including the seven below that we do not have struct definitions for. 1662306a36Sopenharmony_ci * Even with protocol definitions for most of these now available, we still 1762306a36Sopenharmony_ci * need to do some experimentation to identify which are practical to do 1862306a36Sopenharmony_ci * remotely. Some of the following, such as the encryption/compression ones 1962306a36Sopenharmony_ci * could be invoked from tools via a specialized hook into the VFS rather 2062306a36Sopenharmony_ci * than via the standard vfs entry points 2162306a36Sopenharmony_ci * 2262306a36Sopenharmony_ci * See MS-SMB2 Section 2.2.31 (last checked September 2021, all of that list are 2362306a36Sopenharmony_ci * below). Additional detail on less common ones can be found in MS-FSCC 2462306a36Sopenharmony_ci * section 2.3. 2562306a36Sopenharmony_ci */ 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#ifndef __SMBFSCTL_H 2862306a36Sopenharmony_ci#define __SMBFSCTL_H 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci/* 3162306a36Sopenharmony_ci * FSCTL values are 32 bits and are constructed as 3262306a36Sopenharmony_ci * <device 16bits> <access 2bits> <function 12bits> <method 2bits> 3362306a36Sopenharmony_ci */ 3462306a36Sopenharmony_ci/* Device */ 3562306a36Sopenharmony_ci#define FSCTL_DEVICE_DFS (0x0006 << 16) 3662306a36Sopenharmony_ci#define FSCTL_DEVICE_FILE_SYSTEM (0x0009 << 16) 3762306a36Sopenharmony_ci#define FSCTL_DEVICE_NAMED_PIPE (0x0011 << 16) 3862306a36Sopenharmony_ci#define FSCTL_DEVICE_NETWORK_FILE_SYSTEM (0x0014 << 16) 3962306a36Sopenharmony_ci#define FSCTL_DEVICE_MASK 0xffff0000 4062306a36Sopenharmony_ci/* Access */ 4162306a36Sopenharmony_ci#define FSCTL_DEVICE_ACCESS_FILE_ANY_ACCESS (0x00 << 14) 4262306a36Sopenharmony_ci#define FSCTL_DEVICE_ACCESS_FILE_READ_ACCESS (0x01 << 14) 4362306a36Sopenharmony_ci#define FSCTL_DEVICE_ACCESS_FILE_WRITE_ACCESS (0x02 << 14) 4462306a36Sopenharmony_ci#define FSCTL_DEVICE_ACCESS_FILE_READ_WRITE_ACCESS (0x03 << 14) 4562306a36Sopenharmony_ci#define FSCTL_DEVICE_ACCESS_MASK 0x0000c000 4662306a36Sopenharmony_ci/* Function */ 4762306a36Sopenharmony_ci#define FSCTL_DEVICE_FUNCTION_MASK 0x00003ffc 4862306a36Sopenharmony_ci/* Method */ 4962306a36Sopenharmony_ci#define FSCTL_DEVICE_METHOD_BUFFERED 0x00 5062306a36Sopenharmony_ci#define FSCTL_DEVICE_METHOD_IN_DIRECT 0x01 5162306a36Sopenharmony_ci#define FSCTL_DEVICE_METHOD_OUT_DIRECT 0x02 5262306a36Sopenharmony_ci#define FSCTL_DEVICE_METHOD_NEITHER 0x03 5362306a36Sopenharmony_ci#define FSCTL_DEVICE_METHOD_MASK 0x00000003 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci#define FSCTL_DFS_GET_REFERRALS 0x00060194 5762306a36Sopenharmony_ci#define FSCTL_DFS_GET_REFERRALS_EX 0x000601B0 5862306a36Sopenharmony_ci#define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000 5962306a36Sopenharmony_ci#define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004 6062306a36Sopenharmony_ci#define FSCTL_REQUEST_BATCH_OPLOCK 0x00090008 6162306a36Sopenharmony_ci#define FSCTL_LOCK_VOLUME 0x00090018 6262306a36Sopenharmony_ci#define FSCTL_UNLOCK_VOLUME 0x0009001C 6362306a36Sopenharmony_ci#define FSCTL_IS_PATHNAME_VALID 0x0009002C /* BB add struct */ 6462306a36Sopenharmony_ci#define FSCTL_GET_COMPRESSION 0x0009003C /* BB add struct */ 6562306a36Sopenharmony_ci#define FSCTL_SET_COMPRESSION 0x0009C040 /* BB add struct */ 6662306a36Sopenharmony_ci#define FSCTL_QUERY_FAT_BPB 0x00090058 /* BB add struct */ 6762306a36Sopenharmony_ci/* Verify the next FSCTL number, we had it as 0x00090090 before */ 6862306a36Sopenharmony_ci#define FSCTL_FILESYSTEM_GET_STATS 0x00090060 /* BB add struct */ 6962306a36Sopenharmony_ci#define FSCTL_GET_NTFS_VOLUME_DATA 0x00090064 /* BB add struct */ 7062306a36Sopenharmony_ci#define FSCTL_GET_RETRIEVAL_POINTERS 0x00090073 /* BB add struct */ 7162306a36Sopenharmony_ci#define FSCTL_IS_VOLUME_DIRTY 0x00090078 /* BB add struct */ 7262306a36Sopenharmony_ci#define FSCTL_ALLOW_EXTENDED_DASD_IO 0x00090083 /* BB add struct */ 7362306a36Sopenharmony_ci#define FSCTL_REQUEST_FILTER_OPLOCK 0x0009008C 7462306a36Sopenharmony_ci#define FSCTL_FIND_FILES_BY_SID 0x0009008F /* BB add struct */ 7562306a36Sopenharmony_ci#define FSCTL_SET_OBJECT_ID 0x00090098 /* BB add struct */ 7662306a36Sopenharmony_ci#define FSCTL_GET_OBJECT_ID 0x0009009C /* BB add struct */ 7762306a36Sopenharmony_ci#define FSCTL_DELETE_OBJECT_ID 0x000900A0 /* BB add struct */ 7862306a36Sopenharmony_ci#define FSCTL_SET_REPARSE_POINT 0x000900A4 /* BB add struct */ 7962306a36Sopenharmony_ci#define FSCTL_GET_REPARSE_POINT 0x000900A8 /* BB add struct */ 8062306a36Sopenharmony_ci#define FSCTL_DELETE_REPARSE_POINT 0x000900AC /* BB add struct */ 8162306a36Sopenharmony_ci#define FSCTL_SET_OBJECT_ID_EXTENDED 0x000900BC /* BB add struct */ 8262306a36Sopenharmony_ci#define FSCTL_CREATE_OR_GET_OBJECT_ID 0x000900C0 /* BB add struct */ 8362306a36Sopenharmony_ci#define FSCTL_SET_SPARSE 0x000900C4 /* BB add struct */ 8462306a36Sopenharmony_ci#define FSCTL_SET_ZERO_DATA 0x000980C8 8562306a36Sopenharmony_ci#define FSCTL_SET_ENCRYPTION 0x000900D7 /* BB add struct */ 8662306a36Sopenharmony_ci#define FSCTL_ENCRYPTION_FSCTL_IO 0x000900DB /* BB add struct */ 8762306a36Sopenharmony_ci#define FSCTL_WRITE_RAW_ENCRYPTED 0x000900DF /* BB add struct */ 8862306a36Sopenharmony_ci#define FSCTL_READ_RAW_ENCRYPTED 0x000900E3 /* BB add struct */ 8962306a36Sopenharmony_ci#define FSCTL_READ_FILE_USN_DATA 0x000900EB /* BB add struct */ 9062306a36Sopenharmony_ci#define FSCTL_WRITE_USN_CLOSE_RECORD 0x000900EF /* BB add struct */ 9162306a36Sopenharmony_ci#define FSCTL_MARK_HANDLE 0x000900FC /* BB add struct */ 9262306a36Sopenharmony_ci#define FSCTL_SIS_COPYFILE 0x00090100 /* BB add struct */ 9362306a36Sopenharmony_ci#define FSCTL_RECALL_FILE 0x00090117 /* BB add struct */ 9462306a36Sopenharmony_ci#define FSCTL_QUERY_SPARING_INFO 0x00090138 /* BB add struct */ 9562306a36Sopenharmony_ci#define FSCTL_QUERY_ON_DISK_VOLUME_INFO 0x0009013C 9662306a36Sopenharmony_ci#define FSCTL_SET_ZERO_ON_DEALLOC 0x00090194 /* BB add struct */ 9762306a36Sopenharmony_ci#define FSCTL_SET_SHORT_NAME_BEHAVIOR 0x000901B4 /* BB add struct */ 9862306a36Sopenharmony_ci#define FSCTL_GET_INTEGRITY_INFORMATION 0x0009027C 9962306a36Sopenharmony_ci#define FSCTL_QUERY_FILE_REGIONS 0x00090284 10062306a36Sopenharmony_ci#define FSCTL_GET_REFS_VOLUME_DATA 0x000902D8 /* See MS-FSCC 2.3.24 */ 10162306a36Sopenharmony_ci#define FSCTL_SET_INTEGRITY_INFORMATION_EXT 0x00090380 10262306a36Sopenharmony_ci#define FSCTL_GET_RETRIEVAL_POINTERS_AND_REFCOUNT 0x000903d3 10362306a36Sopenharmony_ci#define FSCTL_GET_RETRIEVAL_POINTER_COUNT 0x0009042b 10462306a36Sopenharmony_ci#define FSCTL_REFS_STREAM_SNAPSHOT_MANAGEMENT 0x00090440 10562306a36Sopenharmony_ci#define FSCTL_QUERY_ALLOCATED_RANGES 0x000940CF 10662306a36Sopenharmony_ci#define FSCTL_OFFLOAD_READ 0x00094264 /* BB add struct */ 10762306a36Sopenharmony_ci#define FSCTL_OFFLOAD_WRITE 0x00098268 /* BB add struct */ 10862306a36Sopenharmony_ci#define FSCTL_SET_DEFECT_MANAGEMENT 0x00098134 /* BB add struct */ 10962306a36Sopenharmony_ci#define FSCTL_FILE_LEVEL_TRIM 0x00098208 /* BB add struct */ 11062306a36Sopenharmony_ci#define FSCTL_DUPLICATE_EXTENTS_TO_FILE 0x00098344 11162306a36Sopenharmony_ci#define FSCTL_DUPLICATE_EXTENTS_TO_FILE_EX 0x000983E8 11262306a36Sopenharmony_ci#define FSCTL_SIS_LINK_FILES 0x0009C104 11362306a36Sopenharmony_ci#define FSCTL_SET_INTEGRITY_INFORMATION 0x0009C280 11462306a36Sopenharmony_ci#define FSCTL_PIPE_PEEK 0x0011400C /* BB add struct */ 11562306a36Sopenharmony_ci#define FSCTL_PIPE_TRANSCEIVE 0x0011C017 /* BB add struct */ 11662306a36Sopenharmony_ci/* strange that the number for this op is not sequential with previous op */ 11762306a36Sopenharmony_ci#define FSCTL_PIPE_WAIT 0x00110018 /* BB add struct */ 11862306a36Sopenharmony_ci/* Enumerate previous versions of a file */ 11962306a36Sopenharmony_ci#define FSCTL_SRV_ENUMERATE_SNAPSHOTS 0x00144064 12062306a36Sopenharmony_ci/* Retrieve an opaque file reference for server-side data movement ie copy */ 12162306a36Sopenharmony_ci#define FSCTL_SRV_REQUEST_RESUME_KEY 0x00140078 12262306a36Sopenharmony_ci#define FSCTL_LMR_REQUEST_RESILIENCY 0x001401D4 12362306a36Sopenharmony_ci#define FSCTL_LMR_GET_LINK_TRACK_INF 0x001400E8 /* BB add struct */ 12462306a36Sopenharmony_ci#define FSCTL_LMR_SET_LINK_TRACK_INF 0x001400EC /* BB add struct */ 12562306a36Sopenharmony_ci#define FSCTL_VALIDATE_NEGOTIATE_INFO 0x00140204 12662306a36Sopenharmony_ci/* Perform server-side data movement */ 12762306a36Sopenharmony_ci#define FSCTL_SRV_COPYCHUNK 0x001440F2 12862306a36Sopenharmony_ci#define FSCTL_SRV_COPYCHUNK_WRITE 0x001480F2 12962306a36Sopenharmony_ci#define FSCTL_QUERY_NETWORK_INTERFACE_INFO 0x001401FC /* BB add struct */ 13062306a36Sopenharmony_ci#define FSCTL_SRV_READ_HASH 0x001441BB /* BB add struct */ 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci/* See FSCC 2.1.2.5 */ 13362306a36Sopenharmony_ci#define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003 13462306a36Sopenharmony_ci#define IO_REPARSE_TAG_HSM 0xC0000004 13562306a36Sopenharmony_ci#define IO_REPARSE_TAG_SIS 0x80000007 13662306a36Sopenharmony_ci#define IO_REPARSE_TAG_HSM2 0x80000006 13762306a36Sopenharmony_ci#define IO_REPARSE_TAG_DRIVER_EXTENDER 0x80000005 13862306a36Sopenharmony_ci/* Used by the DFS filter. See MS-DFSC */ 13962306a36Sopenharmony_ci#define IO_REPARSE_TAG_DFS 0x8000000A 14062306a36Sopenharmony_ci/* Used by the DFS filter See MS-DFSC */ 14162306a36Sopenharmony_ci#define IO_REPARSE_TAG_DFSR 0x80000012 14262306a36Sopenharmony_ci#define IO_REPARSE_TAG_FILTER_MANAGER 0x8000000B 14362306a36Sopenharmony_ci/* See section MS-FSCC 2.1.2.4 */ 14462306a36Sopenharmony_ci#define IO_REPARSE_TAG_SYMLINK 0xA000000C 14562306a36Sopenharmony_ci#define IO_REPARSE_TAG_DEDUP 0x80000013 14662306a36Sopenharmony_ci#define IO_REPARSE_APPXSTREAM 0xC0000014 14762306a36Sopenharmony_ci/* NFS symlinks, Win 8/SMB3 and later */ 14862306a36Sopenharmony_ci#define IO_REPARSE_TAG_NFS 0x80000014 14962306a36Sopenharmony_ci/* 15062306a36Sopenharmony_ci * AzureFileSync - see 15162306a36Sopenharmony_ci * https://docs.microsoft.com/en-us/azure/storage/files/storage-sync-cloud-tiering 15262306a36Sopenharmony_ci */ 15362306a36Sopenharmony_ci#define IO_REPARSE_TAG_AZ_FILE_SYNC 0x8000001e 15462306a36Sopenharmony_ci/* WSL reparse tags */ 15562306a36Sopenharmony_ci#define IO_REPARSE_TAG_LX_SYMLINK 0xA000001D 15662306a36Sopenharmony_ci#define IO_REPARSE_TAG_AF_UNIX 0x80000023 15762306a36Sopenharmony_ci#define IO_REPARSE_TAG_LX_FIFO 0x80000024 15862306a36Sopenharmony_ci#define IO_REPARSE_TAG_LX_CHR 0x80000025 15962306a36Sopenharmony_ci#define IO_REPARSE_TAG_LX_BLK 0x80000026 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_ci#define IO_REPARSE_TAG_LX_SYMLINK_LE cpu_to_le32(0xA000001D) 16262306a36Sopenharmony_ci#define IO_REPARSE_TAG_AF_UNIX_LE cpu_to_le32(0x80000023) 16362306a36Sopenharmony_ci#define IO_REPARSE_TAG_LX_FIFO_LE cpu_to_le32(0x80000024) 16462306a36Sopenharmony_ci#define IO_REPARSE_TAG_LX_CHR_LE cpu_to_le32(0x80000025) 16562306a36Sopenharmony_ci#define IO_REPARSE_TAG_LX_BLK_LE cpu_to_le32(0x80000026) 16662306a36Sopenharmony_ci 16762306a36Sopenharmony_ci/* fsctl flags */ 16862306a36Sopenharmony_ci/* If Flags is set to this value, the request is an FSCTL not ioctl request */ 16962306a36Sopenharmony_ci#define SMB2_0_IOCTL_IS_FSCTL 0x00000001 17062306a36Sopenharmony_ci#endif /* __SMBFSCTL_H */ 171