Steve French | fc111fb | 2021-09-08 23:06:24 -0500 | [diff] [blame] | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
Steve French | 0382457 | 2009-02-25 16:24:04 +0000 | [diff] [blame] | 2 | /* |
Steve French | 099dd78 | 2021-09-13 14:51:10 -0500 | [diff] [blame] | 3 | * SMB, CIFS, SMB2 FSCTL definitions |
Steve French | 0382457 | 2009-02-25 16:24:04 +0000 | [diff] [blame] | 4 | * |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 5 | * Copyright (c) International Business Machines Corp., 2002,2013 |
Steve French | 0382457 | 2009-02-25 16:24:04 +0000 | [diff] [blame] | 6 | * Author(s): Steve French (sfrench@us.ibm.com) |
| 7 | * |
Steve French | 0382457 | 2009-02-25 16:24:04 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | /* IOCTL information */ |
| 11 | /* |
| 12 | * List of ioctl/fsctl function codes that are or could be useful in the |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 13 | * future to remote clients like cifs or SMB2/SMB3 client. This is probably |
Steve French | 0382457 | 2009-02-25 16:24:04 +0000 | [diff] [blame] | 14 | * a slightly larger set of fsctls that NTFS local filesystem could handle, |
| 15 | * including the seven below that we do not have struct definitions for. |
| 16 | * Even with protocol definitions for most of these now available, we still |
| 17 | * need to do some experimentation to identify which are practical to do |
| 18 | * remotely. Some of the following, such as the encryption/compression ones |
| 19 | * could be invoked from tools via a specialized hook into the VFS rather |
| 20 | * than via the standard vfs entry points |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 21 | * |
Steve French | fc111fb | 2021-09-08 23:06:24 -0500 | [diff] [blame] | 22 | * See MS-SMB2 Section 2.2.31 (last checked September 2021, all of that list are |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 23 | * below). Additional detail on less common ones can be found in MS-FSCC |
| 24 | * section 2.3. |
Steve French | 0382457 | 2009-02-25 16:24:04 +0000 | [diff] [blame] | 25 | */ |
Ronnie Sahlberg | efac779 | 2019-04-11 12:20:17 +1000 | [diff] [blame] | 26 | |
Steve French | fc111fb | 2021-09-08 23:06:24 -0500 | [diff] [blame] | 27 | #ifndef __SMBFSCTL_H |
| 28 | #define __SMBFSCTL_H |
| 29 | |
Ronnie Sahlberg | efac779 | 2019-04-11 12:20:17 +1000 | [diff] [blame] | 30 | /* |
| 31 | * FSCTL values are 32 bits and are constructed as |
| 32 | * <device 16bits> <access 2bits> <function 12bits> <method 2bits> |
| 33 | */ |
| 34 | /* Device */ |
| 35 | #define FSCTL_DEVICE_DFS (0x0006 << 16) |
| 36 | #define FSCTL_DEVICE_FILE_SYSTEM (0x0009 << 16) |
| 37 | #define FSCTL_DEVICE_NAMED_PIPE (0x0011 << 16) |
| 38 | #define FSCTL_DEVICE_NETWORK_FILE_SYSTEM (0x0014 << 16) |
| 39 | #define FSCTL_DEVICE_MASK 0xffff0000 |
| 40 | /* Access */ |
| 41 | #define FSCTL_DEVICE_ACCESS_FILE_ANY_ACCESS (0x00 << 14) |
| 42 | #define FSCTL_DEVICE_ACCESS_FILE_READ_ACCESS (0x01 << 14) |
| 43 | #define FSCTL_DEVICE_ACCESS_FILE_WRITE_ACCESS (0x02 << 14) |
| 44 | #define FSCTL_DEVICE_ACCESS_FILE_READ_WRITE_ACCESS (0x03 << 14) |
| 45 | #define FSCTL_DEVICE_ACCESS_MASK 0x0000c000 |
| 46 | /* Function */ |
| 47 | #define FSCTL_DEVICE_FUNCTION_MASK 0x00003ffc |
| 48 | /* Method */ |
| 49 | #define FSCTL_DEVICE_METHOD_BUFFERED 0x00 |
| 50 | #define FSCTL_DEVICE_METHOD_IN_DIRECT 0x01 |
| 51 | #define FSCTL_DEVICE_METHOD_OUT_DIRECT 0x02 |
| 52 | #define FSCTL_DEVICE_METHOD_NEITHER 0x03 |
| 53 | #define FSCTL_DEVICE_METHOD_MASK 0x00000003 |
| 54 | |
| 55 | |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 56 | #define FSCTL_DFS_GET_REFERRALS 0x00060194 |
| 57 | #define FSCTL_DFS_GET_REFERRALS_EX 0x000601B0 |
Steve French | 0382457 | 2009-02-25 16:24:04 +0000 | [diff] [blame] | 58 | #define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000 |
| 59 | #define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004 |
| 60 | #define FSCTL_REQUEST_BATCH_OPLOCK 0x00090008 |
| 61 | #define FSCTL_LOCK_VOLUME 0x00090018 |
| 62 | #define FSCTL_UNLOCK_VOLUME 0x0009001C |
| 63 | #define FSCTL_IS_PATHNAME_VALID 0x0009002C /* BB add struct */ |
| 64 | #define FSCTL_GET_COMPRESSION 0x0009003C /* BB add struct */ |
| 65 | #define FSCTL_SET_COMPRESSION 0x0009C040 /* BB add struct */ |
| 66 | #define FSCTL_QUERY_FAT_BPB 0x00090058 /* BB add struct */ |
| 67 | /* Verify the next FSCTL number, we had it as 0x00090090 before */ |
| 68 | #define FSCTL_FILESYSTEM_GET_STATS 0x00090060 /* BB add struct */ |
| 69 | #define FSCTL_GET_NTFS_VOLUME_DATA 0x00090064 /* BB add struct */ |
| 70 | #define FSCTL_GET_RETRIEVAL_POINTERS 0x00090073 /* BB add struct */ |
| 71 | #define FSCTL_IS_VOLUME_DIRTY 0x00090078 /* BB add struct */ |
| 72 | #define FSCTL_ALLOW_EXTENDED_DASD_IO 0x00090083 /* BB add struct */ |
| 73 | #define FSCTL_REQUEST_FILTER_OPLOCK 0x0009008C |
| 74 | #define FSCTL_FIND_FILES_BY_SID 0x0009008F /* BB add struct */ |
| 75 | #define FSCTL_SET_OBJECT_ID 0x00090098 /* BB add struct */ |
| 76 | #define FSCTL_GET_OBJECT_ID 0x0009009C /* BB add struct */ |
| 77 | #define FSCTL_DELETE_OBJECT_ID 0x000900A0 /* BB add struct */ |
| 78 | #define FSCTL_SET_REPARSE_POINT 0x000900A4 /* BB add struct */ |
| 79 | #define FSCTL_GET_REPARSE_POINT 0x000900A8 /* BB add struct */ |
| 80 | #define FSCTL_DELETE_REPARSE_POINT 0x000900AC /* BB add struct */ |
| 81 | #define FSCTL_SET_OBJECT_ID_EXTENDED 0x000900BC /* BB add struct */ |
| 82 | #define FSCTL_CREATE_OR_GET_OBJECT_ID 0x000900C0 /* BB add struct */ |
| 83 | #define FSCTL_SET_SPARSE 0x000900C4 /* BB add struct */ |
Steve French | 31742c5 | 2014-08-17 08:38:47 -0500 | [diff] [blame] | 84 | #define FSCTL_SET_ZERO_DATA 0x000980C8 |
Steve French | 0382457 | 2009-02-25 16:24:04 +0000 | [diff] [blame] | 85 | #define FSCTL_SET_ENCRYPTION 0x000900D7 /* BB add struct */ |
| 86 | #define FSCTL_ENCRYPTION_FSCTL_IO 0x000900DB /* BB add struct */ |
| 87 | #define FSCTL_WRITE_RAW_ENCRYPTED 0x000900DF /* BB add struct */ |
| 88 | #define FSCTL_READ_RAW_ENCRYPTED 0x000900E3 /* BB add struct */ |
| 89 | #define FSCTL_READ_FILE_USN_DATA 0x000900EB /* BB add struct */ |
| 90 | #define FSCTL_WRITE_USN_CLOSE_RECORD 0x000900EF /* BB add struct */ |
| 91 | #define FSCTL_SIS_COPYFILE 0x00090100 /* BB add struct */ |
| 92 | #define FSCTL_RECALL_FILE 0x00090117 /* BB add struct */ |
| 93 | #define FSCTL_QUERY_SPARING_INFO 0x00090138 /* BB add struct */ |
| 94 | #define FSCTL_SET_ZERO_ON_DEALLOC 0x00090194 /* BB add struct */ |
| 95 | #define FSCTL_SET_SHORT_NAME_BEHAVIOR 0x000901B4 /* BB add struct */ |
Steve French | 9d1b066 | 2015-06-24 02:12:19 -0500 | [diff] [blame] | 96 | #define FSCTL_GET_INTEGRITY_INFORMATION 0x0009027C |
Steve French | fc111fb | 2021-09-08 23:06:24 -0500 | [diff] [blame] | 97 | #define FSCTL_GET_REFS_VOLUME_DATA 0x000902D8 /* See MS-FSCC 2.3.24 */ |
Steve French | e4e2787 | 2022-01-18 16:36:27 -0600 | [diff] [blame] | 98 | #define FSCTL_SET_INTEGRITY_INFORMATION_EXT 0x00090380 |
Steve French | 7d03ae4 | 2020-10-23 15:21:38 -0500 | [diff] [blame] | 99 | #define FSCTL_GET_RETRIEVAL_POINTERS_AND_REFCOUNT 0x000903d3 |
| 100 | #define FSCTL_GET_RETRIEVAL_POINTER_COUNT 0x0009042b |
Steve French | e4e2787 | 2022-01-18 16:36:27 -0600 | [diff] [blame] | 101 | #define FSCTL_REFS_STREAM_SNAPSHOT_MANAGEMENT 0x00090440 |
Ronnie Sahlberg | 2f3ebab | 2019-04-25 16:45:29 +1000 | [diff] [blame] | 102 | #define FSCTL_QUERY_ALLOCATED_RANGES 0x000940CF |
Steve French | 0382457 | 2009-02-25 16:24:04 +0000 | [diff] [blame] | 103 | #define FSCTL_SET_DEFECT_MANAGEMENT 0x00098134 /* BB add struct */ |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 104 | #define FSCTL_FILE_LEVEL_TRIM 0x00098208 /* BB add struct */ |
Steve French | 02b1666 | 2015-06-27 21:18:36 -0700 | [diff] [blame] | 105 | #define FSCTL_DUPLICATE_EXTENTS_TO_FILE 0x00098344 |
Steve French | 0382457 | 2009-02-25 16:24:04 +0000 | [diff] [blame] | 106 | #define FSCTL_SIS_LINK_FILES 0x0009C104 |
Steve French | 9d1b066 | 2015-06-24 02:12:19 -0500 | [diff] [blame] | 107 | #define FSCTL_SET_INTEGRITY_INFORMATION 0x0009C280 |
Steve French | 0382457 | 2009-02-25 16:24:04 +0000 | [diff] [blame] | 108 | #define FSCTL_PIPE_PEEK 0x0011400C /* BB add struct */ |
| 109 | #define FSCTL_PIPE_TRANSCEIVE 0x0011C017 /* BB add struct */ |
| 110 | /* strange that the number for this op is not sequential with previous op */ |
| 111 | #define FSCTL_PIPE_WAIT 0x00110018 /* BB add struct */ |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 112 | /* Enumerate previous versions of a file */ |
| 113 | #define FSCTL_SRV_ENUMERATE_SNAPSHOTS 0x00144064 |
| 114 | /* Retrieve an opaque file reference for server-side data movement ie copy */ |
| 115 | #define FSCTL_SRV_REQUEST_RESUME_KEY 0x00140078 |
Steve French | b56eae4 | 2015-11-03 09:26:27 -0600 | [diff] [blame] | 116 | #define FSCTL_LMR_REQUEST_RESILIENCY 0x001401D4 |
Steve French | 0382457 | 2009-02-25 16:24:04 +0000 | [diff] [blame] | 117 | #define FSCTL_LMR_GET_LINK_TRACK_INF 0x001400E8 /* BB add struct */ |
| 118 | #define FSCTL_LMR_SET_LINK_TRACK_INF 0x001400EC /* BB add struct */ |
Steve French | ff1c038 | 2013-11-19 23:44:46 -0600 | [diff] [blame] | 119 | #define FSCTL_VALIDATE_NEGOTIATE_INFO 0x00140204 |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 120 | /* Perform server-side data movement */ |
| 121 | #define FSCTL_SRV_COPYCHUNK 0x001440F2 |
| 122 | #define FSCTL_SRV_COPYCHUNK_WRITE 0x001480F2 |
| 123 | #define FSCTL_QUERY_NETWORK_INTERFACE_INFO 0x001401FC /* BB add struct */ |
| 124 | #define FSCTL_SRV_READ_HASH 0x001441BB /* BB add struct */ |
Steve French | 0382457 | 2009-02-25 16:24:04 +0000 | [diff] [blame] | 125 | |
Steve French | c31f330 | 2013-09-28 18:24:12 -0500 | [diff] [blame] | 126 | /* See FSCC 2.1.2.5 */ |
Steve French | 0382457 | 2009-02-25 16:24:04 +0000 | [diff] [blame] | 127 | #define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003 |
| 128 | #define IO_REPARSE_TAG_HSM 0xC0000004 |
| 129 | #define IO_REPARSE_TAG_SIS 0x80000007 |
Steve French | c31f330 | 2013-09-28 18:24:12 -0500 | [diff] [blame] | 130 | #define IO_REPARSE_TAG_HSM2 0x80000006 |
| 131 | #define IO_REPARSE_TAG_DRIVER_EXTENDER 0x80000005 |
| 132 | /* Used by the DFS filter. See MS-DFSC */ |
| 133 | #define IO_REPARSE_TAG_DFS 0x8000000A |
| 134 | /* Used by the DFS filter See MS-DFSC */ |
| 135 | #define IO_REPARSE_TAG_DFSR 0x80000012 |
| 136 | #define IO_REPARSE_TAG_FILTER_MANAGER 0x8000000B |
| 137 | /* See section MS-FSCC 2.1.2.4 */ |
| 138 | #define IO_REPARSE_TAG_SYMLINK 0xA000000C |
| 139 | #define IO_REPARSE_TAG_DEDUP 0x80000013 |
| 140 | #define IO_REPARSE_APPXSTREAM 0xC0000014 |
| 141 | /* NFS symlinks, Win 8/SMB3 and later */ |
| 142 | #define IO_REPARSE_TAG_NFS 0x80000014 |
Steve French | 131ea1e | 2019-09-24 23:27:34 -0500 | [diff] [blame] | 143 | /* |
| 144 | * AzureFileSync - see |
| 145 | * https://docs.microsoft.com/en-us/azure/storage/files/storage-sync-cloud-tiering |
| 146 | */ |
| 147 | #define IO_REPARSE_TAG_AZ_FILE_SYNC 0x8000001e |
| 148 | /* WSL reparse tags */ |
| 149 | #define IO_REPARSE_TAG_LX_SYMLINK 0xA000001D |
| 150 | #define IO_REPARSE_TAG_AF_UNIX 0x80000023 |
| 151 | #define IO_REPARSE_TAG_LX_FIFO 0x80000024 |
| 152 | #define IO_REPARSE_TAG_LX_CHR 0x80000025 |
| 153 | #define IO_REPARSE_TAG_LX_BLK 0x80000026 |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 154 | |
Steve French | fc111fb | 2021-09-08 23:06:24 -0500 | [diff] [blame] | 155 | #define IO_REPARSE_TAG_LX_SYMLINK_LE cpu_to_le32(0xA000001D) |
| 156 | #define IO_REPARSE_TAG_AF_UNIX_LE cpu_to_le32(0x80000023) |
| 157 | #define IO_REPARSE_TAG_LX_FIFO_LE cpu_to_le32(0x80000024) |
| 158 | #define IO_REPARSE_TAG_LX_CHR_LE cpu_to_le32(0x80000025) |
| 159 | #define IO_REPARSE_TAG_LX_BLK_LE cpu_to_le32(0x80000026) |
| 160 | |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 161 | /* fsctl flags */ |
| 162 | /* If Flags is set to this value, the request is an FSCTL not ioctl request */ |
| 163 | #define SMB2_0_IOCTL_IS_FSCTL 0x00000001 |
Steve French | fc111fb | 2021-09-08 23:06:24 -0500 | [diff] [blame] | 164 | #endif /* __SMBFSCTL_H */ |