Why do we truncate the file and write to it in expand_file in tdb.c

Richard Sharpe rsharpe at richardsharpe.com
Wed Mar 30 18:49:16 GMT 2005


Hi,

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?

Regards
-----
Richard Sharpe, rsharpe[at]richardsharpe.com, rsharpe[at]samba.org,
sharpe[at]ethereal.com, http://www.richardsharpe.com


More information about the samba-technical mailing list