| 1 |
/* SPDX-License-Identifier: LGPL-2.1 */ |
| 2 |
/* |
| 3 |
* |
| 4 |
* Copyright (c) International Business Machines Corp., 2009, 2013 |
| 5 |
* Etersoft, 2012 |
| 6 |
* 2018 Samsung Electronics Co., Ltd. |
| 7 |
* Author(s): Steve French ([email protected]) |
| 8 |
* Pavel Shilovsky ([email protected]) 2012 |
| 9 |
* Namjae Jeon ([email protected]) |
| 10 |
* |
| 11 |
*/ |
| 12 |
#ifndef _COMMON_SMB_FSCC_H |
| 13 |
#define _COMMON_SMB_FSCC_H |
| 14 |
|
| 15 |
/* See MS-FSCC 2.4.8 */ |
| 16 |
typedef struct { |
| 17 |
__le32 NextEntryOffset; |
| 18 |
__u32 FileIndex; |
| 19 |
__le64 CreationTime; |
| 20 |
__le64 LastAccessTime; |
| 21 |
__le64 LastWriteTime; |
| 22 |
__le64 ChangeTime; |
| 23 |
__le64 EndOfFile; |
| 24 |
__le64 AllocationSize; |
| 25 |
__le32 ExtFileAttributes; |
| 26 |
__le32 FileNameLength; |
| 27 |
__le32 EaSize; /* length of the xattrs */ |
| 28 |
__u8 ShortNameLength; |
| 29 |
__u8 Reserved; |
| 30 |
__u8 ShortName[24]; |
| 31 |
char FileName[]; |
| 32 |
} __packed FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */ |
| 33 |
|
| 34 |
/* See MS-FSCC 2.4.10 */ |
| 35 |
typedef struct { |
| 36 |
__le32 NextEntryOffset; |
| 37 |
__u32 FileIndex; |
| 38 |
__le64 CreationTime; |
| 39 |
__le64 LastAccessTime; |
| 40 |
__le64 LastWriteTime; |
| 41 |
__le64 ChangeTime; |
| 42 |
__le64 EndOfFile; |
| 43 |
__le64 AllocationSize; |
| 44 |
__le32 ExtFileAttributes; |
| 45 |
__le32 FileNameLength; |
| 46 |
char FileName[]; |
| 47 |
} __packed FILE_DIRECTORY_INFO; /* level 0x101 FF resp data */ |
| 48 |
|
| 49 |
/* See MS-FSCC 2.4.14 */ |
| 50 |
typedef struct { |
| 51 |
__le32 NextEntryOffset; |
| 52 |
__u32 FileIndex; |
| 53 |
__le64 CreationTime; |
| 54 |
__le64 LastAccessTime; |
| 55 |
__le64 LastWriteTime; |
| 56 |
__le64 ChangeTime; |
| 57 |
__le64 EndOfFile; |
| 58 |
__le64 AllocationSize; |
| 59 |
__le32 ExtFileAttributes; |
| 60 |
__le32 FileNameLength; |
| 61 |
__le32 EaSize; /* length of the xattrs */ |
| 62 |
char FileName[]; |
| 63 |
} __packed FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */ |
| 64 |
|
| 65 |
/* See MS-FSCC 2.4.24 */ |
| 66 |
typedef struct { |
| 67 |
__le32 NextEntryOffset; |
| 68 |
__u32 FileIndex; |
| 69 |
__le64 CreationTime; |
| 70 |
__le64 LastAccessTime; |
| 71 |
__le64 LastWriteTime; |
| 72 |
__le64 ChangeTime; |
| 73 |
__le64 EndOfFile; |
| 74 |
__le64 AllocationSize; |
| 75 |
__le32 ExtFileAttributes; |
| 76 |
__le32 FileNameLength; |
| 77 |
__le32 EaSize; /* EA size */ |
| 78 |
__le32 Reserved; |
| 79 |
__le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/ |
| 80 |
char FileName[]; |
| 81 |
} __packed FILE_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */ |
| 82 |
|
| 83 |
/* See MS-FSCC 2.4.34 */ |
| 84 |
struct smb2_file_network_open_info { |
| 85 |
struct_group_attr(network_open_info, __packed, |
| 86 |
__le64 CreationTime; |
| 87 |
__le64 LastAccessTime; |
| 88 |
__le64 LastWriteTime; |
| 89 |
__le64 ChangeTime; |
| 90 |
__le64 AllocationSize; |
| 91 |
__le64 EndOfFile; |
| 92 |
__le32 Attributes; |
| 93 |
); |
| 94 |
__le32 Reserved; |
| 95 |
} __packed; /* level 34 Query also similar returned in close rsp and open rsp */ |
| 96 |
|
| 97 |
/* See MS-FSCC 2.5.1 */ |
| 98 |
#define MAX_FS_NAME_LEN 52 |
| 99 |
typedef struct { |
| 100 |
__le32 Attributes; |
| 101 |
__le32 MaxPathNameComponentLength; |
| 102 |
__le32 FileSystemNameLen; |
| 103 |
__le16 FileSystemName[]; /* do not have to save this - get subset? */ |
| 104 |
} __packed FILE_SYSTEM_ATTRIBUTE_INFO; |
| 105 |
|
| 106 |
/* List of FileSystemAttributes - see MS-FSCC 2.5.1 */ |
| 107 |
#define FILE_SUPPORTS_SPARSE_VDL 0x10000000 /* faster nonsparse extend */ |
| 108 |
#define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000 /* allow ioctl dup extents */ |
| 109 |
#define FILE_SUPPORT_INTEGRITY_STREAMS 0x04000000 |
| 110 |
#define FILE_SUPPORTS_USN_JOURNAL 0x02000000 |
| 111 |
#define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000 |
| 112 |
#define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000 |
| 113 |
#define FILE_SUPPORTS_HARD_LINKS 0x00400000 |
| 114 |
#define FILE_SUPPORTS_TRANSACTIONS 0x00200000 |
| 115 |
#define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000 |
| 116 |
#define FILE_READ_ONLY_VOLUME 0x00080000 |
| 117 |
#define FILE_NAMED_STREAMS 0x00040000 |
| 118 |
#define FILE_SUPPORTS_ENCRYPTION 0x00020000 |
| 119 |
#define FILE_SUPPORTS_OBJECT_IDS 0x00010000 |
| 120 |
#define FILE_VOLUME_IS_COMPRESSED 0x00008000 |
| 121 |
#define FILE_SUPPORTS_POSIX_UNLINK_RENAME 0x00000400 |
| 122 |
#define FILE_RETURNS_CLEANUP_RESULT_INFO 0x00000200 |
| 123 |
#define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100 |
| 124 |
#define FILE_SUPPORTS_REPARSE_POINTS 0x00000080 |
| 125 |
#define FILE_SUPPORTS_SPARSE_FILES 0x00000040 |
| 126 |
#define FILE_VOLUME_QUOTAS 0x00000020 |
| 127 |
#define FILE_FILE_COMPRESSION 0x00000010 |
| 128 |
#define FILE_PERSISTENT_ACLS 0x00000008 |
| 129 |
#define FILE_UNICODE_ON_DISK 0x00000004 |
| 130 |
#define FILE_CASE_PRESERVED_NAMES 0x00000002 |
| 131 |
#define FILE_CASE_SENSITIVE_SEARCH 0x00000001 |
| 132 |
|
| 133 |
/* See MS-FSCC 2.5.8 */ |
| 134 |
typedef struct { |
| 135 |
__le64 TotalAllocationUnits; |
| 136 |
__le64 AvailableAllocationUnits; |
| 137 |
__le32 SectorsPerAllocationUnit; |
| 138 |
__le32 BytesPerSector; |
| 139 |
} __packed FILE_SYSTEM_SIZE_INFO; /* size info, level 0x103 */ |
| 140 |
|
| 141 |
/* See MS-FSCC 2.5.10 */ |
| 142 |
typedef struct { |
| 143 |
__le32 DeviceType; |
| 144 |
__le32 DeviceCharacteristics; |
| 145 |
} __packed FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */ |
| 146 |
|
| 147 |
/* |
| 148 |
* File Attributes |
| 149 |
* See MS-FSCC 2.6 |
| 150 |
*/ |
| 151 |
#define FILE_ATTRIBUTE_READONLY 0x00000001 |
| 152 |
#define FILE_ATTRIBUTE_HIDDEN 0x00000002 |
| 153 |
#define FILE_ATTRIBUTE_SYSTEM 0x00000004 |
| 154 |
#define FILE_ATTRIBUTE_DIRECTORY 0x00000010 |
| 155 |
#define FILE_ATTRIBUTE_ARCHIVE 0x00000020 |
| 156 |
#define FILE_ATTRIBUTE_NORMAL 0x00000080 |
| 157 |
#define FILE_ATTRIBUTE_TEMPORARY 0x00000100 |
| 158 |
#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 |
| 159 |
#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 |
| 160 |
#define FILE_ATTRIBUTE_COMPRESSED 0x00000800 |
| 161 |
#define FILE_ATTRIBUTE_OFFLINE 0x00001000 |
| 162 |
#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 |
| 163 |
#define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 |
| 164 |
#define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000 |
| 165 |
#define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000 |
| 166 |
#define FILE_ATTRIBUTE_MASK (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | \ |
| 167 |
FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_DIRECTORY | \ |
| 168 |
FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_NORMAL | \ |
| 169 |
FILE_ATTRIBUTE_TEMPORARY | FILE_ATTRIBUTE_SPARSE_FILE | \ |
| 170 |
FILE_ATTRIBUTE_REPARSE_POINT | FILE_ATTRIBUTE_COMPRESSED | \ |
| 171 |
FILE_ATTRIBUTE_OFFLINE | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED | \ |
| 172 |
FILE_ATTRIBUTE_ENCRYPTED | FILE_ATTRIBUTE_INTEGRITY_STREAM | \ |
| 173 |
FILE_ATTRIBUTE_NO_SCRUB_DATA) |
| 174 |
|
| 175 |
#define FILE_ATTRIBUTE_READONLY_LE cpu_to_le32(FILE_ATTRIBUTE_READONLY) |
| 176 |
#define FILE_ATTRIBUTE_HIDDEN_LE cpu_to_le32(FILE_ATTRIBUTE_HIDDEN) |
| 177 |
#define FILE_ATTRIBUTE_SYSTEM_LE cpu_to_le32(FILE_ATTRIBUTE_SYSTEM) |
| 178 |
#define FILE_ATTRIBUTE_DIRECTORY_LE cpu_to_le32(FILE_ATTRIBUTE_DIRECTORY) |
| 179 |
#define FILE_ATTRIBUTE_ARCHIVE_LE cpu_to_le32(FILE_ATTRIBUTE_ARCHIVE) |
| 180 |
#define FILE_ATTRIBUTE_NORMAL_LE cpu_to_le32(FILE_ATTRIBUTE_NORMAL) |
| 181 |
#define FILE_ATTRIBUTE_TEMPORARY_LE cpu_to_le32(FILE_ATTRIBUTE_TEMPORARY) |
| 182 |
#define FILE_ATTRIBUTE_SPARSE_FILE_LE cpu_to_le32(FILE_ATTRIBUTE_SPARSE_FILE) |
| 183 |
#define FILE_ATTRIBUTE_REPARSE_POINT_LE cpu_to_le32(FILE_ATTRIBUTE_REPARSE_POINT) |
| 184 |
#define FILE_ATTRIBUTE_COMPRESSED_LE cpu_to_le32(FILE_ATTRIBUTE_COMPRESSED) |
| 185 |
#define FILE_ATTRIBUTE_OFFLINE_LE cpu_to_le32(FILE_ATTRIBUTE_OFFLINE) |
| 186 |
#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED_LE cpu_to_le32(FILE_ATTRIBUTE_NOT_CONTENT_INDEXED) |
| 187 |
#define FILE_ATTRIBUTE_ENCRYPTED_LE cpu_to_le32(FILE_ATTRIBUTE_ENCRYPTED) |
| 188 |
#define FILE_ATTRIBUTE_INTEGRITY_STREAM_LE cpu_to_le32(FILE_ATTRIBUTE_INTEGRITY_STREAM) |
| 189 |
#define FILE_ATTRIBUTE_NO_SCRUB_DATA_LE cpu_to_le32(FILE_ATTRIBUTE_NO_SCRUB_DATA) |
| 190 |
#define FILE_ATTRIBUTE_MASK_LE cpu_to_le32(FILE_ATTRIBUTE_MASK) |
| 191 |
|
| 192 |
/* |
| 193 |
* Response contains array of the following structures |
| 194 |
* See MS-FSCC 2.7.1 |
| 195 |
*/ |
| 196 |
struct file_notify_information { |
| 197 |
__le32 NextEntryOffset; |
| 198 |
__le32 Action; |
| 199 |
__le32 FileNameLength; |
| 200 |
__u8 FileName[]; |
| 201 |
} __packed; |
| 202 |
|
| 203 |
/* |
| 204 |
* See POSIX Extensions to MS-FSCC 2.3.2.1 |
| 205 |
* Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/fscc_posix_extensions.md |
| 206 |
*/ |
| 207 |
typedef struct { |
| 208 |
/* For undefined recommended transfer size return -1 in that field */ |
| 209 |
__le32 OptimalTransferSize; /* bsize on some os, iosize on other os */ |
| 210 |
__le32 BlockSize; |
| 211 |
/* The next three fields are in terms of the block size. |
| 212 |
* (above). If block size is unknown, 4096 would be a |
| 213 |
* reasonable block size for a server to report. |
| 214 |
* Note that returning the blocks/blocksavail removes need |
| 215 |
* to make a second call (to QFSInfo level 0x103 to get this info. |
| 216 |
* UserBlockAvail is typically less than or equal to BlocksAvail, |
| 217 |
* if no distinction is made return the same value in each |
| 218 |
*/ |
| 219 |
__le64 TotalBlocks; |
| 220 |
__le64 BlocksAvail; /* bfree */ |
| 221 |
__le64 UserBlocksAvail; /* bavail */ |
| 222 |
/* For undefined Node fields or FSID return -1 */ |
| 223 |
__le64 TotalFileNodes; |
| 224 |
__le64 FreeFileNodes; |
| 225 |
__le64 FileSysIdentifier; /* fsid */ |
| 226 |
/* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */ |
| 227 |
/* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */ |
| 228 |
} __packed FILE_SYSTEM_POSIX_INFO; |
| 229 |
|
| 230 |
#endif /* _COMMON_SMB_FSCC_H */ |