Unified · Split
| @@ -43,12 +43,28 @@ void usage(void); · 42 unmodified lines | ||
| 43 | 43 | Dir *rootdir; |
| 44 | 44 | |
| 45 | 45 | int |
| 46 | −fsgetattr(const char *path, struct stat *st) | |
| 46 | +stubstat(const char *path, struct stat *st) | |
| 47 | 47 | { |
| 48 | 48 | FFid *f; |
| 49 | 49 | Dir *d; |
| 50 | 50 | |
| 51 | − DPRINT("fsgetattr %s\n", path); | |
| 51 | + if((f = _9pwalk(path)) == NULL) | |
| 52 | + return -EIO; | |
| 53 | + if((d = _9pstat(f)) == NULL){ | |
| 54 | + _9pclunk(f); | |
| 55 | + return -EACCES; | |
| 56 | + } | |
| 57 | + dir2stat(st, d); | |
| 58 | + _9pclunk(f); | |
| 59 | + free(d); | |
| 60 | + return 0; | |
| 61 | +} | |
| 62 | + | |
| 63 | +int | |
| 64 | +fsgetattr(const char *path, struct stat *st) | |
| 65 | +{ | |
| 66 | + Dir *d; | |
| 67 | + | |
| 52 | 68 | if(iscachectl(path)){ |
| 53 | 69 | st->st_mode = 0666 | S_IFREG; |
| 54 | 70 | st->st_uid = getuid(); |
| @@ -56,25 +72,13 @@ fsgetattr(const char *path, struct stat *st) · 1 unmodified line | ||
| 56 | 72 | st->st_size = sizeof("cleared\n") - 1; |
| 57 | 73 | return 0; |
| 58 | 74 | } |
| 59 | − if((d = iscached(path)) == NULL){ | |
| 60 | − DPRINT("fsgetattr %s is not cached\n", path); | |
| 75 | + if((d = iscached(path)) == NULL) | |
| 61 | 76 | d = addtocache(path); |
| 62 | − } | |
| 63 | 77 | if(d == NULL) |
| 64 | 78 | return -ENOENT; |
| 65 | − if(strcmp(d->uid, "stub") != 0){ /* hack for aux/stub */ | |
| 66 | − dir2stat(st, d); | |
| 67 | − return 0; | |
| 68 | − } | |
| 69 | − if((f = _9pwalk(path)) == NULL) | |
| 70 | − return -EIO; | |
| 71 | − if((d = _9pstat(f)) == NULL){ | |
| 72 | − _9pclunk(f); | |
| 73 | − return -EACCES; | |
| 74 | − } | |
| 79 | + if(strcmp(d->uid, "stub") == 0) /* hack for aux/stub */ | |
| 80 | + return stubstat(path, st); | |
| 75 | 81 | dir2stat(st, d); |
| 76 | − _9pclunk(f); | |
| 77 | − free(d); | |
| 78 | 82 | return 0; |
| 79 | 83 | } |
| 80 | 84 | |