Skip to content

Commit

Permalink
Merge pull request #1 from fisop/add_flag
Browse files Browse the repository at this point in the history
Added flag to fisopfs to indicate filename for persistency
  • Loading branch information
FranciscoGauna authored Oct 31, 2024
2 parents 1b69229 + 078178a commit 46ab1bd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fisopfs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ En el mismo directorio que se utilizó para compilar la solución, ejectuar:
$ ./fisopfs prueba/
```

Hay una flag `--filedisk NAME` para indicar que archivo se
quiere utilizar como archivo de persistencia en disco.
El valor por defecto es "persistence_file.fisopfs"

```bash
$ ./fisopfs prueba/ --filedisk nuevo_disco.fisopfs
```

### Verificar directorio

```bash
Expand Down
20 changes: 20 additions & 0 deletions fisopfs/fisopfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include <stdlib.h>
#include <errno.h>

#define DEFAULT_FILE_DISK "persistence_file.fisopfs"

char *filedisk = DEFAULT_FILE_DISK;

static int
fisopfs_getattr(const char *path, struct stat *st)
{
Expand Down Expand Up @@ -91,5 +95,21 @@ static struct fuse_operations operations = {
int
main(int argc, char *argv[])
{
for (int i = 1; i < argc - 1; i++) {
if (strcmp(argv[i], "--filedisk") == 0) {
filedisk = argv[i + 1];

// We remove the argument so that fuse doesn't use our
// argument or name as folder.
// Equivalent to a pop.
for (int j = i; j < argc - 1; j++) {
argv[j] = argv[j + 2];
}

argc = argc - 2;
break;
}
}

return fuse_main(argc, argv, &operations, NULL);
}

0 comments on commit 46ab1bd

Please sign in to comment.