corrupted tdb files under FreeBSD (Was Re: Why do we truncate
the file and write to it in expand_file in tdb.c)
Jeremy Allison
jra at samba.org
Wed Mar 30 19:15:44 GMT 2005
On Wed, Mar 30, 2005 at 10:56:44AM -0800, Richard Sharpe wrote:
> On Wed, 30 Mar 2005, Richard Sharpe wrote:
>
> > In tdb.c, when we are expanding the tdb file, in expand_file, the first
> > thing we do is:
> >
> > char buf[1024];
> > #if HAVE_FTRUNCATE_EXTEND
> > if (ftruncate(tdb->fd, size+addition) != 0) {
> > TDB_LOG((tdb, 0, "expand_file ftruncate to %d failed
> > (%s)\n",
> > size+addition, strerror(errno)));
> > return -1;
> > }
> > #else
> >
> > Then, below, we write 'B' to every byte of the extended portion.
> >
> > So, why do we bother to ftruncate the file?
>
> So, I was complaining on another list that tdb's use of mmap/munmap on
> FreeBSD lead to corrupted tdb files.
>
> I have now tested the removal of ftruncate on FreeBSD 4.10, and things
> work correctly.
>
> I will soon test on Linux and another version of FreeBSD, and if all works
> OK, I propose removing the seemingly bogus ftruncate (etc) code from
> expand_file in tdb.c.
Well, it's still a bug in FreeBSD that it can't cope with ftruncate
on an mmapped file. I remember this being worked on in Linux.
Jeremy.
More information about the samba-technical
mailing list