-struct fastbuf *
-fbdir_open_try(byte *name, uns mode, struct asio_queue *q)
-{
- if (!fbdir_cheat)
- mode |= O_DIRECT;
- int fd = sh_open(name, mode, 0666);
- if (fd < 0)
- return NULL;
- struct fastbuf *b = fbdir_open_internal(name, fd, q);
- if (mode & O_APPEND)
- fbdir_seek(b, 0, SEEK_END);
- return b;
-}
-
-struct fastbuf *
-fbdir_open(byte *name, uns mode, struct asio_queue *q)
-{
- struct fastbuf *b = fbdir_open_try(name, mode, q);
- if (!b)
- die("Unable to %s file %s: %m",
- (mode & O_CREAT) ? "create" : "open", name);
- return b;
-}
-
-struct fastbuf *
-fbdir_open_fd(int fd, struct asio_queue *q)
-{
- byte x[32];
-
- sprintf(x, "fd%d", fd);
- if (!fbdir_cheat && fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_DIRECT) < 0)
- log(L_WARN, "Cannot set O_DIRECT on fd %d: %m", fd);
- return fbdir_open_internal(x, fd, q);
-}
-
-struct fastbuf *
-fbdir_open_tmp(struct asio_queue *q)
-{
- byte buf[TEMP_FILE_NAME_LEN];
- struct fastbuf *f;
-
- temp_file_name(buf);
- f = fbdir_open(buf, O_RDWR | O_CREAT | O_TRUNC, q);
- bconfig(f, BCONFIG_IS_TEMP_FILE, 1);
- return f;
-}
-