-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include "lib.h"
-#include "fastbuf.h"
-#include "lfs.h"
-
-struct fastbuf *__bfdopen(int fd, uns buffer, byte *name)
-{
- struct fastbuf *b = xmalloc(sizeof(struct fastbuf));
-
- b->buflen = buffer;
- b->buffer = xmalloc(buffer);
- b->bptr = b->bstop = b->buffer;
- b->bufend = b->buffer + buffer;
- b->name = stralloc(name);
- b->pos = b->fdpos = 0;
- b->fd = fd;
- return b;
-}
-
-struct fastbuf *
-bopen(byte *name, uns mode, uns buffer)
-{
- int fd;
-
- mode |= SHERLOCK_O_LARGEFILE;
- fd = open(name, mode, 0666);
-
- if (fd < 0)
- die("Unable to %s file %s: %m",
- (mode & O_CREAT) ? "create" : "open", name);
- return __bfdopen(fd, buffer, name);
-}
-
-struct fastbuf *
-bfdopen(int fd, uns buffer)
-{
- byte x[32];
-
- sprintf(x, "fd%d", fd);
- return __bfdopen(fd, buffer, x);
-}