From: Sapan Bhatia Date: Wed, 25 Mar 2009 18:27:08 +0000 (+0000) Subject: Reroutemount library for transparently mounting fuse partitions. X-Git-Url: http://git.onelab.eu/?p=vsys-wrappers.git;a=commitdiff_plain;h=3adff48421bd28afd1ace702b0f7cde17ce60ef4 Reroutemount library for transparently mounting fuse partitions. --- diff --git a/fuse/reroutemount.c b/fuse/reroutemount.c index 3fa229e..9bb8b60 100644 --- a/fuse/reroutemount.c +++ b/fuse/reroutemount.c @@ -7,7 +7,16 @@ #include "stolen_from_fuse.h" char *socket_name = "/vsys/fd_fusemount.control"; - +unsigned int arg_length = 128; + +void send_argument(int control_channel_fd, char *source) { + int sent; + sent=send(control_channel_fd, source, arg_length, 0); + if (sent 0 ) { - // get the fd - fuse_fd = receive_fd(fd); - - // what was the old fd? - int old_fd; - char extra[1024]; - int s = sscanf( data, "fd=%d,%s", &old_fd, extra ); - assert( dup2( fuse_fd, old_fd ) == old_fd ); + old_fuse_fd = get_magic_fd (data); + + send_fd(fd, old_fuse_fd); + + if (fuse_fd == -1) { + printf ("Reroutemount: Could not identify FUSE fd: %d\n", fuse_fd); + exit(1); + } + + new_fuse_fd=receive_fd(fd); + + if (new_fuse_fd == -1) { + printf ("Reroutemount: Fusemount returned bad fd: %d\n", fuse_fd); + exit(1); + } + if( dup2(new_fuse_fd, old_fuse_fd ) != new_fuse_fd ) { + printf ("Could not duplicate returned file descriptor\n"); + exit(1); } close(fd);