Bug 5925 - Cannot mount subdirectory with mount.cifs
Summary: Cannot mount subdirectory with mount.cifs
Status: RESOLVED FIXED
Alias: None
Product: CifsVFS
Classification: Unclassified
Component: user space tools (show other bugs)
Version: 2.6
Hardware: x86 Linux
: P3 normal
Target Milestone: ---
Assignee: Steve French
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-28 08:59 UTC by Alex Luch
Modified: 2008-12-05 13:23 UTC (History)
0 users

See Also:


Attachments
fix to cifs.ko against 2.6.28 (rc6) but should work on any reasonably recent kernel (3.65 KB, patch)
2008-12-05 13:22 UTC, Steve French
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Luch 2008-11-28 08:59:09 UTC
I saw a mention that this issue has been fixed in CIFS implementation, however I probably misunderstood since it is not working correctly:

When trying to mount subdirectory of a share: //server/dir1/dir2 mount.cifs strips down unc to //server\dir1. 

I have a situation where my Windows home directory is dir2 as above, however I don't have permissions to mount dir1 directly, I can only mount dir2.
So using "mount.cifs //server/dir1/dir2 -o prefixpath=dir1" will not work, resulting in error 13 permission denied since it still tries to mount //server\dir1.

It would be good to have an option to mount a subdirectory (dir2 in this case) directly, rather then mounting dir1 only. This works fine on Windows, where I can browse and then map that dir2 without any issues. I can also browse that directory with smbclient, but cannot mount it using mount.cifs.

I tested this on Ubuntu 8.10 with both default smbfs 3.2.3-1ubuntu3.3 and compiled 3.3.0rc1.
Comment 1 Steve French 2008-12-04 10:48:42 UTC
Looks like you are right that we are always passing an empty path when we get the root inode of the mount (the root path should be the prefixpath, if present, not null).  So although using a prefixpath works for most cases, with current cifs.ko cod you have to have (at least) permission enough to do SMB QuerPathInfo in cifs_get_inode_info.

/* gets root inode */
struct inode *cifs_iget(struct super_block *sb, unsigned long ino)
{
        int xid;
        struct cifs_sb_info *cifs_sb;
        struct inode *inode;
        long rc;

        inode = iget_locked(sb, ino);
        if (!inode)
                return ERR_PTR(-ENOMEM);
        if (!(inode->i_state & I_NEW))
                return inode;

        cifs_sb = CIFS_SB(inode->i_sb);
        xid = GetXid();

        if (cifs_sb->tcon->unix_ext)
                rc = cifs_get_inode_info_unix(&inode, "", inode->i_sb, xid);
        else
                rc = cifs_get_inode_info(&inode, "", NULL, inode->i_sb, xid,
                                         NULL);
Comment 2 Steve French 2008-12-05 13:22:53 UTC
Created attachment 3783 [details]
fix to cifs.ko against 2.6.28 (rc6) but should work on any reasonably recent kernel

tested and reviewed and checked into cifs-2.6.git tree.  Will push into 2.6.29 mainline kernel when it opens up in a few weeks
Comment 3 Steve French 2008-12-05 13:23:45 UTC
checked into cifs-2.6.git and patch provided