From e734f3f65489349026e74ceb537c43a644df4427 Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Tue, 26 May 2009 00:44:38 +0000 Subject: [PATCH] Poor man's virtualization of ntp --- fd_myntp.c | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 fd_myntp.c 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; +} -- 2.43.0