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