annotate rvinterf/etmsync/launchrvif.c @ 275:cedf09b6b5ac

started laying the foundation for fc-fsio host utility
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 23 Feb 2014 20:27:15 +0000
parents
children 909f00c15f27
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
275
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This module implements the optional "behind the scenes" invokation
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * of rvinterf from fc-fsio etc.
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <sys/types.h>
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <sys/socket.h>
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <stdio.h>
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <stdlib.h>
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <unistd.h>
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 static char rvinterf_pathname[] = "/usr/local/bin/rvinterf";
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 extern int sock;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 launch_rvinterf()
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 {
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 int sp[2], rc;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 char *rvif_argv[11], Sarg[16], **ap;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 rc = socketpair(AF_UNIX, SOCK_STREAM, 0, sp);
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 if (rc < 0) {
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 perror("socketpair");
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 exit(1);
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 }
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 sock = sp[0];
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 sprintf(Sarg, "-S%d", sp[1]);
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 ap = rvif_argv;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 *ap++ = "rvinterf";
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 *ap++ = Sarg;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 *ap++ = "-n";
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 if (rvinterf_Bopt) {
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 *ap++ = "-B";
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 *ap++ = rvinterf_Bopt;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 }
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 if (rvinterf_lopt) {
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 *ap++ = "-l";
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 *ap++ = rvinterf_lopt;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 }
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 if (rvinterf_wopt) {
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 *ap++ = "-w";
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 *ap++ = rvinterf_wopt;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 }
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 *ap++ = rvinterf_ttyport;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 *ap = 0;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 rc = vfork();
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 if (rc < 0) {
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 perror("vfork for launching rvinterf");
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 exit(1);
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 }
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 if (!rc) {
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 /* we are in the child - do the exec */
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 close(sp[0]);
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 execv(rvinterf_pathname, rvif_argv);
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 perror(rvinterf_pathname);
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 _exit(1);
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 }
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 close(sp[1]);
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 return 0;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 }