smbmount - file permissions on RH7

Urban Widmark urban at
Thu Mar 8 20:50:02 GMT 2001

On Wed, 7 Mar 2001, Dormition Skete wrote:

> According to their documentation, if I understand it correctly, one should 
> be able to:
> mkdir /mnt/MtAthos-c
> chown -R root.smbusers /mnt/MtAthos-c

smbmount/smbfs ignores this and only relies on the options used when
mounting (uid, gid, fmask, dmask). The docs describe how a unix filesystem
would react, smbfs is not a unix filesystem. This list of options should
do what you want:

However, by itself it will not make the error message go away (see below).

> cd /home/nmetsovo
> cp .Xclients-default /mnt/MtAthos-c/temp/
> cp: preserving permissions for 
> '/mnt/MtAthos-c/temp/.Xclients-default':Operation not permitted
> It goes ahead and changes the uid and gid to however it is set when I mount 
> it, but it gives me this pesky error message, which is killing me...

It doesn't actually change them ...

smbfs does not handle multiple users, all users are the same to the smb
server. You are getting this error because smbfs can't really do anything
useful on a chmod request, so it returns an error.

Linux smbfs client			Windows server

makes a connection as 'guest'		Sees the user 'guest' connecting
user A creates a new file		user guest creates a new file
user B creates a new file		user guest creates a new file

The permissions smbfs show have nothing to do with what is allowed on the
server (not entirely true, a readonly file is listed as readonly, but
they are not per-user). smbfs does not know how to tell the server that a
file should be owned by A, and even if it could it would probably not have
permission on the server to do so.

What exactly is the problem with the error message? Ignoring it seems
like the easiest way to handle it ...

If you can't ignore them, the attached patch should stop the errors. It
does on the 2.4.2 kernel I use (and the 2.2 code is identical). You need
to apply it vs a 2.2.18 kernel source tree, something like this:

% cd $HOME/src
% tar xvIf linux-2.2.18.tar.bz2
% cd linux
% less README
	(and ignore any references to /usr/src)
% patch -p1 < $HOME/smbfs-2.2.18-mode.patch
% make xconfig
	(configure it for your hardware, filesystems you use, etc.
	 There are others who have described this better than me ...
% make dep
% make bzImage modules

And as root:
% make install modules_install
% vi /etc/lilo.conf
	(add something like this, root= should be the same as your 
	 existing entries)
% lilo
	(this updates the boot stuff, I assume you use lilo as that is 
	 the RH7 default.)

You should be able to find more help on how to do this on IRC or on some
(redhat) mailinglist. It is offtopic for this list.

-------------- next part --------------
diff -urN -X exclude linux-2.2.18-orig/fs/smbfs/inode.c linux-2.2.18-smbfs/fs/smbfs/inode.c
--- linux-2.2.18-orig/fs/smbfs/inode.c	Mon Dec 11 01:49:44 2000
+++ linux-2.2.18-smbfs/fs/smbfs/inode.c	Thu Mar  8 21:25:12 2001
@@ -466,6 +466,11 @@
 	unsigned int mask = (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO);
 	int error, changed, refresh = 0;
 	struct smb_fattr fattr;
+	unsigned int valid;
+	/* uid/gid and most mode changes have no meaning on smbfs */
+	valid = attr->ia_valid;
+	attr->ia_valid &= ~(ATTR_UID | ATTR_GID | ATTR_MODE);
 	error = smb_revalidate_inode(dentry);
 	if (error)
@@ -475,6 +480,7 @@
 		goto out;
 	error = -EPERM;
+#if 0
 	if ((attr->ia_valid & ATTR_UID) && (attr->ia_uid != server->mnt->uid))
 		goto out;
@@ -483,6 +489,7 @@
 	if ((attr->ia_valid & ATTR_MODE) && (attr->ia_mode & ~mask))
 		goto out;
 	if ((attr->ia_valid & ATTR_SIZE) != 0)
@@ -538,7 +545,7 @@
 	 * Check for mode changes ... we're extremely limited in
 	 * what can be set for SMB servers: just the read-only bit.
-	if ((attr->ia_valid & ATTR_MODE) != 0)
+	if ((valid & ATTR_MODE) != 0)
 		VERBOSE("%s/%s mode change, old=%x, new=%lx\n",
 			DENTRY_PATH(dentry), fattr.f_mode,attr->ia_mode);
@@ -569,6 +576,8 @@
 	error = 0;
+	attr->ia_valid = valid;
 	if (refresh)
 	return error;

More information about the samba mailing list