Mac OS X,  Unix,  Windows XP

SMB: Name Mangling

Windows 3.x and earlier used what was known as an 8.3 naming scheme, meaning that files had eight places for a name, three for an extension and a dot in the middle.  Name decorating is programatically how Windows 3.x and DOS clients interact with files that have more than 8 characters followed by a dot and then three characters for a file extension.  Those of us who can remember doing mass migrations of data from Windows 3.x to Windows 9x and/or NT will remember well the naming changes that had to happen to maintain backwards compatibility during this trying time.  Especially if we had been using *nix boxen to store our shares. 

And you put SMB: in the title of this post, right Charles?  Well, Samba doesn’t use the term name decorating – instead they use name mangling, which is honestly a bit more accurate a representation.  Essentially, Samba presents file names to clients  and shortens, or mangles them to normalize the data for presentation (for example, using a dir command with a network volume as your working directory.  For example, you have mapped H to a Samba box using the net use command.  You have a document called H:Document.doc: you cd to the h: drive and you see H:DOCUME~1.doc.  Samba uses name mangling for backwards compatibility and provided you don’t have any Windows for Workgroups clients or previous then you should be able to disable it.  However, if you don’t want to disable it due to some random problems you might be having, then you could do some troubleshooting and experiment with the other options provided in relation to name mangling. 

For starters, ‘mangle case’ is a per share setting, which allows mangling but only in mixed case environments (although in modern computing aren’t most environments mixed case…).  You could also increase the number of names allowed to keep on a local mangling stack.  Basically, this stack simply counts up in the event of files that have names too long for the local operating system to handle yet also have the same first six characters in the name.  Because everyone assumed this would happen rarely and because it can slow down processes this item is set to 50 by default but can be updated in your [Global] section using ‘mangling stack’.  It’s also sometimes helpful crossing platforms to look at what happens with the mangling character itself, the ~.  You can swap this out with something different, like ! or maybe for us Mac users something a bit more *nix friendly like an _.  Either way, you aren’t stuck with a ~.  Finally, if you’re really froggy you can create what is known as a mangling map using oddly enough the ‘mangling map’ per-share setting in Samba.  

Name mangling isn’t just an issue you see with samba.  You can physically take a drive and move it and see issues that way.  I’ve also seen them in other systems, such as Netatalk, but not for some time…