Added support of custom option separator for the cifs filesystem. #1836
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DESCRIPTION OF THE PROBLEM
Some users are accustomed to using shared folders in Windows with a comma in the name, for example: "//server3/Block 3,4".
When they try to migrate to Linux, they cannot mount such paths.
An example of the line generated by "mount.cifs" for the kernel when mounting "//server3/Block 3,4":
"ip=10.0.2.212,unc=\server3\Block 3,4,iocharset=utf8,user=user1,domain=AD"
Accordingly, due to the extra comma, we have an error:
"Sep 7 21:57:18 S1 kernel: [ 795.604821] CIFS: Unknown mount option "4""
DOCUMENTATION
https://www.kernel.org/doc/html/latest/admin-guide/cifs/usage.html
The "sep" parameter is described here to specify a new delimiter instead of a comma.
I quote:
"sep
if first mount option (after the -o), overrides the comma as the separator between the mount parms. e.g.:
-o user=myname,password=mypassword,domain=mydom
could be passed instead with period as the separator by:
-o sep=.user=myname.password=mypassword.domain=mydom
this might be useful when comma is contained within username or password or domain."
RESEARCH WORK
I looked at the "mount.cifs" code. There is no provision for the use of a comma by the user, since the comma is used to form the parameter string to the kernel (man 2 mount). This line can be seen by adding the "--verbose" flag to the mount.
"mount.cifs --help" lists "sep" as a possible option, but does not implement it in the code and does not describe it in "man 8 mount.cifs".
I looked at the "pam-mount" code - the mount options are assembled with a wildcard comma. The result is a text line: "mount -t cifs ...".
The handling of options in the "mount" utility is based on the "libmount" library, which is hardcoded to use only a comma as a delimiter.
I tried to mount "//server3/Block 3,4" with my own program (man 2 mount) by specifying "sep=!" - successfully.
SOLUTION
It would be nice if we add in "mount.cifs", in "mount" utility and in "pam-mount" the ability to set a custom mount option separator. In other words, we need to implement the already documented "sep" option.
For "mount.cifs" I did it in: https://github.com/dmitry-telegin/cifs-utils in branch "custom_option_separator". Commit: dmitry-telegin/cifs-utils@04325b8
For "mount" utility I did it in: https://github.com/dmitry-telegin/util-linux in branch "custom_option_separator". Commit: dmitry-telegin@5e0ecd2
For "pam-mount" I did it in: https://sourceforge.net/u/dmitry-t/pam-mount/ci/master/tree/ in branch "custom_option_separator". Commit: https://sourceforge.net/u/dmitry-t/pam-mount/ci/9860f9234977f1110230482b5d87bdcb8bc6ce03/
I checked the work on the Linux 5.10 kernel.