[Mono-list] silly samba/nt4/cygwin problem

Carl R. Witty cwitty@newtonlabs.com
13 May 2002 11:37:22 -0700

Martin Baulig <martin@gnome.org> writes:

> Daniel Stodden <stodden@in.tum.de> writes:
> > this might be somewhat offtopic for mono-list, but since the nt4 box
> > under my desk is mostly there for running csc -- maybe someone around
> > here can help me out.
> > 
> > bitch is running samba-2.2.3a on linux 2.4.18.
> > ballmer NT4sp6a with cygwin.
> > xemacs on X for coding, secure shell into bash on ballmer for builds.
> > $HOME shared to ballmer via smb.
> > 
> > the strange behavior is this: 
> > 1. save a .cs file on the linux box
> > 2. switch to the NT terminal
> > 3. run csc
> > 4. parse error: ';' missing in line y (or similar).
> > 5. investigate. but no typos at all..
> > 
> > i've originally thought csc has troubles with unix line endings. it has
> > not:
> > 
> > 6. ballmer: "csc x.cs"
> > 7. parser error again.
> > 8. cat x.cs
> > 9. csc x.cs
> > 10. compilation successful. wow.
> > 
> > the share does _never_ really mess up the contents. what it does is
> > producing very small typos like repeating just one or two ascii
> > characters, e.g. a comma or so, leading to small syntax errors.
> > doing a simple 'cat' on that file always seems to fix the problem.
> > 
> > anyone with similar phenomenons or a tip which screw to turn?
> I get the same behavior, but I have no idea what it is.
> Doing a `cat *.cs > /dev/null ; <some command>' helps.

I've seen behavior like this using Samba with "oplocks = True" (which
is the default, I believe).  Basically, Samba serves files in a way
that tells the Windows box that it is allowed to cache pieces; this
works if all modifications are made through Samba, but fails if some
modifications are made directly on the Linux box.  It can happen that
the Windows box will see one sector from an old version of the file
and another sector from a new version; if you changed the file size,
this can manifest as what looks like a few characters added or deleted
at the sector boundary, which will often cause syntax errors.

To disable this Samba behavior (which will reduce performance, but
restore correctness for modifications made from the Linux side), add a

   oplocks = False

to an appropriate place in your smb.conf.  (Either in the [global]
section or in the section for your share.)

Carl Witty