Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: LGPL-2.1+ */
0002 /*
0003  *   SMB, CIFS, SMB2 FSCTL definitions
0004  *
0005  *   Copyright (c) International Business Machines  Corp., 2002,2013
0006  *   Author(s): Steve French (sfrench@us.ibm.com)
0007  *
0008  */
0009 
0010 /* IOCTL information */
0011 /*
0012  * List of ioctl/fsctl function codes that are or could be useful in the
0013  * future to remote clients like cifs or SMB2/SMB3 client.  This is probably
0014  * a slightly larger set of fsctls that NTFS local filesystem could handle,
0015  * including the seven below that we do not have struct definitions for.
0016  * Even with protocol definitions for most of these now available, we still
0017  * need to do some experimentation to identify which are practical to do
0018  * remotely.  Some of the following, such as the encryption/compression ones
0019  * could be invoked from tools via a specialized hook into the VFS rather
0020  * than via the standard vfs entry points
0021  *
0022  * See MS-SMB2 Section 2.2.31 (last checked September 2021, all of that list are
0023  * below). Additional detail on less common ones can be found in MS-FSCC
0024  * section 2.3.
0025  */
0026 
0027 #ifndef __SMBFSCTL_H
0028 #define __SMBFSCTL_H
0029 
0030 /*
0031  * FSCTL values are 32 bits and are constructed as
0032  * <device 16bits> <access 2bits> <function 12bits> <method 2bits>
0033  */
0034 /* Device */
0035 #define FSCTL_DEVICE_DFS                 (0x0006 << 16)
0036 #define FSCTL_DEVICE_FILE_SYSTEM         (0x0009 << 16)
0037 #define FSCTL_DEVICE_NAMED_PIPE          (0x0011 << 16)
0038 #define FSCTL_DEVICE_NETWORK_FILE_SYSTEM (0x0014 << 16)
0039 #define FSCTL_DEVICE_MASK                0xffff0000
0040 /* Access */
0041 #define FSCTL_DEVICE_ACCESS_FILE_ANY_ACCESS        (0x00 << 14)
0042 #define FSCTL_DEVICE_ACCESS_FILE_READ_ACCESS       (0x01 << 14)
0043 #define FSCTL_DEVICE_ACCESS_FILE_WRITE_ACCESS      (0x02 << 14)
0044 #define FSCTL_DEVICE_ACCESS_FILE_READ_WRITE_ACCESS (0x03 << 14)
0045 #define FSCTL_DEVICE_ACCESS_MASK                   0x0000c000
0046 /* Function */
0047 #define FSCTL_DEVICE_FUNCTION_MASK       0x00003ffc
0048 /* Method */
0049 #define FSCTL_DEVICE_METHOD_BUFFERED   0x00
0050 #define FSCTL_DEVICE_METHOD_IN_DIRECT  0x01
0051 #define FSCTL_DEVICE_METHOD_OUT_DIRECT 0x02
0052 #define FSCTL_DEVICE_METHOD_NEITHER    0x03
0053 #define FSCTL_DEVICE_METHOD_MASK       0x00000003
0054 
0055 
0056 #define FSCTL_DFS_GET_REFERRALS      0x00060194
0057 #define FSCTL_DFS_GET_REFERRALS_EX   0x000601B0
0058 #define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000
0059 #define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004
0060 #define FSCTL_REQUEST_BATCH_OPLOCK   0x00090008
0061 #define FSCTL_LOCK_VOLUME            0x00090018
0062 #define FSCTL_UNLOCK_VOLUME          0x0009001C
0063 #define FSCTL_IS_PATHNAME_VALID      0x0009002C /* BB add struct */
0064 #define FSCTL_GET_COMPRESSION        0x0009003C /* BB add struct */
0065 #define FSCTL_SET_COMPRESSION        0x0009C040 /* BB add struct */
0066 #define FSCTL_QUERY_FAT_BPB          0x00090058 /* BB add struct */
0067 /* Verify the next FSCTL number, we had it as 0x00090090 before */
0068 #define FSCTL_FILESYSTEM_GET_STATS   0x00090060 /* BB add struct */
0069 #define FSCTL_GET_NTFS_VOLUME_DATA   0x00090064 /* BB add struct */
0070 #define FSCTL_GET_RETRIEVAL_POINTERS 0x00090073 /* BB add struct */
0071 #define FSCTL_IS_VOLUME_DIRTY        0x00090078 /* BB add struct */
0072 #define FSCTL_ALLOW_EXTENDED_DASD_IO 0x00090083 /* BB add struct */
0073 #define FSCTL_REQUEST_FILTER_OPLOCK  0x0009008C
0074 #define FSCTL_FIND_FILES_BY_SID      0x0009008F /* BB add struct */
0075 #define FSCTL_SET_OBJECT_ID          0x00090098 /* BB add struct */
0076 #define FSCTL_GET_OBJECT_ID          0x0009009C /* BB add struct */
0077 #define FSCTL_DELETE_OBJECT_ID       0x000900A0 /* BB add struct */
0078 #define FSCTL_SET_REPARSE_POINT      0x000900A4 /* BB add struct */
0079 #define FSCTL_GET_REPARSE_POINT      0x000900A8 /* BB add struct */
0080 #define FSCTL_DELETE_REPARSE_POINT   0x000900AC /* BB add struct */
0081 #define FSCTL_SET_OBJECT_ID_EXTENDED 0x000900BC /* BB add struct */
0082 #define FSCTL_CREATE_OR_GET_OBJECT_ID 0x000900C0 /* BB add struct */
0083 #define FSCTL_SET_SPARSE             0x000900C4 /* BB add struct */
0084 #define FSCTL_SET_ZERO_DATA          0x000980C8
0085 #define FSCTL_SET_ENCRYPTION         0x000900D7 /* BB add struct */
0086 #define FSCTL_ENCRYPTION_FSCTL_IO    0x000900DB /* BB add struct */
0087 #define FSCTL_WRITE_RAW_ENCRYPTED    0x000900DF /* BB add struct */
0088 #define FSCTL_READ_RAW_ENCRYPTED     0x000900E3 /* BB add struct */
0089 #define FSCTL_READ_FILE_USN_DATA     0x000900EB /* BB add struct */
0090 #define FSCTL_WRITE_USN_CLOSE_RECORD 0x000900EF /* BB add struct */
0091 #define FSCTL_MARK_HANDLE        0x000900FC /* BB add struct */
0092 #define FSCTL_SIS_COPYFILE           0x00090100 /* BB add struct */
0093 #define FSCTL_RECALL_FILE            0x00090117 /* BB add struct */
0094 #define FSCTL_QUERY_SPARING_INFO     0x00090138 /* BB add struct */
0095 #define FSCTL_QUERY_ON_DISK_VOLUME_INFO 0x0009013C
0096 #define FSCTL_SET_ZERO_ON_DEALLOC    0x00090194 /* BB add struct */
0097 #define FSCTL_SET_SHORT_NAME_BEHAVIOR 0x000901B4 /* BB add struct */
0098 #define FSCTL_GET_INTEGRITY_INFORMATION 0x0009027C
0099 #define FSCTL_QUERY_FILE_REGIONS     0x00090284
0100 #define FSCTL_GET_REFS_VOLUME_DATA   0x000902D8 /* See MS-FSCC 2.3.24 */
0101 #define FSCTL_SET_INTEGRITY_INFORMATION_EXT 0x00090380
0102 #define FSCTL_GET_RETRIEVAL_POINTERS_AND_REFCOUNT 0x000903d3
0103 #define FSCTL_GET_RETRIEVAL_POINTER_COUNT 0x0009042b
0104 #define FSCTL_REFS_STREAM_SNAPSHOT_MANAGEMENT 0x00090440
0105 #define FSCTL_QUERY_ALLOCATED_RANGES 0x000940CF
0106 #define FSCTL_OFFLOAD_READ  0x00094264 /* BB add struct */
0107 #define FSCTL_OFFLOAD_WRITE 0x00098268 /* BB add struct */
0108 #define FSCTL_SET_DEFECT_MANAGEMENT  0x00098134 /* BB add struct */
0109 #define FSCTL_FILE_LEVEL_TRIM        0x00098208 /* BB add struct */
0110 #define FSCTL_DUPLICATE_EXTENTS_TO_FILE 0x00098344
0111 #define FSCTL_DUPLICATE_EXTENTS_TO_FILE_EX 0x000983E8
0112 #define FSCTL_SIS_LINK_FILES         0x0009C104
0113 #define FSCTL_SET_INTEGRITY_INFORMATION 0x0009C280
0114 #define FSCTL_PIPE_PEEK              0x0011400C /* BB add struct */
0115 #define FSCTL_PIPE_TRANSCEIVE        0x0011C017 /* BB add struct */
0116 /* strange that the number for this op is not sequential with previous op */
0117 #define FSCTL_PIPE_WAIT              0x00110018 /* BB add struct */
0118 /* Enumerate previous versions of a file */
0119 #define FSCTL_SRV_ENUMERATE_SNAPSHOTS 0x00144064
0120 /* Retrieve an opaque file reference for server-side data movement ie copy */
0121 #define FSCTL_SRV_REQUEST_RESUME_KEY 0x00140078
0122 #define FSCTL_LMR_REQUEST_RESILIENCY 0x001401D4
0123 #define FSCTL_LMR_GET_LINK_TRACK_INF 0x001400E8 /* BB add struct */
0124 #define FSCTL_LMR_SET_LINK_TRACK_INF 0x001400EC /* BB add struct */
0125 #define FSCTL_VALIDATE_NEGOTIATE_INFO 0x00140204
0126 /* Perform server-side data movement */
0127 #define FSCTL_SRV_COPYCHUNK 0x001440F2
0128 #define FSCTL_SRV_COPYCHUNK_WRITE 0x001480F2
0129 #define FSCTL_QUERY_NETWORK_INTERFACE_INFO 0x001401FC /* BB add struct */
0130 #define FSCTL_SRV_READ_HASH          0x001441BB /* BB add struct */
0131 
0132 /* See FSCC 2.1.2.5 */
0133 #define IO_REPARSE_TAG_MOUNT_POINT   0xA0000003
0134 #define IO_REPARSE_TAG_HSM           0xC0000004
0135 #define IO_REPARSE_TAG_SIS           0x80000007
0136 #define IO_REPARSE_TAG_HSM2          0x80000006
0137 #define IO_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
0138 /* Used by the DFS filter. See MS-DFSC */
0139 #define IO_REPARSE_TAG_DFS           0x8000000A
0140 /* Used by the DFS filter See MS-DFSC */
0141 #define IO_REPARSE_TAG_DFSR          0x80000012
0142 #define IO_REPARSE_TAG_FILTER_MANAGER 0x8000000B
0143 /* See section MS-FSCC 2.1.2.4 */
0144 #define IO_REPARSE_TAG_SYMLINK       0xA000000C
0145 #define IO_REPARSE_TAG_DEDUP         0x80000013
0146 #define IO_REPARSE_APPXSTREAM        0xC0000014
0147 /* NFS symlinks, Win 8/SMB3 and later */
0148 #define IO_REPARSE_TAG_NFS           0x80000014
0149 /*
0150  * AzureFileSync - see
0151  * https://docs.microsoft.com/en-us/azure/storage/files/storage-sync-cloud-tiering
0152  */
0153 #define IO_REPARSE_TAG_AZ_FILE_SYNC  0x8000001e
0154 /* WSL reparse tags */
0155 #define IO_REPARSE_TAG_LX_SYMLINK    0xA000001D
0156 #define IO_REPARSE_TAG_AF_UNIX       0x80000023
0157 #define IO_REPARSE_TAG_LX_FIFO       0x80000024
0158 #define IO_REPARSE_TAG_LX_CHR        0x80000025
0159 #define IO_REPARSE_TAG_LX_BLK        0x80000026
0160 
0161 #define IO_REPARSE_TAG_LX_SYMLINK_LE    cpu_to_le32(0xA000001D)
0162 #define IO_REPARSE_TAG_AF_UNIX_LE   cpu_to_le32(0x80000023)
0163 #define IO_REPARSE_TAG_LX_FIFO_LE   cpu_to_le32(0x80000024)
0164 #define IO_REPARSE_TAG_LX_CHR_LE    cpu_to_le32(0x80000025)
0165 #define IO_REPARSE_TAG_LX_BLK_LE    cpu_to_le32(0x80000026)
0166 
0167 /* fsctl flags */
0168 /* If Flags is set to this value, the request is an FSCTL not ioctl request */
0169 #define SMB2_0_IOCTL_IS_FSCTL       0x00000001
0170 #endif /* __SMBFSCTL_H */