History

refactor whitespace

Matus Skvarla committed 1 year ago

Commit b2e028c1 parent 2a541121 file · +84 −77Browse files

Unified · Split

9pfs.c+84−77
@@ -39,27 +39,27 @@ enum · 38 unmodified lines
3939 Msize = 32768,
4040 };
4141
42−void dir2stat(struct stat*, Dir*);
43−Dir *iscached(const char*);
44−Dir *addtocache(const char*);
45−void clearcache(const char*);
46−int iscachectl(const char*);
47−char *breakpath(char*);
48−void usage(void);
49−
50−Dir *rootdir;
51−FILE *logfile;
52−FFid *rootfid;
53−FFid *authfid;
54−int msize;
55−int infd, outfd;
56−int debug;
42+void dir2stat(struct stat*, Dir*);
43+Dir *iscached(const char*);
44+Dir *addtocache(const char*);
45+void clearcache(const char*);
46+int iscachectl(const char*);
47+char *breakpath(char*);
48+void usage(void);
49+
50+Dir *rootdir;
51+FILE *logfile;
52+FFid *rootfid;
53+FFid *authfid;
54+int msize;
55+int infd, outfd;
56+int debug;
5757
5858 int
5959 fsstat(const char *path, struct stat *st)
6060 {
61− FFid *f;
62− Dir *d;
61+ FFid *f;
62+ Dir *d;
6363
6464 if((f = _9pwalk(path)) == NULL)
6565 return -EIO;
@@ -76,7 +76,7 @@ fsstat(const char *path, struct stat *st) · 10 unmodified lines
7676 int
7777 fsgetattr(const char *path, struct stat *st)
7878 {
79− Dir *d;
79+ Dir *d;
8080
8181 if(iscachectl(path)){
8282 st->st_mode = 0666 | S_IFREG;
@@ -104,7 +104,7 @@ fsrelease(const char *path, struct fuse_file_info *ffi) · 21 unmodified lines
104104 int
105105 fsreleasedir(const char *path, struct fuse_file_info *ffi)
106106 {
107− FFid *f;
107+ FFid *f;
108108
109109 f = FFIH(ffi);
110110 if(f == NULL)
@@ -117,8 +117,8 @@ fsreleasedir(const char *path, struct fuse_file_info *ffi) · 6 unmodified lines
117117 int
118118 fstruncate(const char *path, off_t off)
119119 {
120− FFid *f;
121− Dir *d;
120+ FFid *f;
121+ Dir *d;
122122
123123 if(iscachectl(path))
124124 return 0;
@@ -151,9 +151,9 @@ fstruncate(const char *path, off_t off) · 26 unmodified lines
151151 int
152152 fsrename(const char *opath, const char *npath)
153153 {
154− Dir *d;
155− FFid *f;
156− char *dname, *bname;
154+ Dir *d;
155+ FFid *f;
156+ char *dname, *bname;
157157
158158 if(iscachectl(opath))
159159 return -EACCES;
@@ -189,7 +189,7 @@ fsrename(const char *opath, const char *npath) · 29 unmodified lines
189189 int
190190 fsopen(const char *path, struct fuse_file_info *ffi)
191191 {
192− FFid *f;
192+ FFid *f;
193193
194194 if(iscachectl(path))
195195 return 0;
@@ -210,8 +210,8 @@ fsopen(const char *path, struct fuse_file_info *ffi) · 14 unmodified lines
210210 int
211211 fscreate(const char *path, mode_t perm, struct fuse_file_info *ffi)
212212 {
213− FFid *f;
214− char *dname, *bname;
213+ FFid *f;
214+ char *dname, *bname;
215215
216216 if(iscachectl(path))
217217 return -EACCES;
@@ -246,8 +246,9 @@ fscreate(const char *path, mode_t perm, struct fuse_file_info *ffi) · 28 unmodified lines
246246 int
247247 fsmknod(const char *path, mode_t perm, dev_t dev)
248248 {
249− FFid *f;
250− char *dname, *bname;
249+ FFid *f;
250+ char *dname, *bname;
251+
251252 if(iscachectl(path))
252253 return -EACCES;
253254 if((f = _9pwalk(path)) == NULL){
@@ -270,7 +271,7 @@ fsmknod(const char *path, mode_t perm, dev_t dev) · 16 unmodified lines
270271 int
271272 fsunlink(const char *path)
272273 {
273− FFid *f;
274+ FFid *f;
274275
275276 if(iscachectl(path))
276277 return 0;
@@ -286,8 +287,8 @@ int · 9 unmodified lines
286287 fsread(const char *path, char *buf, size_t size, off_t off,
287288 struct fuse_file_info *ffi)
288289 {
289− FFid *f;
290− int r;
290+ FFid *f;
291+ int r;
291292
292293 if(iscachectl(path)){
293294 if(off >= CACHECTLSIZE)
@@ -311,8 +312,8 @@ int · 17 unmodified lines
311312 fswrite(const char *path, const char *buf, size_t size, off_t off,
312313 struct fuse_file_info *ffi)
313314 {
314− FFid *f;
315− int r;
315+ FFid *f;
316+ int r;
316317
317318 if(iscachectl(path)){
318319 clearcache(path);
@@ -331,7 +332,7 @@ fswrite(const char *path, const char *buf, size_t size, off_t off, · 12 unmodified lines
331332 int
332333 fsopendir(const char *path, struct fuse_file_info *ffi)
333334 {
334− FFid *f;
335+ FFid *f;
335336
336337 if(lookupdir(path, GET) != NULL){
337338 ffi->fh = (uintptr_t)0;
@@ -355,8 +356,8 @@ fsopendir(const char *path, struct fuse_file_info *ffi) · 17 unmodified lines
355356 int
356357 fsmkdir(const char *path, mode_t perm)
357358 {
358− FFid *f;
359− char *dname, *bname;
359+ FFid *f;
360+ char *dname, *bname;
360361
361362 if((f = _9pwalk(path)) != NULL){
362363 _9pclunk(f);
@@ -381,7 +382,7 @@ fsmkdir(const char *path, mode_t perm) · 18 unmodified lines
381382 int
382383 fsrmdir(const char *path)
383384 {
384− FFid *f;
385+ FFid *f;
385386
386387 if((f = _9pwalk(path)) == NULL)
387388 return -ENOENT;
@@ -399,10 +400,10 @@ int · 11 unmodified lines
399400 fsreaddir(const char *path, void *data, fuse_fill_dir_t ffd,
400401 off_t off, struct fuse_file_info *ffi)
401402 {
402− FDir *f;
403− Dir *d, *e;
404− long n;
405− struct stat s;
403+ FDir *f;
404+ Dir *d, *e;
405+ long n;
406+ struct stat s;
406407
407408 ffd(data, ".", NULL, 0);
408409 ffd(data, "..", NULL, 0);
@@ -425,8 +426,8 @@ fsreaddir(const char *path, void *data, fuse_fill_dir_t ffd, · 16 unmodified lines
425426 int
426427 fschmod(const char *path, mode_t perm)
427428 {
428− FFid *f;
429− Dir *d;
429+ FFid *f;
430+ Dir *d;
430431
431432 if((f = _9pwalk(path)) == NULL)
432433 return -ENOENT;
@@ -447,22 +448,22 @@ fschmod(const char *path, mode_t perm) · 14 unmodified lines
447448 }
448449
449450 struct fuse_operations fsops = {
450− .getattr = fsgetattr,
451− .truncate = fstruncate,
452− .rename = fsrename,
453− .open = fsopen,
454− .create = fscreate,
455− .mknod = fsmknod,
456− .unlink = fsunlink,
457− .read = fsread,
458− .write = fswrite,
459− .opendir = fsopendir,
460− .mkdir = fsmkdir,
461− .rmdir = fsrmdir,
462− .readdir = fsreaddir,
463− .release = fsrelease,
451+ .getattr = fsgetattr,
452+ .truncate = fstruncate,
453+ .rename = fsrename,
454+ .open = fsopen,
455+ .create = fscreate,
456+ .mknod = fsmknod,
457+ .unlink = fsunlink,
458+ .read = fsread,
459+ .write = fswrite,
460+ .opendir = fsopendir,
461+ .mkdir = fsmkdir,
462+ .rmdir = fsrmdir,
463+ .readdir = fsreaddir,
464+ .release = fsrelease,
464465 .releasedir = fsreleasedir,
465− .chmod = fschmod
466+ .chmod = fschmod
466467 };
467468
468469 static int uflag, tflag, vflag;
@@ -470,13 +471,13 @@ static int uflag, tflag, vflag; · 1 unmodified line
470471 static void
471472 doconnect(char *name, char *port)
472473 {
473− struct sockaddr_un uaddr;
474+ struct sockaddr_un uaddr;
474475 #ifdef __linux__
475− struct sockaddr_vm vaddr;
476+ struct sockaddr_vm vaddr;
476477 #endif
477− struct addrinfo *a, *ainfo, hint;
478− int e, n, yes;
479− int p1[2], p2[2];
478+ struct addrinfo *a, *ainfo, hint;
479+ int e, n, yes;
480+ int p1[2], p2[2];
480481
481482 if(tflag){
482483 if(pipe(p1) < 0 || pipe(p2) < 0)
@@ -560,6 +561,7 @@ doconnect(char *name, char *port) · 77 unmodified lines
560561 freeaddrinfo(ainfo);
561562 if(infd >= 0)
562563 return;
564+
563565 err:
564566 err(1, "Could not connect to 9p server");
565567 }
@@ -568,9 +570,9 @@ int · 2 unmodified lines
568570 main(int argc, char *argv[])
569571 {
570572 AuthInfo *ai;
571− struct passwd *pw;
573+ struct passwd *pw;
572574 char logstr[100], *fusearg[argc], **fargp, port[10], user[30], *aname;
573− int ch, doauth;
575+ int ch, doauth;
574576
575577 fargp = fusearg;
576578 *fargp++ = *argv;
@@ -616,7 +618,7 @@ main(int argc, char *argv[]) · 39 unmodified lines
616618 case 'A':
617619 aname = strdup(optarg);
618620 break;
619− case 'o':
621+ case 'o':
620622 *fargp++ = "-o";
621623 *fargp++ = optarg;
622624 break;
@@ -629,8 +631,10 @@ main(int argc, char *argv[]) · 6 unmodified lines
629631 argv += optind;
630632 if(argc != 2)
631633 usage();
634+
632635 *fargp++ = "-s";
633636 *fargp++ = argv[1];
637+
634638 if(debug){
635639 snprintf(logstr, sizeof(logstr), "/tmp/9pfs-%d.log", getpid());
636640 if((logfile = fopen(logstr, "w")) == NULL)
@@ -641,6 +645,7 @@ main(int argc, char *argv[]) · 4 unmodified lines
641645 doconnect(argv[0], port);
642646 init9p();
643647 msize = _9pversion(Msize);
648+
644649 if(doauth){
645650 authfid = _9pauth(AUTHFID, user, NULL);
646651 ai = auth_proxy(authfid, auth_getkey, "proto=p9any role=client");
@@ -648,9 +653,11 @@ main(int argc, char *argv[]) · 1 unmodified line
648653 err(1, "Could not establish authentication");
649654 auth_freeAI(ai);
650655 }
656+
651657 rootfid = _9pattach(ROOTFID, doauth ? AUTHFID : NOFID, user, aname);
652658 if((rootdir = _9pstat(rootfid)) == NULL)
653659 errx(1, "Could not stat root");
660+
654661 DPRINT("About to fuse_main\n");
655662 fuse_main(fargp - fusearg, fusearg, &fsops, NULL);
656663 exit(0);
@@ -659,8 +666,8 @@ main(int argc, char *argv[]) · 2 unmodified lines
659666 void
660667 dir2stat(struct stat *s, Dir *d)
661668 {
662− struct passwd *p;
663− struct group *g;
669+ struct passwd *p;
670+ struct group *g;
664671
665672 s->st_dev = d->dev;
666673 s->st_ino = d->qid.path;
@@ -683,7 +690,7 @@ dir2stat(struct stat *s, Dir *d) · 16 unmodified lines
683690 void
684691 clearcache(const char *path)
685692 {
686− char *dname;
693+ char *dname;
687694
688695 dname = estrdup(path);
689696 breakpath(dname);
@@ -695,9 +702,9 @@ clearcache(const char *path) · 5 unmodified lines
695702 Dir*
696703 iscached(const char *path)
697704 {
698− FDir *fd;
699− Dir *d, e;
700− char *dname, *bname;
705+ FDir *fd;
706+ Dir *d, e;
707+ char *dname, *bname;
701708
702709 if(strcmp(path, "/") == 0)
703710 return rootdir;
@@ -716,9 +723,9 @@ iscached(const char *path) · 12 unmodified lines
716723 Dir*
717724 addtocache(const char *path)
718725 {
719− FFid *f;
720− Dir *d;
721− char *dname;
726+ FFid *f;
727+ Dir *d;
728+ char *dname;
722729
723730 DPRINT("addtocache %s\n", path);
724731 dname = estrdup(path);
@@ -759,7 +766,7 @@ iscachectl(const char *path) · 34 unmodified lines
759766 char*
760767 breakpath(char *dname)
761768 {
762− char *bname;
769+ char *bname;
763770
764771 bname = strrchr(dname, '/');
765772 *bname++ = '\0';

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