Skip to contentSkip to conversation

cifs: Add support of Alternate Data Streams

PATCH Superseded [email protected] 2 participants 3 messages Sep 16, 2012 2 messages not in the archive

Subsystems (2)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cifs: Add support of Alternate Data Streams

From: Shirish Pargaonkar <[email protected]>

Add support of Alternate Data Streams (ads).

The generic access flags that cifs client currently employs are sufficient for alternate data streams as well (MS-CIFS 2.2.4.64.1).

The ads files have a : in the name, so that is used to differentiate between a regular file and its alternate data streams as they have the same file id.
This scheme applies to non-posix compliant servers such as Windows only.

One operation that does not work is Rename (0x7).

---
 fs/cifs/inode.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
fs/cifs/inode.c +9 -0
index cb79c7e..a28950a 100644
@@ -709,10 +709,15 @@ cifs_get_inode_info(struct inode **inode, const char *full_path,
 			cFYI(1, "CIFSCheckMFSymlink: %d", tmprc);
 	}
 
+	if (strstr(full_path, ":"))
+		fattr.cf_flags |= S_PRIVATE;
+
 	if (!*inode) {
 		*inode = cifs_iget(sb, &fattr);
 		if (!*inode)
 			rc = -ENOMEM;
+		else
+			(*inode)->i_flags |= fattr.cf_flags;
 	} else {
 		cifs_fattr_to_inode(*inode, &fattr);
 	}
@@ -744,6 +749,10 @@ cifs_find_inode(struct inode *inode, void *opaque)
 	if ((inode->i_mode & S_IFMT) != (fattr->cf_mode & S_IFMT))
 		return 0;
 
+	/* don't match inode with different flags */
+	if ((inode->i_flags & S_PRIVATE) != (fattr->cf_flags & S_PRIVATE))
+		return 0;
+
 	/* if it's not a directory or has no dentries, then flag it */
 	if (S_ISDIR(inode->i_mode) && !hlist_empty(&inode->i_dentry))
 		fattr->cf_flags |= CIFS_FATTR_INO_COLLISION;
Signature · 1 line
1.6.0.2

A message that is not in the archive (sent off-list or not yet received): 1347764747-16822-1-git-send-email-shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 26 lines · On Sat, 15 Sep 2012 22:05:47 -0500 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Add support of Alternate Data Streams (ads).

The generic access flags that cifs client currently employs are sufficient for alternate data streams as well (MS-CIFS 2.2.4.64.1).

The ads files have a : in the name, so that is used to differentiate between a regular file and its alternate data streams as they have the same file id.
This scheme applies to non-posix compliant servers such as Windows only.

One operation that does not work is Rename (0x7).

---
 fs/cifs/inode.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
fs/cifs/inode.c +0 -0
index cb79c7e..a28950a 100644

fs/cifs/inode.c cifs_get_inode_info(struct inode **inode, const char *full_path, · line 714

Quoted 6 lines
fs/cifs/inode.c +3 -0
@@ -709,10 +709,15 @@ cifs_get_inode_info(struct inode **inode, const char *full_path,
 			cFYI(1, "CIFSCheckMFSymlink: %d", tmprc);
 	}
 
+	if (strstr(full_path, ":"))
+		fattr.cf_flags |= S_PRIVATE;
+

While S_PRIVATE doesn't conflict with any of the other cf_flag values currently, I think it would be best to define a new CIFS_FATTR_* flag for this purpose.

fs/cifs/inode.c cifs_get_inode_info(struct inode **inode, const char *full_path, · line 720

Quoted 6 lines
fs/cifs/inode.c +2 -0
 	if (!*inode) {
 		*inode = cifs_iget(sb, &fattr);
 		if (!*inode)
 			rc = -ENOMEM;
+		else
+			(*inode)->i_flags |= fattr.cf_flags;

Uhh no...these flags have nothing to do with the i_flags. This will almost certainly break things.

Quoted 4 lines
fs/cifs/inode.c +0 -0
 	} else {
 		cifs_fattr_to_inode(*inode, &fattr);
 	}

fs/cifs/inode.c cifs_find_inode(struct inode *inode, void *opaque) · line 758

Quoted 10 lines
fs/cifs/inode.c +4 -0
@@ -744,6 +749,10 @@ cifs_find_inode(struct inode *inode, void *opaque)
 	if ((inode->i_mode & S_IFMT) != (fattr->cf_mode & S_IFMT))
 		return 0;
 
+	/* don't match inode with different flags */
+	if ((inode->i_flags & S_PRIVATE) != (fattr->cf_flags & S_PRIVATE))
+		return 0;
+
 	/* if it's not a directory or has no dentries, then flag it */
 	if (S_ISDIR(inode->i_mode) && !hlist_empty(&inode->i_dentry))
 		fattr->cf_flags |= CIFS_FATTR_INO_COLLISION;

I'm still trying to understand the point of this patch. I guess the concern is that these files have the same uniqueid? So this will look like a hardlinked file metadata-wise, but will have different contents?

If so, then isn't it possible that you'd have more than one alternate data stream attached to the file? In that case, it looks like the approach you're using here won't work since you're only designating the alternate data stream with a single flag value.

Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20120916065941.7f6f778d-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org

#4 lore raw
Quoted 69 lines · Jeff Layton
Quoted 26 lines · On Sat, 15 Sep 2012 22:05:47 -0500 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Add support of Alternate Data Streams (ads).

The generic access flags that cifs client currently employs are sufficient for alternate data streams as well (MS-CIFS 2.2.4.64.1).

The ads files have a : in the name, so that is used to differentiate between a regular file and its alternate data streams as they have the same file id.
This scheme applies to non-posix compliant servers such as Windows only.

One operation that does not work is Rename (0x7).

---
 fs/cifs/inode.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
fs/cifs/inode.c +0 -0
index cb79c7e..a28950a 100644

fs/cifs/inode.c cifs_get_inode_info(struct inode **inode, const char *full_path, · line 714

Quoted 6 lines
fs/cifs/inode.c +3 -0
@@ -709,10 +709,15 @@ cifs_get_inode_info(struct inode **inode, const char *full_path,
                      cFYI(1, "CIFSCheckMFSymlink: %d", tmprc);
      }
 
+     if (strstr(full_path, ":"))
+             fattr.cf_flags |= S_PRIVATE;
+

While S_PRIVATE doesn't conflict with any of the other cf_flag values currently, I think it would be best to define a new CIFS_FATTR_* flag for this purpose.

fs/cifs/inode.c cifs_get_inode_info(struct inode **inode, const char *full_path, · line 720

Quoted 6 lines
fs/cifs/inode.c +2 -0
      if (!*inode) {
              *inode = cifs_iget(sb, &fattr);
              if (!*inode)
                      rc = -ENOMEM;
+             else
+                     (*inode)->i_flags |= fattr.cf_flags;

Uhh no...these flags have nothing to do with the i_flags. This will almost certainly break things.

Quoted 4 lines
fs/cifs/inode.c +0 -0
      } else {
              cifs_fattr_to_inode(*inode, &fattr);
      }

fs/cifs/inode.c cifs_find_inode(struct inode *inode, void *opaque) · line 758

Quoted 10 lines
fs/cifs/inode.c +4 -0
@@ -744,6 +749,10 @@ cifs_find_inode(struct inode *inode, void *opaque)
      if ((inode->i_mode & S_IFMT) != (fattr->cf_mode & S_IFMT))
              return 0;
 
+     /* don't match inode with different flags */
+     if ((inode->i_flags & S_PRIVATE) != (fattr->cf_flags & S_PRIVATE))
+             return 0;
+
      /* if it's not a directory or has no dentries, then flag it */
      if (S_ISDIR(inode->i_mode) && !hlist_empty(&inode->i_dentry))
              fattr->cf_flags |= CIFS_FATTR_INO_COLLISION;

I'm still trying to understand the point of this patch. I guess the concern is that these files have the same uniqueid? So this will look like a hardlinked file metadata-wise, but will have different contents?

Quoted 7 lines

If so, then isn't it possible that you'd have more than one alternate data stream attached to the file? In that case, it looks like the approach you're using here won't work since you're only designating the alternate data stream with a single flag value.

--
Jeff Layton <[email protected]>

Jeff, yes, realized that after posting the patch. Will work on fixing that and other comments.

Regards,

Shirish