Unified · Split
| @@ -2,6 +2,10 @@ · 1 unmodified line | ||
| 2 | 2 | #include <sys/socket.h> |
| 3 | 3 | #include <sys/un.h> |
| 4 | 4 | |
| 5 | +#ifdef __linux__ | |
| 6 | +#include <linux/vm_sockets.h> | |
| 7 | +#endif | |
| 8 | + | |
| 5 | 9 | #include <netinet/in.h> |
| 6 | 10 | #include <netinet/tcp.h> |
| 7 | 11 | #include <netdb.h> |
| @@ -461,12 +465,15 @@ struct fuse_operations fsops = { · 453 unmodified lines | ||
| 461 | 465 | .chmod = fschmod |
| 462 | 466 | }; |
| 463 | 467 | |
| 464 | −static int uflag, tflag; | |
| 468 | +static int uflag, tflag, vflag; | |
| 465 | 469 | |
| 466 | 470 | static void |
| 467 | 471 | doconnect(char *name, char *port) |
| 468 | 472 | { |
| 469 | 473 | struct sockaddr_un uaddr; |
| 474 | +#ifdef __linux__ | |
| 475 | + struct sockaddr_vm vaddr; | |
| 476 | +#endif | |
| 470 | 477 | struct addrinfo *a, *ainfo, hint; |
| 471 | 478 | int e, n, yes; |
| 472 | 479 | int p1[2], p2[2]; |
| @@ -509,6 +516,31 @@ doconnect(char *name, char *port) · 36 unmodified lines | ||
| 509 | 516 | return; |
| 510 | 517 | } |
| 511 | 518 | |
| 519 | +#ifdef __linux__ | |
| 520 | + if(vflag){ | |
| 521 | + long cid = strtol(name, NULL, 10); | |
| 522 | + if(cid < 0 || cid > UINT32_MAX){ | |
| 523 | + errx(1, "parsing service as vsock cid"); | |
| 524 | + } | |
| 525 | + | |
| 526 | + long intport = strtol(port, NULL, 10); | |
| 527 | + if(intport <= 0 || intport > UINT32_MAX){ | |
| 528 | + errx(1, "parsing vsock port"); | |
| 529 | + } | |
| 530 | + | |
| 531 | + memset(&vaddr, 0, sizeof(struct sockaddr_vm)); | |
| 532 | + vaddr.svm_family = AF_VSOCK; | |
| 533 | + vaddr.svm_cid = cid; | |
| 534 | + vaddr.svm_port = intport; | |
| 535 | + | |
| 536 | + infd = outfd = socket(AF_VSOCK, SOCK_STREAM, 0); | |
| 537 | + if(connect(infd, (struct sockaddr *)&vaddr, sizeof(struct sockaddr_vm)) == -1) | |
| 538 | + goto err; | |
| 539 | + | |
| 540 | + return; | |
| 541 | + } | |
| 542 | +#endif | |
| 543 | + | |
| 512 | 544 | memset(&hint, 0, sizeof(hint)); |
| 513 | 545 | hint.ai_flags = AI_ADDRCONFIG; |
| 514 | 546 | hint.ai_family = AF_UNSPEC; |
| @@ -550,7 +582,7 @@ main(int argc, char *argv[]) · 35 unmodified lines | ||
| 550 | 582 | if((pw = getpwuid(getuid())) == NULL) |
| 551 | 583 | errx(1, "Could not get user"); |
| 552 | 584 | strecpy(user, user+sizeof(user), pw->pw_name); |
| 553 | − while((ch = getopt(argc, argv, ":dnUTap:u:A:o:f")) != -1){ | |
| 585 | + while((ch = getopt(argc, argv, ":dnUVTap:u:A:o:f")) != -1){ | |
| 554 | 586 | switch(ch){ |
| 555 | 587 | case 'd': |
| 556 | 588 | debug++; |
| @@ -561,6 +593,13 @@ main(int argc, char *argv[]) · 4 unmodified lines | ||
| 561 | 593 | case 'U': |
| 562 | 594 | uflag++; |
| 563 | 595 | break; |
| 596 | + case 'V': | |
| 597 | +#ifdef __linux__ | |
| 598 | + vflag++; | |
| 599 | +#else | |
| 600 | + errx(2, "vsock not supported on this platform"); | |
| 601 | +#endif | |
| 602 | + break; | |
| 564 | 603 | case 'T': |
| 565 | 604 | tflag++; |
| 566 | 605 | break; |
| @@ -732,6 +771,6 @@ breakpath(char *dname) · 165 unmodified lines | ||
| 732 | 771 | void |
| 733 | 772 | usage(void) |
| 734 | 773 | { |
| 735 | − fprintf(stderr, "Usage: 9pfs [-anUfd] [-A aname] [-p port] [-u user] [-o option] service mtpt\n"); | |
| 774 | + fprintf(stderr, "Usage: 9pfs [-anUVfd] [-A aname] [-p port] [-u user] [-o option] service mtpt\n"); | |
| 736 | 775 | exit(2); |
| 737 | 776 | } |