Mosfet Since netbsd implements posix_fallocate:
I think not:
$ fgrep -r fallocate /usr/src/sys/ufs/ /usr/src/sys/miscfs/ /usr/src/sys/fs/
/usr/src/sys/ufs/chfs/chfs_vnops.c: { &vop_fallocate_desc, genfs_eopnotsupp },
/usr/src/sys/ufs/ext2fs/ext2fs_vnops.c: { &vop_fallocate_desc, genfs_eopnotsupp }, /* fallocate */
/usr/src/sys/ufs/ffs/ffs_vnops.c: { &vop_fallocate_desc, genfs_eopnotsupp }, /* fallocate */
/usr/src/sys/ufs/lfs/lfs_vnops.c: { &vop_fallocate_desc, genfs_eopnotsupp }, /* fallocate */
/usr/src/sys/ufs/mfs/mfs_vnops.c: { &vop_fallocate_desc, genfs_eopnotsupp }, /* fallocate */
/usr/src/sys/fs/tmpfs/tmpfs_vnops.c: { &vop_fallocate_desc, genfs_eopnotsupp },
[...]
$
At least, not on UFS or tmpfs
. Not sure about ZFS.
#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int
main(int argc, char* argv[])
{
int fd, rc = EXIT_FAILURE;
off_t len;
char* fn;
if (argc != 3)
errx(rc, "Usage: %s filename len", getprogname());
if ((len = atoi(argv[2])) <= 0)
errx(rc, "%zd: bad length", len);
fn = argv[1];
if ((fd = open(fn, O_WRONLY | O_CREAT, 0600)) == -1)
err(rc, "%s: open failed", fn);
if (ftruncate(fd, len) == -1)
err(rc, "%s: ftruncate failed", fn);
if ((rc = posix_fallocate(fd, 0, len)) != 0)
errc(1, rc, "%s: posix_fallocate failed", fn);
if (write(fd, &rc, 1) != 1)
err(rc, "%s: write failed", fn);
if (fsync(fd) == -1)
err(rc, "%s: fsync failed", fn);
if (close(fd) == -1)
err(rc, "%s: close failed", fn);
return 0;
}
$ cc fallocate.c
$ ./a.out file 10000
a.out: file: posix_fallocate failed: Operation not supported
$