2 #include <sys/socket.h>
9 unsigned int rcvbuf = 16*1024*1024;
10 unsigned int arg_length = 128;
11 unsigned int mountflags = MS_NODEV | MS_NOSUID;
13 void receive_argument(int control_channel_fd, char *source) {
15 received=recv(control_channel_fd, source, arg_length, 0);
16 if (received<arg_length) {
17 printf("Error receiving arguments over the control buffer\n");
22 int get_magic_fd (char *data) {
26 data[arg_length-1]='\0';
27 ptr = strstr(data,"fd=");
31 // Found two fd= expressions
32 if (strstr(ptr+3,"fd="))
36 sscanf(ptr+3,"%d",&fd);
43 int main(int argc, char *argv[]) {
44 int control_channel_fd, magic_fd, mount_fd;
45 char source[128],target[128],filesystemtype[128],data[128],slice_target[256];
50 printf("This script is called by vsys.\n");
54 char *slice_name = argv[1];
56 sscanf(argv[2],"%d", &control_channel_fd);
58 if (control_channel_fd <3 || control_channel_fd > 1023) {
59 printf ("Got control_channel_fd = %d\n", control_channel_fd);
63 receive_argument(control_channel_fd, source);
64 receive_argument(control_channel_fd, target);
65 receive_argument(control_channel_fd, filesystemtype);
66 receive_argument(control_channel_fd, data);
68 magic_fd = get_magic_fd (data);
71 printf("Got fd %d in fusemount\n",magic_fd);
75 mount_fd = receive_fd (control_channel_fd);
77 if (mount_fd != magic_fd) {
78 printf("mount_fd (%d) != magic_fd (%d)\n", mount_fd, magic_fd);
84 check_fstype(filesystemtype);
86 sprintf(slice_target,"/vservers/%s/%s", target);
88 if (!mount(source, slice_target, filesystemtype, mountflags, data)) {
89 send_fd(control_channel_fd, magic_fd);