linux/fs/smb/common/smbfsctl.h

/* SPDX-License-Identifier: LGPL-2.1+ */
/*
 *   SMB, CIFS, SMB2 FSCTL definitions
 *
 *   Copyright (c) International Business Machines  Corp., 2002,2013
 *   Author(s): Steve French ([email protected])
 *
 */

/* IOCTL information */
/*
 * List of ioctl/fsctl function codes that are or could be useful in the
 * future to remote clients like cifs or SMB2/SMB3 client.  This is probably
 * a slightly larger set of fsctls that NTFS local filesystem could handle,
 * including the seven below that we do not have struct definitions for.
 * Even with protocol definitions for most of these now available, we still
 * need to do some experimentation to identify which are practical to do
 * remotely.  Some of the following, such as the encryption/compression ones
 * could be invoked from tools via a specialized hook into the VFS rather
 * than via the standard vfs entry points
 *
 * See MS-SMB2 Section 2.2.31 (last checked September 2021, all of that list are
 * below). Additional detail on less common ones can be found in MS-FSCC
 * section 2.3.
 */

#ifndef __SMBFSCTL_H
#define __SMBFSCTL_H

/*
 * FSCTL values are 32 bits and are constructed as
 * <device 16bits> <access 2bits> <function 12bits> <method 2bits>
 */
/* Device */
#define FSCTL_DEVICE_DFS
#define FSCTL_DEVICE_FILE_SYSTEM
#define FSCTL_DEVICE_NAMED_PIPE
#define FSCTL_DEVICE_NETWORK_FILE_SYSTEM
#define FSCTL_DEVICE_MASK
/* Access */
#define FSCTL_DEVICE_ACCESS_FILE_ANY_ACCESS
#define FSCTL_DEVICE_ACCESS_FILE_READ_ACCESS
#define FSCTL_DEVICE_ACCESS_FILE_WRITE_ACCESS
#define FSCTL_DEVICE_ACCESS_FILE_READ_WRITE_ACCESS
#define FSCTL_DEVICE_ACCESS_MASK
/* Function */
#define FSCTL_DEVICE_FUNCTION_MASK
/* Method */
#define FSCTL_DEVICE_METHOD_BUFFERED
#define FSCTL_DEVICE_METHOD_IN_DIRECT
#define FSCTL_DEVICE_METHOD_OUT_DIRECT
#define FSCTL_DEVICE_METHOD_NEITHER
#define FSCTL_DEVICE_METHOD_MASK


#define FSCTL_DFS_GET_REFERRALS
#define FSCTL_DFS_GET_REFERRALS_EX
#define FSCTL_REQUEST_OPLOCK_LEVEL_1
#define FSCTL_REQUEST_OPLOCK_LEVEL_2
#define FSCTL_REQUEST_BATCH_OPLOCK
#define FSCTL_LOCK_VOLUME
#define FSCTL_UNLOCK_VOLUME
#define FSCTL_IS_PATHNAME_VALID
#define FSCTL_GET_COMPRESSION
#define FSCTL_SET_COMPRESSION
#define FSCTL_QUERY_FAT_BPB
/* Verify the next FSCTL number, we had it as 0x00090090 before */
#define FSCTL_FILESYSTEM_GET_STATS
#define FSCTL_GET_NTFS_VOLUME_DATA
#define FSCTL_GET_RETRIEVAL_POINTERS
#define FSCTL_IS_VOLUME_DIRTY
#define FSCTL_ALLOW_EXTENDED_DASD_IO
#define FSCTL_REQUEST_FILTER_OPLOCK
#define FSCTL_FIND_FILES_BY_SID
#define FSCTL_SET_OBJECT_ID
#define FSCTL_GET_OBJECT_ID
#define FSCTL_DELETE_OBJECT_ID
#define FSCTL_SET_REPARSE_POINT
#define FSCTL_GET_REPARSE_POINT
#define FSCTL_DELETE_REPARSE_POINT
#define FSCTL_SET_OBJECT_ID_EXTENDED
#define FSCTL_CREATE_OR_GET_OBJECT_ID
#define FSCTL_SET_SPARSE
#define FSCTL_SET_ZERO_DATA
#define FSCTL_SET_ENCRYPTION
#define FSCTL_ENCRYPTION_FSCTL_IO
#define FSCTL_WRITE_RAW_ENCRYPTED
#define FSCTL_READ_RAW_ENCRYPTED
#define FSCTL_READ_FILE_USN_DATA
#define FSCTL_WRITE_USN_CLOSE_RECORD
#define FSCTL_MARK_HANDLE
#define FSCTL_SIS_COPYFILE
#define FSCTL_RECALL_FILE
#define FSCTL_QUERY_SPARING_INFO
#define FSCTL_QUERY_ON_DISK_VOLUME_INFO
#define FSCTL_SET_ZERO_ON_DEALLOC
#define FSCTL_SET_SHORT_NAME_BEHAVIOR
#define FSCTL_GET_INTEGRITY_INFORMATION
#define FSCTL_QUERY_FILE_REGIONS
#define FSCTL_GET_REFS_VOLUME_DATA
#define FSCTL_SET_INTEGRITY_INFORMATION_EXT
#define FSCTL_GET_RETRIEVAL_POINTERS_AND_REFCOUNT
#define FSCTL_GET_RETRIEVAL_POINTER_COUNT
#define FSCTL_REFS_STREAM_SNAPSHOT_MANAGEMENT
#define FSCTL_QUERY_ALLOCATED_RANGES
#define FSCTL_OFFLOAD_READ
#define FSCTL_OFFLOAD_WRITE
#define FSCTL_SET_DEFECT_MANAGEMENT
#define FSCTL_FILE_LEVEL_TRIM
#define FSCTL_DUPLICATE_EXTENTS_TO_FILE
#define FSCTL_DUPLICATE_EXTENTS_TO_FILE_EX
#define FSCTL_SIS_LINK_FILES
#define FSCTL_SET_INTEGRITY_INFORMATION
#define FSCTL_PIPE_PEEK
#define FSCTL_PIPE_TRANSCEIVE
/* strange that the number for this op is not sequential with previous op */
#define FSCTL_PIPE_WAIT
/* Enumerate previous versions of a file */
#define FSCTL_SRV_ENUMERATE_SNAPSHOTS
/* Retrieve an opaque file reference for server-side data movement ie copy */
#define FSCTL_SRV_REQUEST_RESUME_KEY
#define FSCTL_LMR_REQUEST_RESILIENCY
#define FSCTL_LMR_GET_LINK_TRACK_INF
#define FSCTL_LMR_SET_LINK_TRACK_INF
#define FSCTL_VALIDATE_NEGOTIATE_INFO
/* Perform server-side data movement */
#define FSCTL_SRV_COPYCHUNK
#define FSCTL_SRV_COPYCHUNK_WRITE
#define FSCTL_QUERY_NETWORK_INTERFACE_INFO
#define FSCTL_SRV_READ_HASH

/* See FSCC 2.1.2.5 */
#define IO_REPARSE_TAG_MOUNT_POINT
#define IO_REPARSE_TAG_HSM
#define IO_REPARSE_TAG_SIS
#define IO_REPARSE_TAG_HSM2
#define IO_REPARSE_TAG_DRIVER_EXTENDER
/* Used by the DFS filter. See MS-DFSC */
#define IO_REPARSE_TAG_DFS
/* Used by the DFS filter See MS-DFSC */
#define IO_REPARSE_TAG_DFSR
#define IO_REPARSE_TAG_FILTER_MANAGER
/* See section MS-FSCC 2.1.2.4 */
#define IO_REPARSE_TAG_SYMLINK
#define IO_REPARSE_TAG_DEDUP
#define IO_REPARSE_APPXSTREAM
/* NFS symlinks, Win 8/SMB3 and later */
#define IO_REPARSE_TAG_NFS
/*
 * AzureFileSync - see
 * https://docs.microsoft.com/en-us/azure/storage/files/storage-sync-cloud-tiering
 */
#define IO_REPARSE_TAG_AZ_FILE_SYNC
/* WSL reparse tags */
#define IO_REPARSE_TAG_LX_SYMLINK
#define IO_REPARSE_TAG_AF_UNIX
#define IO_REPARSE_TAG_LX_FIFO
#define IO_REPARSE_TAG_LX_CHR
#define IO_REPARSE_TAG_LX_BLK

/* fsctl flags */
/* If Flags is set to this value, the request is an FSCTL not ioctl request */
#define SMB2_0_IOCTL_IS_FSCTL
#endif /* __SMBFSCTL_H */