
From: Haroldo Gamal <haroldo.gamal@infolink.com.br>

The patches attached here fixes the BUG #3758 - "Broken symlinks on smbfs
with 2.6.10-rc[12]".  There are two patches, one to be applied over version
2.6.9 and the other over 2.6.10-rc2.

The old utilities (and the old driver) uses uid=0, gid=0, dmask=0 and
fmask=0 to flag the lack of this parameters on the mount command line. 
When the user do not specify the uid, gid, fmask or dmask, the current
driver will assign gid=root, gid=root, dmask=755, fmask=755.  This behavior
is similar to the old 2.x samba versions.

To make the driver see the permissions and ownership assigned on the
server, "smbmount" and "smbmnt" utilities must be patched.  The patches is
already available on the attached patches at Bug #3330 or Samba Bug #999.

Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/fs/smbfs/inode.c |    8 ++++----
 25-akpm/fs/smbfs/proc.c  |    5 +++--
 2 files changed, 7 insertions(+), 6 deletions(-)

diff -puN fs/smbfs/inode.c~smbfs-bug-3758-broken-symlinks-on-smbfs-with fs/smbfs/inode.c
--- 25/fs/smbfs/inode.c~smbfs-bug-3758-broken-symlinks-on-smbfs-with	2004-11-17 22:24:40.013378688 -0800
+++ 25-akpm/fs/smbfs/inode.c	2004-11-17 22:24:40.019377776 -0800
@@ -574,10 +574,10 @@ int smb_fill_super(struct super_block *s
 		mnt->flags = (oldmnt->file_mode >> 9) | SMB_MOUNT_UID |
 			SMB_MOUNT_GID | SMB_MOUNT_FMODE | SMB_MOUNT_DMODE;
 	} else {
-		mnt->file_mode = mnt->dir_mode = S_IRWXU | S_IRGRP | S_IXGRP |
-						S_IROTH | S_IXOTH | S_IFREG;
-		mnt->dir_mode = mnt->dir_mode = S_IRWXU | S_IRGRP | S_IXGRP |
-						S_IROTH | S_IXOTH | S_IFDIR;
+		mnt->file_mode = S_IRWXU | S_IRGRP | S_IXGRP |
+				S_IROTH | S_IXOTH | S_IFREG;
+		mnt->dir_mode = S_IRWXU | S_IRGRP | S_IXGRP |
+				S_IROTH | S_IXOTH | S_IFDIR;
 		if (parse_options(mnt, raw_data))
 			goto out_bad_option;
 	}
diff -puN fs/smbfs/proc.c~smbfs-bug-3758-broken-symlinks-on-smbfs-with fs/smbfs/proc.c
--- 25/fs/smbfs/proc.c~smbfs-bug-3758-broken-symlinks-on-smbfs-with	2004-11-17 22:24:40.015378384 -0800
+++ 25-akpm/fs/smbfs/proc.c	2004-11-17 22:24:40.022377320 -0800
@@ -2138,10 +2138,11 @@ void smb_decode_unix_basic(struct smb_fa
 
 	if ( (server->mnt->flags & SMB_MOUNT_DMODE) &&
 	     (S_ISDIR(fattr->f_mode)) )
-		fattr->f_mode = (server->mnt->dir_mode & (S_IRWXU | S_IRWXG | S_IRWXO)) | S_IFDIR;
+		fattr->f_mode = (server->mnt->dir_mode & S_IRWXUGO) | S_IFDIR;
 	else if ( (server->mnt->flags & SMB_MOUNT_FMODE) &&
 	          !(S_ISDIR(fattr->f_mode)) )
-		fattr->f_mode = (server->mnt->file_mode & (S_IRWXU | S_IRWXG | S_IRWXO)) | S_IFREG;
+		fattr->f_mode = (server->mnt->file_mode & S_IRWXUGO) |
+				(fattr->f_mode & S_IFMT);
 
 }
 
_
