Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int my_getattr(const char *path, struct stat *stbuf)
- {
- int res = 0;
- int ok=0; //ok permet de controler si @para path fait partie des fichiers du répétoire intéressé ou pas
- int i=0;
- memset(stbuf, 0, sizeof(struct stat));
- //Vérifier quel type de fichier qu'on devra retourner: répétoire ou fichier régulier
- if(strcmp(path, "/") == 0) { // path est un répétoire
- stbuf->st_mode = S_IFDIR | 0755;
- stbuf->st_nlink = 2;
- ok=1;
- }
- else{
- for(i=0;i<MAX_FICHIER;i++){
- if(strcmp(atoi(path),matrice[i][0]) == 0) { //path est un fichier existe dans le répertoire
- stbuf->st_mode = S_IFREG | 0444; //0444: O_RDONLY
- stbuf->st_nlink = 1;
- if(strcmp(my_path,path) == 0)
- stbuf->st_size = strlen(path); //taille du fichier est la taille de la chaine "Je connais FUSE\n" si @path est le fichier lire
- else
- stbuf->st_size = 0; //sinon la taille du fichier est 0
- ok=1;
- break;
- }
- }
- }
- if(ok==0) //path n'existe pas dans le répétoire
- res = -ENOENT;
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement