From: Sapan Bhatia Date: Tue, 26 May 2009 00:44:38 +0000 (+0000) Subject: Poor man's virtualization of ntp X-Git-Tag: vsys-scripts-0.95-3~4 X-Git-Url: http://git.onelab.eu/?p=vsys-scripts.git;a=commitdiff_plain;h=e734f3f65489349026e74ceb537c43a644df4427 Poor man's virtualization of ntp --- diff --git a/fd_myntp.c b/fd_myntp.c new file mode 100644 index 0000000..5c29c98 --- /dev/null +++ b/fd_myntp.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; +}