Skip to content

Commit

Permalink
release notes 1.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
yhoogstrate committed Sep 6, 2019
1 parent 755faf0 commit 6e94593
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 50 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project(fastafs)
# Do this once in a while - find different bugs
#set(CMAKE_CXX_COMPILER "clang++")

set(PROJECT_VERSION "1.6.1")
set(PROJECT_VERSION "1.6.2")
set(PACKAGE_URL "https://github.com/yhoogstrate/fastafs")
set(PACKAGE_BUGREPORT "${PACKAGE_URL}/issues")

Expand Down
7 changes: 7 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2019-09-06 Youri Hoogstrate

* v1.6.2
* Rewritten argument parsing of fuse/mounting
* Added binary `mount.fastafs` only for mounting, wihtout the toolkit
* `fastafs --version` will now also output whether the binary was compiled as debug or release.

2019-08-21 Youri Hoogstrate

* v1.6.1
Expand Down
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Here we propose a solution; a mixture of 2bit compression and random on FASTA ve
FASTAFS is compatible with 2bit files but 2bit has some limitations and does for instance not allow mounting DICT files needed for CRAM and Picard tools. The 2bit files can be convert to FASTAFS and, more importantly, a mounted FASTAFS mountpoint will not only virtualize the FASTA but also the 2bit file. Is FASTAFS this famous 15th standard (<https://xkcd.com/927/>)?
Partially, but it is not designed to replace FASTA nor 2bit as those mountpoints should be used as flat files did before and the virtualization of dict files is not possible when we mount 2bit files.

## installation and compilation
## Installation and compilation

Currently the package uses cmake for compilation
Required dependencies are:
Expand Down Expand Up @@ -165,6 +165,30 @@ aaaa
c
```

### Find all running `fastafs mount` / `mount.fastafs` instances

The output format of `fastafs ps` is: `<pid>\t<source>\t<destination>\n`

```
$ fastafs ps
16383 /home/youri/.local/share/fastafs/test.fastafs /mnt/tmp
```

### Mounting via fstab (for instance on linux boot)

You can add the following line(s) to /etc/fstab to make fastafs mount during boot:

```
mount.fastafs#/home/youri/.local/share/fastafs/hg19.fastafs /mnt/fastafs/hg19 fuse auto,allow_other 0 0
```

Here `mount.fastafs` refers to the binary that only does mounting, without the rest of the toolkit.
This is followed by a hash-tag and the path of the desired fastafs file. The next value is the mount point followed by the argument indicating it runs fuse.
The `auto,allow_other` refers to the `-o` argument.
Here `auto` ensures it is mounted automatically after boot.
Given that a system mounts as root user, the default permission of the mount point will be only for root.
By setting `allow_other`, file system users get permissions to the mountpoint.

## Contributing
Feel free to start a discussion or to contribute to the GPL licensed code.

Expand Down
88 changes: 41 additions & 47 deletions src/fuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,9 @@ static int do_getxattr(const char* path, const char* name, char* value, size_t s
sprintf(mypid, "%d", getpid());
size_t pid_size = (size_t) strlen(mypid);


if(size > pid_size) {
strncpy(value, mypid, pid_size);
strcpy(value, mypid);// if statement makes strncpy unneeded
value[pid_size] = '\0';

return (int) pid_size + 1;
Expand Down Expand Up @@ -414,56 +415,57 @@ fuse_instance *parse_args(int argc, char **argv, char **argv_fuse)

//fuse option variable to send to fuse
argv_fuse[fi->argc_fuse++] = (char *) "fastafs"; // becomes fuse.fastafs

std::vector<char*> fuse_options = {}; // those that need to be appended later

char current_argument = '\0';// could be o for '-o', etc.

int i = 1;
std::vector<int> full_args = {};
while(i < argc) {
printf("processing argv[%i] = '%s';\n", i, argv[i]);
for(unsigned int i = 0; i < argc; ++i) {
printf("processing argv[%i] = '%s' [current argument=%i]\n", i, argv[i], (int) current_argument);

if(current_argument != '\0') { // parse the arguments' value
switch(current_argument) {
case 'p':
try {
sscanf(argv[i], "%u", &fi->padding);
} catch(std::exception const & e) {
std::cerr << "ERROR: invalid padding value, must be integer value ranging from 0 to max-int size\n";
exit(1);
}
case 'p': // scanning padding value
if(!sscanf(argv[i], "%u", &fi->padding)) {
throw std::invalid_argument("Invalid argument (padding value): " + std::string(argv[i]));
}
break;
default:
//argv_fuse[fi->argc_fuse++] = argv[i]; // -o contents must be send to fuse
fuse_options.push_back(argv[i]);
printf("Skipping parsing following argument: -%c = %s\n", current_argument, argv[i]);
default:
//throw std::invalid_argument("Invalid argument: " + std::string(argv[i]));
fuse_options.push_back(argv[i]); // could be values that correspond to fuse arguments, such as: -o, -f, etc.
break;
}
}
else if(argv[i][0] == '-') {

current_argument = '\0';// reset
} else if(argv[i][0] == '-') {
if(strlen(argv[i]) == 1) {
// error
throw std::invalid_argument("Invalid argument: " + std::string(argv[i]));
}
else if(argv[i][1] == '2') { // implement flags

switch(argv[i][1]) {
case '2': // a fastafs specific flag
fi->from_fastafs = false;
}
else { // remaining are no flags but arguments with values that need to be parsed
break;

case 'f': // fuse specific flags
case 's':
case 'd':
fuse_options.push_back(argv[i]);
break;

case 'o': // argument, fuse specific
current_argument = argv[i][1];
printf(" -> parsing arg: %c\n", current_argument);

if(argv[i][1] == 'o' or argv[i][1] == 'd' or argv[i][1] == 'f') {
//argv_fuse[fi->argc_fuse++] = argv[i];
fuse_options.push_back(argv[i]);
}
fuse_options.push_back(argv[i]); // fuse specific
break;

default: // argument, fastafs spcific (such as '-p' followed by '50')
current_argument = argv[i][1];
break;
}
} else {
full_args.push_back(i); // args such as 'sudo', 'fastafs' 'fastafs-uid' and '/mount/point' of which only the last 2 are needed
}
else {
full_args.push_back(i);
printf(" candidate of std-args of which last 2 are needed\n");
}
i++;

}

if(full_args.size() >= 2) {
Expand All @@ -479,31 +481,23 @@ fuse_instance *parse_args(int argc, char **argv, char **argv_fuse)
name = std::filesystem::path(fname).filename();

// remove .fastafs suffix
size_t lastindex = name.find_last_of(".");
name = name.substr(0, lastindex);
size_t lastindex = name.find_last_of(".");
name = name.substr(0, lastindex);

}
else {
} else {
name = std::string(argv[mount_target_arg]);
}

printf("[%s : %s]\n", name.c_str(), fname.c_str());

fi->f = new fastafs(name);
printf(" new \n");

fi->f->load(fname);
printf("loaded!\n");

fi->cache = fi->f->init_ffs2f(fi->padding, true);// allow mixed case
printf("initiated cache!\n");
} else {
std::string basename = std::filesystem::path(std::string(argv[mount_target_arg])).filename();

fi->u2b = new ucsc2bit(basename);// useses basename as prefix for filenames to mount: hg19.2bit -> hg19.2bit.fa
fi->u2b->load(std::string(argv[mount_target_arg]));
}

//argv_fuse[fi->argc_fuse++] = argv[mount_target_arg];
argv_fuse[fi->argc_fuse++] = argv[mount_target_arg + 1];
for(size_t j = 0; j < fuse_options.size(); j++) {
Expand Down
7 changes: 6 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ int main(int argc, char *argv[])
if(strcmp(argv[1], "--help") == 0 or strcmp(argv[1], "-h") == 0) {
usage();
} else if(strcmp(argv[1], "--version") == 0) {
std::cout << PACKAGE << " v" << PACKAGE_VERSION << GIT_SHA1_STRING << "\n\n";
#if DEBUG
std::cout << PACKAGE << " v" << PACKAGE_VERSION << GIT_SHA1_STRING << "-debug\n\n";
#else
std::cout << PACKAGE << " v" << PACKAGE_VERSION << GIT_SHA1_STRING << "-release\n\n";
#endif //DEBUG

std::cout << "Copyright (C) 2017 Youri Hoogstrate." << "\n";
std::cout << "License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.\n";
std::cout << "This is free software: you are free to change and redistribute it.\n";
Expand Down

0 comments on commit 6e94593

Please sign in to comment.