Sams Teach Yourself Samba in 24 Hours

ContentsIndex

Hour 7: File Sharing

Previous HourNext Hour

Sections in this Chapter:

 

Filename Handling and Mangling

mangled names

default case

mangle case

preserve case

mangling char

short preserve case

case sensitive

UNIX file names and DOS/Windows file names follow different rules.

UNIX allows almost any character in a filename, except for a directory separator (/) and escape, and distinguishes between uppercase and lowercase characters in names. It also allows filenames to be very long (up to 255 characters long). In addition, pathnames can be very long under UNIX, often up to 1,024 characters.

DOS (6.22 and below), on the other hand, has the 8.3 restriction, where the filename must be no longer than eight characters, and the extension can't be more than three characters long. In addition, DOS case folds characters to uppercase when dealing with file and directory names. DOS also has restrictions on pathname lengths that are considerably smaller than what most UNIX systems allow. Windows for Workgroups follows the DOS restrictions.

Windows 95 (with DOS 95) and Windows NT have removed many of these restrictions, allowing filenames to be longer than 11 characters, as well as allowing both uppercase and lowercase characters in files. However, both Windows 9x and Windows NT have restrictions on filename and pathname lengths that are lower than what UNIX allows. Windows 95 truncates file names to 127 characters. When the total pathname exceeds 255 characters (including the server and share names), it refuses to create any further files or folders. Windows NT has the same restrictions. However, both Windows 95 and Windows NT can deal with longer filenames and pathnames if they already exist on the Samba share (perhaps created under UNIX).

To provide for compatibility with older clients (DOS, Windows for Workgroups, PATHWORKS, and so on), as well as applications that depend on 8.3 filenames Samba has many share-level parameters to control the way in which UNIX filenames and pathnames are reported to clients. It also has parameters that control the way in which case is handled when new files are created.

Samba refers to this as name mangling, and the following general approach is taken:

The following shows an example of name mangling done by a Windows 95 DOS box while listing your first-share after a couple of new files and folders have been added to it. The mangled names are shown in the left column, whereas the full names are shown in the right column.

E:\>dir
Volume in drive E is FIRST-SHARE
Directory of E:\
file-1   txt            69  01-05-99  2:22p file-1.txt
file-2   txt            59  01-05-99  2:23p file-2.txt
NEWFO~YX       <DIR>        01-06-99  2:53p New Folder
File-1   txt            69  01-06-99  5:33p File-1.txt
new-file txt             0  01-06-99  4:58p new-file.txt
ANOTH~9Y       <DIR>        01-06-99  4:58p another-new-folder
A-FIL~BH TXT            24  01-07-99 12:45a a-file-with-a-long-name.txt
         5 file(s)            221 bytes
         2 dir(s)      33,488,896 bytes free
E:\>

By default, Samba 2.0 operates the same way as Windows NT server: it is not case sensitive but case preserving. That is, in opening files, it matches filenames in a way that's not case sensitive, but when new files are created, Samba preserves the case presented by the client.

In most cases the defaults applied by Samba are fine, but you might need to change some of them for specific clients or applications.

The following parameters control how names are handled. As always, the final list of such parameters and the final word on their function rests with the manual pages on smb.conf for the current version of Samba.

mangled names

This service-level parameter controls whether UNIX names that are not DOS compatible should be mapped to DOS-compatible names. By default, Samba mangles names for clients that cannot handle non-DOS names.

The default value for this parameter is yes. That is, by default, non-DOS names are mangled to their DOS-compatible forms.

Setting this parameter to no specifies that Samba should not provide DOS-compatible names for non-DOS-compatible files. If you do this, DOS clients and DOS command prompts simply see the name of the file truncated to the normal DOS rules.

mangle case

This service-level parameter controls whether names are mangled if they have characters not in the default case. If this parameter is set, names such as Mail would be mangled to the default case.

The default value for this parameter is no. This specifies that no mangling of mixed case names be performed.

mangling char

This service level parameter specifies the character that Samba uses as the mangling character when it mangles names. The default is the tilde character (~).

An example of using this parameter is

mangle char = ^

which specifies that Samba should use the caret (^) character rather than the tilde.

case sensitive

This service-level parameter controls whether Samba regards filenames as case sensitive. If set to no, Samba must do a case insensitive filename match for all filenames passed to it by clients.

By default, this parameter is set to no.

default case

This service-level parameter controls the default case of new files and should be used in conjunction with preserve case.

The default case is lowercase.

preserve case

This service-level parameter controls the behavior of Samba when files are created. If set to yes, the case that the client requests is used (including mixed case); otherwise, the case of new files is forced to that specified with the default case.

The default behavior is to preserve case.

short preserve case

This service-level parameter controls the behavior of Samba when files with DOS-compatible (that is, 8.3 and all in uppercase) names are created. If set to yes, such files are created with uppercase names; otherwise, their names are forced to the default case.

This parameter can be used with preserve case = yes to allow long filenames to retain their case, whereas short names are created in lowercase.

The default value of this parameter is yes.

Sams Teach Yourself Samba in 24 Hours

ContentsIndex

Hour 7: File Sharing

Previous HourNext Hour

Sections in this Chapter: