mount.cifs: fix several problems when mounting subdirectories of shares (try 2)
authorJeff Layton <jlayton@redhat.com>
Mon, 10 Mar 2008 19:54:36 +0000 (15:54 -0400)
committerSimo Sorce <idra@samba.org>
Mon, 31 Mar 2008 20:05:20 +0000 (16:05 -0400)
commit161db3e8e82857987382d204b2113abbbb1fcf4f
tree5afbd149e344b7b1815ecbc6e7a559b7fae35c2e
parent8940fd09a67c79d73712e2dd4b197fffd613dd04
mount.cifs: fix several problems when mounting subdirectories of shares (try 2)

This patch is the second patch to attempt to fix up some of the problems
with mounting subdirectories of shares. The earlier patch didn't handle
this correctly when POSIX extensions were enabled. This one does.

This is a bit of a confusing area since the different components of
a service string have different rules:

1) hostname: no '/' (slash) or '\' (backslash) is allowed to be
     embedded within the string

2) sharename: same rules as hostname

3) prefixpath: '\' *is* allowed to be embedded in a path component,
       iff POSIX extensions are enabled. Otherwise, neither
       character is allowed.

The idea here is to allow either character to act as a delimiter when we
know that the character can't be anything but a delimiter (namely
everywhere up to the start of the prefixpath). The patch will convert
any '\' unconditionally to '/' in the UNC portion of the string.

However, inside the prefixpath, we can't make assumptions about what
constitutes a delimiter because POSIX allows for embedded '\'
characters. So there we don't attempt to do any conversion, and pass the
prefixpath to the kernel as is. Once the kernel determines whether POSIX
extensions are enabled, it can then convert the path if needed and it's
able to do so. A patch to handle this has already been committed to the
cifs-2.6 git tree.

This patch also fixes an annoyance. When you mount a subdir of a share,
mount.cifs munges the device string so that you can't tell what the
prefixpath is. So if I mount:

//server/share/p1/p2/p3

..then /proc/mounts and mtab will show only:

//server/share

Finally, it also tries to apply some consistent rules to the uppercasing
of strings.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
(This used to be commit e03d1dfdb80333c071b600245eb749ef5664aa22)
source3/client/mount.cifs.c