Thoughts on dos cr/lf conversion

Andrew Tridgell tridge at samba.anu.edu.au
Wed Nov 11 07:19:42 GMT 1998


> Here is a first pass at a design for a cr/lf conversion vfs module.
> Comments appreciated!  I'm sure other people have thought longer about
> this problem.

yep, others have thought about it, and there is even a version of
Samba-1.9.02 around that has it fully implemented! I never integrated
the patches into the main tree as I thought they had too large an
impact on the code and I didn't really like the method it used to
distinguish between text/non-text files. It used a link _A in \ and
any files below that link were a mirror of the whole tree but with
cr/lf conversion ... or something like that, it's been a while since I
looked at it, as it was was done in 1995. 

I've put a copy of that implementation in ~samba-bugs/samba-1.9.02aTI/
on samba.anu.edu.au. The work was done by Dan Lydick at Texas
Instruments (lydick at cvpsun01.csc.ti.com).

your VFS work now gives us an opportunity to do this really cleanly.

I think your algorithms sound OK but I would suggest that you:

1) keep it _really_ simple for a first implementation and just make
sure it works 100% accurately. Speed is no good if you have any chance
of losing data.

2) the main thing that will impact performance is the cacheing of
stat() calls. I suggest you store in shared memory an array of:

struct crlf_cache {
       time_t modtime;
       dev_t device;
       ino_t inode;
       size_t original_size;
       size_t converted_size;
};

then if this bit of memory is shared between all smbd processes you
will avoid most of the work. I suggest shared memory because that
allows cdroms and read-only network drives to be exported with cr/lf
enabled.

for smb.conf options to control this you might think about getting
really fancy and allowing loadable modules to register new smb.conf
parameters. To do that you'll need to use something like this:

[global]
	load modules = /opt/samba/lib/crlf.so /opt/samba/lib/tape.so

then in a share you would have:

[foo]
	enable module = crlf.so

the main point is that the module will have to be loaded in the global
section to avoid smb.conf processing problems. You'll also need a
mod_init() function in each module that can do global module
initialisation such as calling lp_register_parameter().

is that too ambitious?



More information about the samba-technical mailing list