Skip to content

Commit c462870

Browse files
Ronnie Sahlbergsmfrench
authored andcommitted
cifs: Move SMB2_Create definitions to the shared area
Move all SMB2_Create definitions (except contexts) into the shared area. Signed-off-by: Ronnie Sahlberg <[email protected]> Reviewed-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent d8d9de5 commit c462870

File tree

5 files changed

+215
-176
lines changed

5 files changed

+215
-176
lines changed

fs/cifs/smb2misc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,8 @@ smb2_handle_cancelled_mid(struct mid_q_entry *mid, struct TCP_Server_Info *serve
832832
rc = __smb2_handle_cancelled_cmd(tcon,
833833
le16_to_cpu(hdr->Command),
834834
le64_to_cpu(hdr->MessageId),
835-
rsp->PersistentFileId,
836-
rsp->VolatileFileId);
835+
le64_to_cpu(rsp->PersistentFileId),
836+
le64_to_cpu(rsp->VolatileFileId));
837837
if (rc)
838838
cifs_put_tcon(tcon);
839839

fs/cifs/smb2ops.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -885,8 +885,8 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
885885
atomic_inc(&tcon->num_remote_opens);
886886

887887
o_rsp = (struct smb2_create_rsp *)rsp_iov[0].iov_base;
888-
oparms.fid->persistent_fid = o_rsp->PersistentFileId;
889-
oparms.fid->volatile_fid = o_rsp->VolatileFileId;
888+
oparms.fid->persistent_fid = le64_to_cpu(o_rsp->PersistentFileId);
889+
oparms.fid->volatile_fid = le64_to_cpu(o_rsp->VolatileFileId);
890890
#ifdef CONFIG_CIFS_DEBUG2
891891
oparms.fid->mid = le64_to_cpu(o_rsp->hdr.MessageId);
892892
#endif /* CIFS_DEBUG2 */
@@ -2395,8 +2395,8 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
23952395
cifs_dbg(FYI, "query_dir_first: open failed rc=%d\n", rc);
23962396
goto qdf_free;
23972397
}
2398-
fid->persistent_fid = op_rsp->PersistentFileId;
2399-
fid->volatile_fid = op_rsp->VolatileFileId;
2398+
fid->persistent_fid = le64_to_cpu(op_rsp->PersistentFileId);
2399+
fid->volatile_fid = le64_to_cpu(op_rsp->VolatileFileId);
24002400

24012401
/* Anything else than ENODATA means a genuine error */
24022402
if (rc && rc != -ENODATA) {

fs/cifs/smb2pdu.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2670,11 +2670,13 @@ int smb311_posix_mkdir(const unsigned int xid, struct inode *inode,
26702670
}
26712671

26722672
rsp = (struct smb2_create_rsp *)rsp_iov.iov_base;
2673-
trace_smb3_posix_mkdir_done(xid, rsp->PersistentFileId, tcon->tid,
2673+
trace_smb3_posix_mkdir_done(xid, le64_to_cpu(rsp->PersistentFileId),
2674+
tcon->tid,
26742675
ses->Suid, CREATE_NOT_FILE,
26752676
FILE_WRITE_ATTRIBUTES);
26762677

2677-
SMB2_close(xid, tcon, rsp->PersistentFileId, rsp->VolatileFileId);
2678+
SMB2_close(xid, tcon, le64_to_cpu(rsp->PersistentFileId),
2679+
le64_to_cpu(rsp->VolatileFileId));
26782680

26792681
/* Eventually save off posix specific response info and timestaps */
26802682

@@ -2941,13 +2943,14 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
29412943
}
29422944
goto creat_exit;
29432945
} else
2944-
trace_smb3_open_done(xid, rsp->PersistentFileId, tcon->tid,
2946+
trace_smb3_open_done(xid, le64_to_cpu(rsp->PersistentFileId),
2947+
tcon->tid,
29452948
ses->Suid, oparms->create_options,
29462949
oparms->desired_access);
29472950

29482951
atomic_inc(&tcon->num_remote_opens);
2949-
oparms->fid->persistent_fid = rsp->PersistentFileId;
2950-
oparms->fid->volatile_fid = rsp->VolatileFileId;
2952+
oparms->fid->persistent_fid = le64_to_cpu(rsp->PersistentFileId);
2953+
oparms->fid->volatile_fid = le64_to_cpu(rsp->VolatileFileId);
29512954
oparms->fid->access = oparms->desired_access;
29522955
#ifdef CONFIG_CIFS_DEBUG2
29532956
oparms->fid->mid = le64_to_cpu(rsp->hdr.MessageId);

fs/cifs/smb2pdu.h

Lines changed: 0 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -115,120 +115,6 @@ struct share_redirect_error_context_rsp {
115115
/* __u8 ResourceName[] */ /* Name of share as counted Unicode string */
116116
} __packed;
117117

118-
/* File Attrubutes */
119-
#define FILE_ATTRIBUTE_READONLY 0x00000001
120-
#define FILE_ATTRIBUTE_HIDDEN 0x00000002
121-
#define FILE_ATTRIBUTE_SYSTEM 0x00000004
122-
#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
123-
#define FILE_ATTRIBUTE_ARCHIVE 0x00000020
124-
#define FILE_ATTRIBUTE_NORMAL 0x00000080
125-
#define FILE_ATTRIBUTE_TEMPORARY 0x00000100
126-
#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
127-
#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
128-
#define FILE_ATTRIBUTE_COMPRESSED 0x00000800
129-
#define FILE_ATTRIBUTE_OFFLINE 0x00001000
130-
#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
131-
#define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
132-
#define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
133-
#define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
134-
135-
/* Oplock levels */
136-
#define SMB2_OPLOCK_LEVEL_NONE 0x00
137-
#define SMB2_OPLOCK_LEVEL_II 0x01
138-
#define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
139-
#define SMB2_OPLOCK_LEVEL_BATCH 0x09
140-
#define SMB2_OPLOCK_LEVEL_LEASE 0xFF
141-
/* Non-spec internal type */
142-
#define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
143-
144-
/* Desired Access Flags */
145-
#define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
146-
#define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
147-
#define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
148-
#define FILE_READ_EA_LE cpu_to_le32(0x00000008)
149-
#define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
150-
#define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
151-
#define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
152-
#define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
153-
#define FILE_DELETE_LE cpu_to_le32(0x00010000)
154-
#define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
155-
#define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
156-
#define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
157-
#define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
158-
#define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
159-
#define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
160-
#define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
161-
#define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
162-
#define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
163-
#define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
164-
165-
/* ShareAccess Flags */
166-
#define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
167-
#define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
168-
#define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
169-
#define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
170-
171-
/* CreateDisposition Flags */
172-
#define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
173-
#define FILE_OPEN_LE cpu_to_le32(0x00000001)
174-
#define FILE_CREATE_LE cpu_to_le32(0x00000002)
175-
#define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
176-
#define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
177-
#define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
178-
179-
/* CreateOptions Flags */
180-
#define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
181-
/* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
182-
#define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
183-
#define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
184-
#define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
185-
#define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
186-
#define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
187-
#define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
188-
#define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
189-
#define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
190-
#define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
191-
#define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
192-
#define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
193-
#define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
194-
#define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
195-
#define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
196-
#define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
197-
#define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
198-
#define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
199-
200-
#define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
201-
| FILE_READ_ATTRIBUTES_LE)
202-
#define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
203-
| FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
204-
#define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
205-
206-
/* Impersonation Levels. See MS-WPO section 9.7 and MSDN-IMPERS */
207-
#define IL_ANONYMOUS cpu_to_le32(0x00000000)
208-
#define IL_IDENTIFICATION cpu_to_le32(0x00000001)
209-
#define IL_IMPERSONATION cpu_to_le32(0x00000002)
210-
#define IL_DELEGATE cpu_to_le32(0x00000003)
211-
212-
/* Create Context Values */
213-
#define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
214-
#define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
215-
#define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
216-
#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
217-
#define SMB2_CREATE_ALLOCATION_SIZE "AISi"
218-
#define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
219-
#define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
220-
#define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
221-
#define SMB2_CREATE_REQUEST_LEASE "RqLs"
222-
#define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q"
223-
#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C"
224-
#define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74
225-
#define SMB2_CREATE_APP_INSTANCE_VERSION 0xB982D0B73B56074FA07B524A8116A010
226-
#define SVHDX_OPEN_DEVICE_CONTEX 0x9CCBCF9E04C1E643980E158DA1F6EC83
227-
#define SMB2_CREATE_TAG_POSIX 0x93AD25509CB411E7B42383DE968BCD7C
228-
229-
/* Flag (SMB3 open response) values */
230-
#define SMB2_CREATE_FLAG_REPARSEPOINT 0x01
231-
232118
/*
233119
* Maximum number of iovs we need for an open/create request.
234120
* [0] : struct smb2_create_req
@@ -242,64 +128,13 @@ struct share_redirect_error_context_rsp {
242128
*/
243129
#define SMB2_CREATE_IOV_SIZE 8
244130

245-
struct smb2_create_req {
246-
struct smb2_hdr hdr;
247-
__le16 StructureSize; /* Must be 57 */
248-
__u8 SecurityFlags;
249-
__u8 RequestedOplockLevel;
250-
__le32 ImpersonationLevel;
251-
__le64 SmbCreateFlags;
252-
__le64 Reserved;
253-
__le32 DesiredAccess;
254-
__le32 FileAttributes;
255-
__le32 ShareAccess;
256-
__le32 CreateDisposition;
257-
__le32 CreateOptions;
258-
__le16 NameOffset;
259-
__le16 NameLength;
260-
__le32 CreateContextsOffset;
261-
__le32 CreateContextsLength;
262-
__u8 Buffer[];
263-
} __packed;
264-
265131
/*
266132
* Maximum size of a SMB2_CREATE response is 64 (smb2 header) +
267133
* 88 (fixed part of create response) + 520 (path) + 208 (contexts) +
268134
* 2 bytes of padding.
269135
*/
270136
#define MAX_SMB2_CREATE_RESPONSE_SIZE 880
271137

272-
struct smb2_create_rsp {
273-
struct smb2_hdr hdr;
274-
__le16 StructureSize; /* Must be 89 */
275-
__u8 OplockLevel;
276-
__u8 Flag; /* 0x01 if reparse point */
277-
__le32 CreateAction;
278-
__le64 CreationTime;
279-
__le64 LastAccessTime;
280-
__le64 LastWriteTime;
281-
__le64 ChangeTime;
282-
__le64 AllocationSize;
283-
__le64 EndofFile;
284-
__le32 FileAttributes;
285-
__le32 Reserved2;
286-
__u64 PersistentFileId; /* opaque endianness */
287-
__u64 VolatileFileId; /* opaque endianness */
288-
__le32 CreateContextsOffset;
289-
__le32 CreateContextsLength;
290-
__u8 Buffer[1];
291-
} __packed;
292-
293-
struct create_context {
294-
__le32 Next;
295-
__le16 NameOffset;
296-
__le16 NameLength;
297-
__le16 Reserved;
298-
__le16 DataOffset;
299-
__le32 DataLength;
300-
__u8 Buffer[];
301-
} __packed;
302-
303138
#define SMB2_LEASE_READ_CACHING_HE 0x01
304139
#define SMB2_LEASE_HANDLE_CACHING_HE 0x02
305140
#define SMB2_LEASE_WRITE_CACHING_HE 0x04

0 commit comments

Comments
 (0)