file-set-size.c revision 3ed2d0f6b5e67e2663d44489d9da3176823789a8
/* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_POSIX_FALLOCATE
#endif
#include "lib.h"
#include "file-set-size.h"
#include <unistd.h>
#include <fcntl.h>
{
#ifdef HAVE_POSIX_FALLOCATE
static bool posix_fallocate_supported = TRUE;
#endif
char block[IO_BLOCK_SIZE];
i_error("fstat() failed: %m");
return -1;
}
i_error("ftruncate() failed: %m");
return -1;
}
return 0;
}
return 0;
#ifdef HAVE_POSIX_FALLOCATE
if (posix_fallocate_supported) {
int err;
if (err == 0)
return 0;
i_error("posix_fallocate() failed: %m");
return -1;
}
/* Not supported by kernel, fallback to writing. */
}
#endif
/* start growing the file */
offset);
if (ret < 0) {
i_error("pwrite() failed: %m");
return -1;
}
}
return 0;
}