History

make stub handling pretty

Benjamin Scher Purcell committed 11 years ago

Commit b9b50f71 parent 05864281 file · +21 −17Browse files

Unified · Split

9pfs.c+21−17
@@ -43,12 +43,28 @@ void usage(void); · 42 unmodified lines
4343 Dir *rootdir;
4444
4545 int
46−fsgetattr(const char *path, struct stat *st)
46+stubstat(const char *path, struct stat *st)
4747 {
4848 FFid *f;
4949 Dir *d;
5050
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+
5268 if(iscachectl(path)){
5369 st->st_mode = 0666 | S_IFREG;
5470 st->st_uid = getuid();
@@ -56,25 +72,13 @@ fsgetattr(const char *path, struct stat *st) · 1 unmodified line
5672 st->st_size = sizeof("cleared\n") - 1;
5773 return 0;
5874 }
59− if((d = iscached(path)) == NULL){
60− DPRINT("fsgetattr %s is not cached\n", path);
75+ if((d = iscached(path)) == NULL)
6176 d = addtocache(path);
62− }
6377 if(d == NULL)
6478 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);
7581 dir2stat(st, d);
76− _9pclunk(f);
77− free(d);
7882 return 0;
7983 }
8084

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t