-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
82 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
#ifndef getattr_h | ||
#define getattr_h | ||
#include "../lib/tree.h" | ||
#include "../lib/logger.h" | ||
|
||
#include <sys/stat.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <fuse.h> | ||
#include "tree.h" | ||
#include "logger.h" | ||
int sifs_getattr(const char*, struct stat*); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,69 @@ | ||
#include "../lib/getattr.h" | ||
/* | ||
./sifs -f -d -o default_permissions ./f ../Tars/testTar.tar | ||
./sifs -f -d -o default_permissions ../tests/testFolder ../tests/tars/testTar.tar | ||
*/ | ||
struct node* get_node_from_path(struct node* n, const char* path) { | ||
// +1 to remove . from filename | ||
|
||
// Node has the same path | ||
if (strcmp(n->header->name + 1, path) == 0) | ||
return n; | ||
// Path contains the node | ||
else if (strncmp(n->header->name + 1, path, strlen(n->header->name + 1) == 0) == 0) { | ||
; | ||
} | ||
return NULL; | ||
} | ||
|
||
int _sifs_getattr(const char* path, struct stat* sbuf) { | ||
return 0; | ||
return -1; | ||
} | ||
|
||
int sifs_getattr(const char* path, struct stat* sbuf) { | ||
logger(DEBUG, "[getattr] Started\n"); | ||
printf("caca\n"); | ||
//logger(DEBUG, "[getattr] Started on path: %s\n", path); | ||
|
||
char *aux; | ||
aux = malloc(strlen(path) + 2); | ||
aux[0] = '.'; aux[1] = '\0'; | ||
strcpy(aux, path); | ||
stat(aux, sbuf); | ||
return 0; | ||
|
||
if (strcmp(path, "/") == 0) { | ||
stat("./", sbuf); | ||
return -1; | ||
} | ||
|
||
struct fuse_context* context; | ||
context = fuse_get_context(); | ||
|
||
struct node* root; | ||
root = (struct node*)context->private_data; | ||
logger(DEBUG, "[getattr] %s\n", root->header->name); | ||
|
||
struct node* n; | ||
n = get_node_from_path(root, path); | ||
|
||
// The 'st_dev' and 'st_blksize' fields are ignored. | ||
// The 'st_ino' field is ignored except if the 'use_ino' mount option is given | ||
sbuf->st_mode = strtoul(n->header->mode, NULL, 10);/* protection */ | ||
sbuf->st_nlink = n->children_size;/* number of hard links */ | ||
sbuf->st_uid = strtoul(n->header->uid, NULL, 10); /* user ID of owner */ | ||
sbuf->st_gid = strtoul(n->header->gid, NULL, 10); /* group ID of owner */ | ||
//sbuf->st_rdev = n->header->; /* device ID (if special file) */ | ||
sbuf->st_size = strtol(n->header->size, NULL, 8); /* total size, in bytes */ | ||
//sbuf->st_blksize = n->header->; /* blocksize for file system I/O */ | ||
//sbuf->st_blocks = n->header->; /* number of 512B blocks allocated */ | ||
sbuf->st_atime = strtol(n->header->atime, NULL, 10); /* time of last access */ | ||
sbuf->st_mtime = strtol(n->header->mtime, NULL, 10); /* time of last modification */ | ||
sbuf->st_ctime = strtol(n->header->ctime, NULL, 10); /* time of last status change */ | ||
|
||
int ret; | ||
ret = _sifs_getattr(path, sbuf); | ||
|
||
logger(DEBUG, "[getattr] Ended\n"); | ||
return ret; | ||
return 0; | ||
} | ||
|