diff mbox series

[SMB311,PATCHES] parse posix create context in order to handle getattr

Message ID CAH2r5mvW_cpUhg-JA7pFd=rcYSSvT43rT2z9RGbkUpdR1fiLsg@mail.gmail.com (mailing list archive)
State New, archived
Headers show
Series [SMB311,PATCHES] parse posix create context in order to handle getattr | expand

Commit Message

Steve French Feb. 28, 2020, 7:53 a.m. UTC
First 1/2 of changes needed to support SMB3.1.1 POSIX Extensions
support for getattr (stat) - the main remaining item left for the
Linux kernel client support of the SMB3.1.1 POSIX Extensions.

The patch from Aurelien allows SMB2_open() callers to pass down a
POSIX data buffer that will trigger requesting POSIX create context
and parsing the response into the provided buffer, and the second
patch fixes some minor problems with the first patch.

Comments

Aurélien Aptel Feb. 28, 2020, 11:39 a.m. UTC | #1
Steve French <smfrench@gmail.com> writes:
> First 1/2 of changes needed to support SMB3.1.1 POSIX Extensions
> support for getattr (stat) - the main remaining item left for the
> Linux kernel client support of the SMB3.1.1 POSIX Extensions.
>
> The patch from Aurelien allows SMB2_open() callers to pass down a
> POSIX data buffer that will trigger requesting POSIX create context
> and parsing the response into the provided buffer, and the second
> patch fixes some minor problems with the first patch.

I know we want progress on this but this patch is part of a WIP series I
shared with Steve not meant to be sent here yet (cf all XXX which I use
in dev/debug). Thanks for spotting the errors and typos but please don't
merge this yet. I will send an updated version if you really want to
have it.

Cheers,
diff mbox series

Patch

From 085ff186f2a9257dff66844ba00fa2b1454bad4d Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Wed, 26 Feb 2020 16:55:40 -0600
Subject: [PATCH 2/2] smb3: update the information returned on posix
 create/open

Fix a couple minor problems with parsing the create context in
the previous patch (length incorrect in one, and field
name incorrect in one othe replace).  And account for sids
in the create posix response.

Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/smb2pdu.c |  4 ++--
 fs/cifs/smb2pdu.h | 12 +++++++-----
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index cfcbe6df2063..244606103d9f 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -1955,7 +1955,7 @@  parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info,
 		 struct create_posix_rsp *posix)
 {
 	int sid_len;
-	u8 *beg = (u8 *)cc + le32_to_cpu(cc->DataOffset);
+	u8 *beg = (u8 *)cc + le16_to_cpu(cc->DataOffset);
 	u8 *end = beg + le32_to_cpu(cc->DataLength);
 	u8 *sid;
 
@@ -1963,7 +1963,7 @@  parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info,
 
 	posix->nlink = le32_to_cpu(*(__le32 *)(beg + 0));
 	posix->reparse_tag = le32_to_cpu(*(__le32 *)(beg + 4));
-	posix->reparse_tag = le32_to_cpu(*(__le32 *)(beg + 8));
+	posix->mode = le32_to_cpu(*(__le32 *)(beg + 8));
 
 	sid = beg + 12;
 	sid_len = posix_info_sid_size(sid, end);
diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h
index 700311978523..4653fa89e7ad 100644
--- a/fs/cifs/smb2pdu.h
+++ b/fs/cifs/smb2pdu.h
@@ -1603,16 +1603,18 @@  struct smb2_file_id_information {
 
 extern char smb2_padding[7];
 
-/* equivalent of the contents of SMB3.1.1 POSIX open context response */
+/* unpacked equivalent of contents of SMB3.1.1 POSIX open context response */
 struct create_posix_rsp {
-	__le32 nlink;
-	__le32 reparse_tag;
-	__le32 mode;
+	u32 nlink;
+	u32 reparse_tag;
+	u32 mode;
 	/*
 	 * var sized owner SID
 	 * var sized group SID
 	 */
-} __packed;
+	struct cifs_sid owner;
+	struct cifs_sid group;
+};
 
 /*
  * SMB2-only POSIX info level
-- 
2.20.1