cannyls
cannyls copied to clipboard
Can't create a new lusf file on tmpfs(Linux)
It may be impossible to create a new lusf file on tmpfs because tmpfs doesn't support O_DIRECT. This issue makes cannyls(or frugalos) crash.
I checked the behavior of tmpfs by the following code:
#define _GNU_SOURCE
#include <fcntl.h>
#include <stdio.h>
#include <errno.h> // errno
#include <string.h> // strerror
int main(int argc, char** argv)
{
int result = open("/tmp/foo.txt", O_CREAT | O_RDONLY | O_DIRECT);
if (result == -1) {
printf("%s\n", strerror(errno));
return -1;
}
printf("ok\n");
return 0;
}
Then run:
$ gcc -o main main.c ; ./main
Invalid argument
environment
$ uname -a
Linux quad 4.18.6-arch1-1-ARCH #1 SMP PREEMPT Wed Sep 5 11:54:09 UTC 2018 x86_64 GNU/Linux
$ cargo -V
cargo 1.30.0 (a1a4ad372 2018-11-02)
how to reproduce
Make sure that /tmp is mounted as tmpfs.
$ git clone https://github.com/frugalos/kanils.git
$ cd kanils
$ cargo run -- Create --storage /tmp/foo.lusf --capacity=1024
Finished dev [unoptimized + debuginfo] target(s) in 0.07s
Running `target/debug/kanils Create --storage /tmp/foo.lusf --capacity=1024`
passed data region size = 1024
thread 'main' panicked at '
EXPRESSION: FileNvm::create(opt.storage_path, total_size)
ERROR: Other (cause; File exists (os error 17))
HISTORY:
[0] at /home/shinnya/.cargo/registry/src/github.com-1ecc6299db9ec823/cannyls-0.9.1/src/nvm/file.rs:163
[1] at src/main.rs:212
I think this is a problem of KaNiLs rather than CannyLS: https://github.com/frugalos/kanils/blob/3fffa9a5641f4f5153f174264e3f88e35ad60ffe/src/main.rs#L212-L217