X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=root-context%2Ffd_fusemount.c;fp=root-context%2Ffd_fusemount.c;h=5c29c983576fb66090165a5544ade5ab950bf48f;hb=10503d985ac1acdac4ed653e608ccc492baa446a;hp=0000000000000000000000000000000000000000;hpb=46f46b3486d68231a875c7c21e5dd64282b3813a;p=vsys-scripts.git diff --git a/root-context/fd_fusemount.c b/root-context/fd_fusemount.c new file mode 100644 index 0000000..5c29c98 --- /dev/null +++ b/root-context/fd_fusemount.c @@ -0,0 +1,138 @@ +#include +#include +#include +#include +#include +#include +#include +#include "fdpass.h" + +unsigned int rcvbuf = 16*1024*1024; +unsigned int arg_length = 128; +unsigned int mountflags = MS_NODEV | MS_NOSUID; + +FILE *logfd; + +void receive_argument(int control_channel_fd, char *source) { + int received; + received=recv(control_channel_fd, source, arg_length, 0); + if (received 1023) { + printf ("Got control_channel_fd = %d\n", control_channel_fd); + exit(1); + } + + receive_argument(control_channel_fd, source); + receive_argument(control_channel_fd, target); + receive_argument(control_channel_fd, filesystemtype); + receive_argument(control_channel_fd, data); + + mount_fd = receive_fd (control_channel_fd); + + if (mount_fd < 2) { + printf("mount_fd = %d\n", mount_fd); + exit(1); + } + + set_magic_fd(data, mount_fd); + + + check_source(source); + check_target(target); + check_fstype(filesystemtype); + + sprintf(slice_target,"/vservers/%s/%s", slice_name, target); + + fprintf(logfd, "Mount fd: %d Source: %s slice_target: %s fstype: %s mountflags: %d data: %s\n", mount_fd, source, slice_target, filesystemtype, mountflags, data); + + if (!mount(source, slice_target, filesystemtype, mountflags, data)) { + send_fd(control_channel_fd, mount_fd); + } + else { + printf ("Error executing mount\n"); + exit(1); + } + + close(logfd); + return 0; +}