{"id":652,"date":"2018-04-04T12:04:51","date_gmt":"2018-04-04T10:04:51","guid":{"rendered":"http:\/\/valentijn.sessink.nl\/?p=652"},"modified":"2018-04-26T11:20:07","modified_gmt":"2018-04-26T09:20:07","slug":"samba-mounting-and-trailing-spaces-trailing-dots","status":"publish","type":"post","link":"https:\/\/valentijn.sessink.nl\/?p=652","title":{"rendered":"Samba mounting and trailing spaces \/ trailing dots"},"content":{"rendered":"<p>If you happen to live in a Windows\/Mac\/Linux-environment and you can&#8217;t access certain directories ending in spaces or dots, this post is for you.<!--more--> It took me a while to find out what was wrong, when I couldn&#8217;t access a couple of directories. I had mounted a Windows Server share on a Linux host. The directories I could not access, had been made on an Apple OSX system and ended in a space or a dot.<\/p>\n<p>Fast forward a dozen of internet searches and the answer lies in a rather obscure mounting option for mount.cifs: <em>mapchars<\/em>.<\/p>\n<p>The mount.cifs manpage doesn&#8217;t explain it all too well, saying:<\/p>\n<pre>Translate six of the seven reserved characters (not backslash, but\r\nincluding the colon, question mark, pipe, asterik, greater than and\r\nless than characters) to the remap range (above 0xF000), which also\r\nallows the CIFS client to recognize files created with such\r\ncharacters by Windows\u00b4s POSIX emulation. This can also be useful\r\nwhen mounting to most versions of Samba (which also forbids\r\ncreating and opening files whose names contain any of these seven\r\ncharacters). This has no effect if the server does not support\r\nUnicode on the wire. Please note that the files created with\r\nmapchars mount option may not be accessible if the share is mounted\r\nwithout that option.<\/pre>\n<p>Uh, what is an <em>asterik<\/em> exactly? Anyway, there is a bug report from 2015 that shines at least some light on the problem: <a href=\"https:\/\/bugzilla.samba.org\/show_bug.cgi?id=11206\">https:\/\/bugzilla.samba.org\/show_bug.cgi?id=11206<\/a>:<span id=\"summary_alias_container\"><span id=\"short_desc_nonedit_display\">&#8220;mapchars&#8221; not handling trailing period and trailing space.<\/span><\/span><\/p>\n<p>So that is what happens: Macintosh translates a space (0x20 character encoding) to 0xF028, but <em>only if occurring as the last character of the name<\/em>. Idem for period: 0x2E to 0xF029. Using the &#8220;mapchars&#8221; option when mounting will have Linux use the same sort of translation.<\/p>\n<p>So if your current Samba mount under Linux does:<\/p>\n<pre> mount -t cifs -o iocharset=utf8,credentials=\/etc\/smbcredentials '\\\\SERVER\\Share' \/mnt\/<\/pre>\n<p>You may want to change that to<\/p>\n<pre>mount -t cifs -o iocharset=utf8,credentials=\/etc\/smbcredentials,mapchars '\\\\SERVER\\Share' \/mnt\/<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you happen to live in a Windows\/Mac\/Linux-environment and you can&#8217;t access certain directories ending in spaces or dots, this post is for you.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[123,9,122,124,129,130,127,128,125,126],"class_list":["post-652","post","type-post","status-publish","format-standard","hentry","category-happy-hacking","tag-cifs","tag-linux","tag-samba","tag-smb","tag-trailing-dot","tag-trailing-dots","tag-trailing-period","tag-trailing-periods","tag-trailing-space","tag-trailing-spaces"],"_links":{"self":[{"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=\/wp\/v2\/posts\/652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=652"}],"version-history":[{"count":5,"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=\/wp\/v2\/posts\/652\/revisions"}],"predecessor-version":[{"id":659,"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=\/wp\/v2\/posts\/652\/revisions\/659"}],"wp:attachment":[{"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}