document the new binlog stats
[beanstalkd.git] / port-bsd.c
blob08134d56bc050fd2f5a45c425432f5cb7413be4a
1 #include <stdint.h>
2 #include <sys/types.h>
3 #include <unistd.h>
4 #include <errno.h>
5 #include "dat.h"
7 static char buf0[512]; /* buffer of zeros */
9 /* Allocate disk space.
10 * Expects fd's offset to be 0; may also reset fd's offset to 0.
11 * Returns 0 on success, and a positive errno otherwise. */
12 int
13 falloc(int fd, int len)
15 int i, w;
17 for (i = 0; i < len; i += w) {
18 w = write(fd, buf0, sizeof buf0);
19 if (w == -1) return errno;
22 lseek(fd, 0, 0); /* do not care if this fails */
24 return 0;