Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 781ea624e5
Fetching contributors…

Cannot retrieve contributors at this time

file 25 lines (20 sloc) 0.529 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#include <stdint.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include "dat.h"

static char buf0[512]; /* buffer of zeros */

/* Allocate disk space.
* Expects fd's offset to be 0; may also reset fd's offset to 0.
* Returns 0 on success, and a positive errno otherwise. */
int
falloc(int fd, int len)
{
    int i, w;

    for (i = 0; i < len; i += w) {
        w = write(fd, buf0, sizeof buf0);
        if (w == -1) return errno;
    }

    lseek(fd, 0, 0); /* do not care if this fails */

    return 0;
}
Something went wrong with that request. Please try again.