xref: /kernel/linux/linux-5.10/fs/cifs/smbfsctl.h (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci *   fs/cifs/smbfsctl.h: SMB, CIFS, SMB2 FSCTL definitions
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci *   Copyright (c) International Business Machines  Corp., 2002,2013
58c2ecf20Sopenharmony_ci *   Author(s): Steve French (sfrench@us.ibm.com)
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci *   This library is free software; you can redistribute it and/or modify
88c2ecf20Sopenharmony_ci *   it under the terms of the GNU Lesser General Public License as published
98c2ecf20Sopenharmony_ci *   by the Free Software Foundation; either version 2.1 of the License, or
108c2ecf20Sopenharmony_ci *   (at your option) any later version.
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci *   This library is distributed in the hope that it will be useful,
138c2ecf20Sopenharmony_ci *   but WITHOUT ANY WARRANTY; without even the implied warranty of
148c2ecf20Sopenharmony_ci *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
158c2ecf20Sopenharmony_ci *   the GNU Lesser General Public License for more details.
168c2ecf20Sopenharmony_ci *
178c2ecf20Sopenharmony_ci *   You should have received a copy of the GNU Lesser General Public License
188c2ecf20Sopenharmony_ci *   along with this library; if not, write to the Free Software
198c2ecf20Sopenharmony_ci *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
208c2ecf20Sopenharmony_ci */
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci/* IOCTL information */
238c2ecf20Sopenharmony_ci/*
248c2ecf20Sopenharmony_ci * List of ioctl/fsctl function codes that are or could be useful in the
258c2ecf20Sopenharmony_ci * future to remote clients like cifs or SMB2/SMB3 client.  This is probably
268c2ecf20Sopenharmony_ci * a slightly larger set of fsctls that NTFS local filesystem could handle,
278c2ecf20Sopenharmony_ci * including the seven below that we do not have struct definitions for.
288c2ecf20Sopenharmony_ci * Even with protocol definitions for most of these now available, we still
298c2ecf20Sopenharmony_ci * need to do some experimentation to identify which are practical to do
308c2ecf20Sopenharmony_ci * remotely.  Some of the following, such as the encryption/compression ones
318c2ecf20Sopenharmony_ci * could be invoked from tools via a specialized hook into the VFS rather
328c2ecf20Sopenharmony_ci * than via the standard vfs entry points
338c2ecf20Sopenharmony_ci *
348c2ecf20Sopenharmony_ci * See MS-SMB2 Section 2.2.31 (last checked June 2013, all of that list are
358c2ecf20Sopenharmony_ci * below). Additional detail on less common ones can be found in MS-FSCC
368c2ecf20Sopenharmony_ci * section 2.3.
378c2ecf20Sopenharmony_ci */
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci/*
408c2ecf20Sopenharmony_ci * FSCTL values are 32 bits and are constructed as
418c2ecf20Sopenharmony_ci * <device 16bits> <access 2bits> <function 12bits> <method 2bits>
428c2ecf20Sopenharmony_ci */
438c2ecf20Sopenharmony_ci/* Device */
448c2ecf20Sopenharmony_ci#define FSCTL_DEVICE_DFS                 (0x0006 << 16)
458c2ecf20Sopenharmony_ci#define FSCTL_DEVICE_FILE_SYSTEM         (0x0009 << 16)
468c2ecf20Sopenharmony_ci#define FSCTL_DEVICE_NAMED_PIPE          (0x0011 << 16)
478c2ecf20Sopenharmony_ci#define FSCTL_DEVICE_NETWORK_FILE_SYSTEM (0x0014 << 16)
488c2ecf20Sopenharmony_ci#define FSCTL_DEVICE_MASK                0xffff0000
498c2ecf20Sopenharmony_ci/* Access */
508c2ecf20Sopenharmony_ci#define FSCTL_DEVICE_ACCESS_FILE_ANY_ACCESS        (0x00 << 14)
518c2ecf20Sopenharmony_ci#define FSCTL_DEVICE_ACCESS_FILE_READ_ACCESS       (0x01 << 14)
528c2ecf20Sopenharmony_ci#define FSCTL_DEVICE_ACCESS_FILE_WRITE_ACCESS      (0x02 << 14)
538c2ecf20Sopenharmony_ci#define FSCTL_DEVICE_ACCESS_FILE_READ_WRITE_ACCESS (0x03 << 14)
548c2ecf20Sopenharmony_ci#define FSCTL_DEVICE_ACCESS_MASK                   0x0000c000
558c2ecf20Sopenharmony_ci/* Function */
568c2ecf20Sopenharmony_ci#define FSCTL_DEVICE_FUNCTION_MASK       0x00003ffc
578c2ecf20Sopenharmony_ci/* Method */
588c2ecf20Sopenharmony_ci#define FSCTL_DEVICE_METHOD_BUFFERED   0x00
598c2ecf20Sopenharmony_ci#define FSCTL_DEVICE_METHOD_IN_DIRECT  0x01
608c2ecf20Sopenharmony_ci#define FSCTL_DEVICE_METHOD_OUT_DIRECT 0x02
618c2ecf20Sopenharmony_ci#define FSCTL_DEVICE_METHOD_NEITHER    0x03
628c2ecf20Sopenharmony_ci#define FSCTL_DEVICE_METHOD_MASK       0x00000003
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#define FSCTL_DFS_GET_REFERRALS      0x00060194
668c2ecf20Sopenharmony_ci#define FSCTL_DFS_GET_REFERRALS_EX   0x000601B0
678c2ecf20Sopenharmony_ci#define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000
688c2ecf20Sopenharmony_ci#define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004
698c2ecf20Sopenharmony_ci#define FSCTL_REQUEST_BATCH_OPLOCK   0x00090008
708c2ecf20Sopenharmony_ci#define FSCTL_LOCK_VOLUME            0x00090018
718c2ecf20Sopenharmony_ci#define FSCTL_UNLOCK_VOLUME          0x0009001C
728c2ecf20Sopenharmony_ci#define FSCTL_IS_PATHNAME_VALID      0x0009002C /* BB add struct */
738c2ecf20Sopenharmony_ci#define FSCTL_GET_COMPRESSION        0x0009003C /* BB add struct */
748c2ecf20Sopenharmony_ci#define FSCTL_SET_COMPRESSION        0x0009C040 /* BB add struct */
758c2ecf20Sopenharmony_ci#define FSCTL_QUERY_FAT_BPB          0x00090058 /* BB add struct */
768c2ecf20Sopenharmony_ci/* Verify the next FSCTL number, we had it as 0x00090090 before */
778c2ecf20Sopenharmony_ci#define FSCTL_FILESYSTEM_GET_STATS   0x00090060 /* BB add struct */
788c2ecf20Sopenharmony_ci#define FSCTL_GET_NTFS_VOLUME_DATA   0x00090064 /* BB add struct */
798c2ecf20Sopenharmony_ci#define FSCTL_GET_RETRIEVAL_POINTERS 0x00090073 /* BB add struct */
808c2ecf20Sopenharmony_ci#define FSCTL_IS_VOLUME_DIRTY        0x00090078 /* BB add struct */
818c2ecf20Sopenharmony_ci#define FSCTL_ALLOW_EXTENDED_DASD_IO 0x00090083 /* BB add struct */
828c2ecf20Sopenharmony_ci#define FSCTL_REQUEST_FILTER_OPLOCK  0x0009008C
838c2ecf20Sopenharmony_ci#define FSCTL_FIND_FILES_BY_SID      0x0009008F /* BB add struct */
848c2ecf20Sopenharmony_ci#define FSCTL_SET_OBJECT_ID          0x00090098 /* BB add struct */
858c2ecf20Sopenharmony_ci#define FSCTL_GET_OBJECT_ID          0x0009009C /* BB add struct */
868c2ecf20Sopenharmony_ci#define FSCTL_DELETE_OBJECT_ID       0x000900A0 /* BB add struct */
878c2ecf20Sopenharmony_ci#define FSCTL_SET_REPARSE_POINT      0x000900A4 /* BB add struct */
888c2ecf20Sopenharmony_ci#define FSCTL_GET_REPARSE_POINT      0x000900A8 /* BB add struct */
898c2ecf20Sopenharmony_ci#define FSCTL_DELETE_REPARSE_POINT   0x000900AC /* BB add struct */
908c2ecf20Sopenharmony_ci#define FSCTL_SET_OBJECT_ID_EXTENDED 0x000900BC /* BB add struct */
918c2ecf20Sopenharmony_ci#define FSCTL_CREATE_OR_GET_OBJECT_ID 0x000900C0 /* BB add struct */
928c2ecf20Sopenharmony_ci#define FSCTL_SET_SPARSE             0x000900C4 /* BB add struct */
938c2ecf20Sopenharmony_ci#define FSCTL_SET_ZERO_DATA          0x000980C8
948c2ecf20Sopenharmony_ci#define FSCTL_SET_ENCRYPTION         0x000900D7 /* BB add struct */
958c2ecf20Sopenharmony_ci#define FSCTL_ENCRYPTION_FSCTL_IO    0x000900DB /* BB add struct */
968c2ecf20Sopenharmony_ci#define FSCTL_WRITE_RAW_ENCRYPTED    0x000900DF /* BB add struct */
978c2ecf20Sopenharmony_ci#define FSCTL_READ_RAW_ENCRYPTED     0x000900E3 /* BB add struct */
988c2ecf20Sopenharmony_ci#define FSCTL_READ_FILE_USN_DATA     0x000900EB /* BB add struct */
998c2ecf20Sopenharmony_ci#define FSCTL_WRITE_USN_CLOSE_RECORD 0x000900EF /* BB add struct */
1008c2ecf20Sopenharmony_ci#define FSCTL_SIS_COPYFILE           0x00090100 /* BB add struct */
1018c2ecf20Sopenharmony_ci#define FSCTL_RECALL_FILE            0x00090117 /* BB add struct */
1028c2ecf20Sopenharmony_ci#define FSCTL_QUERY_SPARING_INFO     0x00090138 /* BB add struct */
1038c2ecf20Sopenharmony_ci#define FSCTL_SET_ZERO_ON_DEALLOC    0x00090194 /* BB add struct */
1048c2ecf20Sopenharmony_ci#define FSCTL_SET_SHORT_NAME_BEHAVIOR 0x000901B4 /* BB add struct */
1058c2ecf20Sopenharmony_ci#define FSCTL_GET_INTEGRITY_INFORMATION 0x0009027C
1068c2ecf20Sopenharmony_ci#define FSCTL_GET_RETRIEVAL_POINTERS_AND_REFCOUNT 0x000903d3
1078c2ecf20Sopenharmony_ci#define FSCTL_GET_RETRIEVAL_POINTER_COUNT 0x0009042b
1088c2ecf20Sopenharmony_ci#define FSCTL_QUERY_ALLOCATED_RANGES 0x000940CF
1098c2ecf20Sopenharmony_ci#define FSCTL_SET_DEFECT_MANAGEMENT  0x00098134 /* BB add struct */
1108c2ecf20Sopenharmony_ci#define FSCTL_FILE_LEVEL_TRIM        0x00098208 /* BB add struct */
1118c2ecf20Sopenharmony_ci#define FSCTL_DUPLICATE_EXTENTS_TO_FILE 0x00098344
1128c2ecf20Sopenharmony_ci#define FSCTL_SIS_LINK_FILES         0x0009C104
1138c2ecf20Sopenharmony_ci#define FSCTL_SET_INTEGRITY_INFORMATION 0x0009C280
1148c2ecf20Sopenharmony_ci#define FSCTL_PIPE_PEEK              0x0011400C /* BB add struct */
1158c2ecf20Sopenharmony_ci#define FSCTL_PIPE_TRANSCEIVE        0x0011C017 /* BB add struct */
1168c2ecf20Sopenharmony_ci/* strange that the number for this op is not sequential with previous op */
1178c2ecf20Sopenharmony_ci#define FSCTL_PIPE_WAIT              0x00110018 /* BB add struct */
1188c2ecf20Sopenharmony_ci/* Enumerate previous versions of a file */
1198c2ecf20Sopenharmony_ci#define FSCTL_SRV_ENUMERATE_SNAPSHOTS 0x00144064
1208c2ecf20Sopenharmony_ci/* Retrieve an opaque file reference for server-side data movement ie copy */
1218c2ecf20Sopenharmony_ci#define FSCTL_SRV_REQUEST_RESUME_KEY 0x00140078
1228c2ecf20Sopenharmony_ci#define FSCTL_LMR_REQUEST_RESILIENCY 0x001401D4
1238c2ecf20Sopenharmony_ci#define FSCTL_LMR_GET_LINK_TRACK_INF 0x001400E8 /* BB add struct */
1248c2ecf20Sopenharmony_ci#define FSCTL_LMR_SET_LINK_TRACK_INF 0x001400EC /* BB add struct */
1258c2ecf20Sopenharmony_ci#define FSCTL_VALIDATE_NEGOTIATE_INFO 0x00140204
1268c2ecf20Sopenharmony_ci/* Perform server-side data movement */
1278c2ecf20Sopenharmony_ci#define FSCTL_SRV_COPYCHUNK 0x001440F2
1288c2ecf20Sopenharmony_ci#define FSCTL_SRV_COPYCHUNK_WRITE 0x001480F2
1298c2ecf20Sopenharmony_ci#define FSCTL_QUERY_NETWORK_INTERFACE_INFO 0x001401FC /* BB add struct */
1308c2ecf20Sopenharmony_ci#define FSCTL_SRV_READ_HASH          0x001441BB /* BB add struct */
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci/* See FSCC 2.1.2.5 */
1338c2ecf20Sopenharmony_ci#define IO_REPARSE_TAG_MOUNT_POINT   0xA0000003
1348c2ecf20Sopenharmony_ci#define IO_REPARSE_TAG_HSM           0xC0000004
1358c2ecf20Sopenharmony_ci#define IO_REPARSE_TAG_SIS           0x80000007
1368c2ecf20Sopenharmony_ci#define IO_REPARSE_TAG_HSM2          0x80000006
1378c2ecf20Sopenharmony_ci#define IO_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
1388c2ecf20Sopenharmony_ci/* Used by the DFS filter. See MS-DFSC */
1398c2ecf20Sopenharmony_ci#define IO_REPARSE_TAG_DFS           0x8000000A
1408c2ecf20Sopenharmony_ci/* Used by the DFS filter See MS-DFSC */
1418c2ecf20Sopenharmony_ci#define IO_REPARSE_TAG_DFSR          0x80000012
1428c2ecf20Sopenharmony_ci#define IO_REPARSE_TAG_FILTER_MANAGER 0x8000000B
1438c2ecf20Sopenharmony_ci/* See section MS-FSCC 2.1.2.4 */
1448c2ecf20Sopenharmony_ci#define IO_REPARSE_TAG_SYMLINK       0xA000000C
1458c2ecf20Sopenharmony_ci#define IO_REPARSE_TAG_DEDUP         0x80000013
1468c2ecf20Sopenharmony_ci#define IO_REPARSE_APPXSTREAM	     0xC0000014
1478c2ecf20Sopenharmony_ci/* NFS symlinks, Win 8/SMB3 and later */
1488c2ecf20Sopenharmony_ci#define IO_REPARSE_TAG_NFS           0x80000014
1498c2ecf20Sopenharmony_ci/*
1508c2ecf20Sopenharmony_ci * AzureFileSync - see
1518c2ecf20Sopenharmony_ci * https://docs.microsoft.com/en-us/azure/storage/files/storage-sync-cloud-tiering
1528c2ecf20Sopenharmony_ci */
1538c2ecf20Sopenharmony_ci#define IO_REPARSE_TAG_AZ_FILE_SYNC  0x8000001e
1548c2ecf20Sopenharmony_ci/* WSL reparse tags */
1558c2ecf20Sopenharmony_ci#define IO_REPARSE_TAG_LX_SYMLINK    0xA000001D
1568c2ecf20Sopenharmony_ci#define IO_REPARSE_TAG_AF_UNIX	     0x80000023
1578c2ecf20Sopenharmony_ci#define IO_REPARSE_TAG_LX_FIFO	     0x80000024
1588c2ecf20Sopenharmony_ci#define IO_REPARSE_TAG_LX_CHR	     0x80000025
1598c2ecf20Sopenharmony_ci#define IO_REPARSE_TAG_LX_BLK	     0x80000026
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci/* fsctl flags */
1628c2ecf20Sopenharmony_ci/* If Flags is set to this value, the request is an FSCTL not ioctl request */
1638c2ecf20Sopenharmony_ci#define SMB2_0_IOCTL_IS_FSCTL		0x00000001
1648c2ecf20Sopenharmony_ci
165