mount.cifs: fix several problems when mounting subdirectories of shares (try 2)
authorJeff Layton <jlayton@redhat.com>
Fri, 12 Sep 2008 20:58:00 +0000 (16:58 -0400)
committerJeff Layton <jlayton@redhat.com>
Fri, 12 Sep 2008 20:58:00 +0000 (16:58 -0400)
commit59d7d3ae58432a07a858fc7e9161e27bb9478c9e
tree3ca38ca727e6b02c9b18e97623356e98290b0b90
parentbe4adc6938b06fc6df79c6c129528fdbb8b0c041
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>
source/client/mount.cifs.c [changed mode: 0755->0644]