📄 cifspdu.h
字号:
__le16 TotalDataCount; __u16 Reserved; __le16 ParameterCount; __le16 ParameterOffset; __le16 ParameterDisplacement; __le16 DataCount; __le16 DataOffset; __le16 DataDisplacement; __u8 SetupCount; __u8 Reserved1; /* should be zero setup words following */ __u16 ByteCount; __u8 Pad; /* may be three bytes *//* followed by data area */} TRANSACTION2_QFSI_RSP;typedef struct smb_com_transaction2_get_dfs_refer_req { struct smb_hdr hdr; /* wct = 15 */ __le16 TotalParameterCount; __le16 TotalDataCount; __le16 MaxParameterCount; __le16 MaxDataCount; __u8 MaxSetupCount; __u8 Reserved; __le16 Flags; __le32 Timeout; __u16 Reserved2; __le16 ParameterCount; __le16 ParameterOffset; __le16 DataCount; __le16 DataOffset; __u8 SetupCount; __u8 Reserved3; __le16 SubCommand; /* one setup word */ __le16 ByteCount; __u8 Pad[3]; /* Win2K has sent 0x0F01 (max resp length perhaps?) followed by one byte pad - doesn't seem to matter though */ __le16 MaxReferralLevel; char RequestFileName[1];} TRANSACTION2_GET_DFS_REFER_REQ;typedef struct dfs_referral_level_3 { __le16 VersionNumber; __le16 ReferralSize; __le16 ServerType; /* 0x0001 = CIFS server */ __le16 ReferralFlags; /* or proximity - not clear which since always set to zero - SNIA spec says 0x01 means strip off PathConsumed chars before submitting RequestFileName to remote node */ __le16 TimeToLive; __le16 Proximity; __le16 DfsPathOffset; __le16 DfsAlternatePathOffset; __le16 NetworkAddressOffset;} REFERRAL3;typedef struct smb_com_transaction_get_dfs_refer_rsp { struct smb_hdr hdr; /* wct = 10 */ __le16 TotalParameterCount; __le16 TotalDataCount; __u16 Reserved; __le16 ParameterCount; __le16 ParameterOffset; __le16 ParameterDisplacement; __le16 DataCount; __le16 DataOffset; __le16 DataDisplacement; __u8 SetupCount; __u8 Reserved1; /* zero setup words following */ __u16 ByteCount; __u8 Pad; __le16 PathConsumed; __le16 NumberOfReferrals; __le16 DFSFlags; __u16 Pad2; REFERRAL3 referrals[1]; /* array of level 3 dfs_referral structures */ /* followed by the strings pointed to by the referral structures */} TRANSACTION2_GET_DFS_REFER_RSP;/* DFS Flags */#define DFSREF_REFERRAL_SERVER 0x0001#define DFSREF_STORAGE_SERVER 0x0002/* IOCTL information *//* List of ioctl function codes that look to be of interest to remote clients like this. *//* Need to do some experimentation to make sure they all work remotely. *//* Some of the following such as the encryption/compression ones would be *//* invoked from tools via a specialized hook into the VFS rather than via the *//* standard vfs entry points */#define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000#define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004#define FSCTL_REQUEST_BATCH_OPLOCK 0x00090008#define FSCTL_LOCK_VOLUME 0x00090018#define FSCTL_UNLOCK_VOLUME 0x0009001C#define FSCTL_GET_COMPRESSION 0x0009003C#define FSCTL_SET_COMPRESSION 0x0009C040#define FSCTL_REQUEST_FILTER_OPLOCK 0x0009008C#define FSCTL_FILESYS_GET_STATISTICS 0x00090090#define FSCTL_SET_REPARSE_POINT 0x000900A4#define FSCTL_GET_REPARSE_POINT 0x000900A8#define FSCTL_DELETE_REPARSE_POINT 0x000900AC#define FSCTL_SET_SPARSE 0x000900C4#define FSCTL_SET_ZERO_DATA 0x000900C8#define FSCTL_SET_ENCRYPTION 0x000900D7#define FSCTL_ENCRYPTION_FSCTL_IO 0x000900DB#define FSCTL_WRITE_RAW_ENCRYPTED 0x000900DF#define FSCTL_READ_RAW_ENCRYPTED 0x000900E3#define FSCTL_SIS_COPYFILE 0x00090100#define FSCTL_SIS_LINK_FILES 0x0009C104#define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003#define IO_REPARSE_TAG_HSM 0xC0000004#define IO_REPARSE_TAG_SIS 0x80000007/* ************************************************************************ * All structs for everything above the SMB PDUs themselves * (such as the T2 level specific data) go here ************************************************************************ *//* * Information on a server */struct serverInfo { char name[16]; unsigned char versionMajor; unsigned char versionMinor; unsigned long type; unsigned int commentOffset;};/* * The following structure is the format of the data returned on a NetShareEnum * with level "90" (x5A) */struct shareInfo { char shareName[13]; char pad; unsigned short type; unsigned int commentOffset;};struct aliasInfo { char aliasName[9]; char pad; unsigned int commentOffset; unsigned char type[2];};struct aliasInfo92 { int aliasNameOffset; int serverNameOffset; int shareNameOffset;};typedef struct { __le64 TotalAllocationUnits; __le64 FreeAllocationUnits; __le32 SectorsPerAllocationUnit; __le32 BytesPerSector;} FILE_SYSTEM_INFO; /* size info, level 0x103 */typedef struct { __le16 MajorVersionNumber; __le16 MinorVersionNumber; __le64 Capability;} FILE_SYSTEM_UNIX_INFO; /* Unix extensions info, level 0x200 *//* Linux/Unix extensions capability flags */#define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */#define CIFS_UNIX_POSIX_ACL_CAP 0x00000002/* DeviceType Flags */#define FILE_DEVICE_CD_ROM 0x00000002#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003#define FILE_DEVICE_DFS 0x00000006#define FILE_DEVICE_DISK 0x00000007#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008#define FILE_DEVICE_FILE_SYSTEM 0x00000009#define FILE_DEVICE_NAMED_PIPE 0x00000011#define FILE_DEVICE_NETWORK 0x00000012#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014#define FILE_DEVICE_NULL 0x00000015#define FILE_DEVICE_PARALLEL_PORT 0x00000016#define FILE_DEVICE_PRINTER 0x00000018#define FILE_DEVICE_SERIAL_PORT 0x0000001b#define FILE_DEVICE_STREAMS 0x0000001e#define FILE_DEVICE_TAPE 0x0000001f#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020#define FILE_DEVICE_VIRTUAL_DISK 0x00000024#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028typedef struct { __le32 DeviceType; __le32 DeviceCharacteristics;} FILE_SYSTEM_DEVICE_INFO; /* device info, level 0x104 */typedef struct { __le32 Attributes; __le32 MaxPathNameComponentLength; __le32 FileSystemNameLen; char FileSystemName[52]; /* do not really need to save this - so potentially get only subset of name */} FILE_SYSTEM_ATTRIBUTE_INFO;typedef struct { /* data block encoding of response to level 263 QPathInfo */ __le64 CreationTime; __le64 LastAccessTime; __le64 LastWriteTime; __le64 ChangeTime; __le32 Attributes; __u32 Pad1; __le64 AllocationSize; __le64 EndOfFile; /* size ie offset to first free byte in file */ __le32 NumberOfLinks; /* hard links */ __u8 DeletePending; __u8 Directory; __u16 Pad2; __u64 IndexNumber; __le32 EASize; __le32 AccessFlags; __u64 IndexNumber1; __le64 CurrentByteOffset; __le32 Mode; __le32 AlignmentRequirement; __le32 FileNameLength; char FileName[1];} FILE_ALL_INFO; /* level 263 QPathInfo */typedef struct { __le64 EndOfFile; __le64 NumOfBytes; __le64 LastStatusChange; /*SNIA spec says DCE time for the three time fields */ __le64 LastAccessTime; __le64 LastModificationTime; __le64 Uid; __le64 Gid; __le32 Type; __le64 DevMajor; __le64 DevMinor; __u64 UniqueId; __le64 Permissions; __le64 Nlinks;} FILE_UNIX_BASIC_INFO; /* level 512 QPathInfo */typedef struct { char LinkDest[1];} FILE_UNIX_LINK_INFO; /* level 513 QPathInfo */typedef struct { __u16 CreationDate; __u16 CreationTime; __u16 LastAccessDate; __u16 LastAccessTime; __u16 LastWriteDate; __u16 LastWriteTime; __u32 DataSize; /* File Size (EOF) */ __u32 AllocationSize; __u16 Attributes; /* verify not u32 */ __u32 EASize;} FILE_INFO_STANDARD; /* level 1 SetPath/FileInfo *//* defines for enumerating possible values of the Unix type field below */#define UNIX_FILE 0#define UNIX_DIR 1#define UNIX_SYMLINK 2#define UNIX_CHARDEV 3#define UNIX_BLOCKDEV 4#define UNIX_FIFO 5#define UNIX_SOCKET 6typedef struct { __le32 NextEntryOffset; __le32 ResumeKey; __le64 EndOfFile; __le64 NumOfBytes; __le64 LastStatusChange; /*SNIA spec says DCE time for the three time fields */ __le64 LastAccessTime; __le64 LastModificationTime; __le64 Uid; __le64 Gid; __le32 Type; __le64 DevMajor; __le64 DevMinor; __le64 UniqueId; __le64 Permissions; __le64 Nlinks; char FileName[1];} FILE_UNIX_INFO;typedef struct { __le64 CreationTime; __le64 LastAccessTime; __le64 LastWriteTime; __le64 ChangeTime; __le32 Attributes; __u32 Pad;} FILE_BASIC_INFO; /* size info, level 0x101 */struct file_allocation_info { __le64 AllocationSize;}; /* size info, level 0x103 */struct file_end_of_file_info { __le64 FileSize; /* offset to end of file */}; /* size info, level 0x104 */typedef struct { __le32 NextEntryOffset; __u32 FileIndex; __le64 CreationTime; __le64 LastAccessTime; __le64 LastWriteTime; __le64 ChangeTime; __le64 EndOfFile; __le64 AllocationSize; __le32 ExtFileAttributes; __le32 FileNameLength; char FileName[1];} FILE_DIRECTORY_INFO; /* level 257 FF response data area */struct gea { unsigned char name_len; char name[1];};struct gealist { unsigned long list_len; struct gea list[1];};struct fea { unsigned char EA_flags; __u8 name_len; __le16 value_len; char name[1]; /* optionally followed by value */};/* flags for _FEA.fEA */#define FEA_NEEDEA 0x80 /* need EA bit */struct fealist { __le32 list_len; struct fea list[1];};/* used to hold an arbitrary blob of data */struct data_blob { __u8 *data; size_t length; void (*free) (struct data_blob * data_blob);};#ifdef CONFIG_CIFS_POSIX/* For better POSIX semantics from Linux client, (even better than the existing CIFS Unix Extensions) we need updated PDUs for: 1) PosixCreateX - to set and return the mode, inode#, device info and perhaps add a CreateDevice - to create Pipes and other special .inodes Also note POSIX open flags 2) Close - to return the last write time to do cache across close more safely 3) PosixQFSInfo - to return statfs info 4) FindFirst return unique inode number - what about resume key, two forms short (matches readdir) and full (enough info to cache inodes) 5) Mkdir - set mode And under consideration: 6) FindClose2 (return nanosecond timestamp ??) 7) Use nanosecond timestamps throughout all time fields if corresponding attribute flag is set 8) sendfile - handle based copy 9) Direct i/o 10) "POSIX ACL" support 11) Misc fcntls? what about fixing 64 bit alignment There are also various legacy SMB/CIFS requests used as is From existing Lanman and NTLM dialects: -------------------------------------- NEGOTIATE SESSION_SETUP_ANDX (BB which?) TREE_CONNECT_ANDX (BB which wct?) TREE_DISCONNECT (BB add volume timestamp on response) LOGOFF_ANDX DELETE (note delete open file behavior) DELETE_DIRECTORY READ_AND_X WRITE_AND_X LOCKING_AND_X (note posix lock semantics) RENAME (note rename across dirs and open file rename posix behaviors) NT_RENAME (for hardlinks) Is this good enough for all features? FIND_CLOSE2 TRANSACTION2 (18 cases) SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2 (BB verify that never need to set allocation size) SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via Unix ext?) COPY (note support for copy across directories) - FUTURE, OPTIONAL setting/getting OS/2 EAs - FUTURE (BB can this handle setting Linux xattrs perfectly) - OPTIONAL dnotify - FUTURE, OPTIONAL quota - FUTURE, OPTIONAL Note that various requests implemented for NT interop such as NT_TRANSACT (IOCTL) QueryReparseInfo are unneeded to servers compliant with the CIFS POSIX extensions From CIFS Unix Extensions: ------------------------- T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2) T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK) T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC) - BB check for missing inode fields Actually need QUERY_FILE_UNIX_INFO since has inode num BB what about a) blksize/blkbits/blocks b) i_version c) i_rdev d) notify mask? e) generation f) size_seqcount T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX TRANS2_GET_DFS_REFERRAL - OPTIONAL but recommended T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL *//* xsymlink is a symlink format that can be used to save symlink info in a regular file when mounted to operating systems that do not support the cifs Unix extensions or EAs (for xattr based symlinks). For such a file to be recognized as containing symlink data: 1) file size must be 1067, 2) signature must begin file data, 3) length field must be set to ASCII representation of a number which is less than or equal to 1024, 4) md5 must match that of the path data */struct xsymlink { /* 1067 bytes */ char signature[4]; /* XSym */ /* not null terminated */ char cr0; /* \n *//* ASCII representation of length (4 bytes decimal) terminated by \n not null */ char length[4]; char cr1; /* \n *//* md5 of valid subset of path ie path[0] through path[length-1] */ __u8 md5[32]; char cr2; /* \n *//* if room left, then end with \n then 0x20s by convention but not required */ char path[1024]; };#endif #pragma pack() /* resume default structure packing */#endif /* _CIFSPDU_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -