(no commit message)
authorSapan Bhatia <sapanb@cs.princeton.edu>
Mon, 30 Mar 2009 20:17:34 +0000 (20:17 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Mon, 30 Mar 2009 20:17:34 +0000 (20:17 +0000)
fuse/Makefile
fuse/fdpass.c [deleted file]
fuse/fdpass.h [deleted file]
fuse/reroutemount.c

index e6f993d..1da8868 100644 (file)
@@ -1,4 +1,4 @@
 all: fuse_vsys_wrapper.so
 
-fuse_vsys_wrapper.so: fdpass.c reroutemount.c
-       gcc -shared fdpass.c reroutemount.c -o fuse_vsys_wrapper.so
+fuse_vsys_wrapper.so: ../lib/fdpass.c reroutemount.c
+       gcc -shared -I../lib ../lib/fdpass.c reroutemount.c -o fuse_vsys_wrapper.so
diff --git a/fuse/fdpass.c b/fuse/fdpass.c
deleted file mode 100644 (file)
index 5548064..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-// Modified version of library functions in FUSE
-//
-
-#include <assert.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/mount.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-
-int send_fd(int sock_fd, int fd)
-{
-       int retval;
-       struct msghdr msg;
-       struct cmsghdr *p_cmsg;
-       struct iovec vec;
-       size_t cmsgbuf[CMSG_SPACE(sizeof(fd)) / sizeof(size_t)];
-       int *p_fds;
-       char sendchar = 0;
-
-       msg.msg_control = cmsgbuf;
-       msg.msg_controllen = sizeof(cmsgbuf);
-       p_cmsg = CMSG_FIRSTHDR(&msg);
-       p_cmsg->cmsg_level = SOL_SOCKET;
-       p_cmsg->cmsg_type = SCM_RIGHTS;
-       p_cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
-       p_fds = (int *) CMSG_DATA(p_cmsg);
-       *p_fds = fd;
-       msg.msg_controllen = p_cmsg->cmsg_len;
-       msg.msg_name = NULL;
-       msg.msg_namelen = 0;
-       msg.msg_iov = &vec;
-       msg.msg_iovlen = 1;
-       msg.msg_flags = 0;
-       /* "To pass file descriptors or credentials you need to send/read at
-        * least one byte" (man 7 unix) */
-       vec.iov_base = &sendchar;
-       vec.iov_len = sizeof(sendchar);
-       while ((retval = sendmsg(sock_fd, &msg, 0)) == -1 && errno == EINTR);
-       if (retval != 1) {
-               perror("sending file descriptor");
-               return -1;
-       }
-       return 0;
-}
-
-
-/* return value:
- * >= 0         => fd
- * -1   => error
- */
-int receive_fd(int fd)
-{
-       struct msghdr msg;
-       struct iovec iov;
-       char buf[1];
-       int rv;
-       size_t ccmsg[CMSG_SPACE(sizeof(int)) / sizeof(size_t)];
-       struct cmsghdr *cmsg;
-
-       iov.iov_base = buf;
-       iov.iov_len = 1;
-
-       msg.msg_name = 0;
-       msg.msg_namelen = 0;
-       msg.msg_iov = &iov;
-       msg.msg_iovlen = 1;
-       /* old BSD implementations should use msg_accrights instead of
-        * msg_control; the interface is different. */
-       msg.msg_control = ccmsg;
-       msg.msg_controllen = sizeof(ccmsg);
-
-       while(((rv = recvmsg(fd, &msg, 0)) == -1) && errno == EINTR);
-       if (rv == -1) {
-               perror("recvmsg");
-               return -1;
-       }
-       if(!rv) {
-               /* EOF */
-               return -1;
-       }
-
-       cmsg = CMSG_FIRSTHDR(&msg);
-       if (!cmsg->cmsg_type == SCM_RIGHTS) {
-               fprintf(stderr, "got control message of unknown type %d\n",
-                       cmsg->cmsg_type);
-               return -1;
-       }
-       return *(int*)CMSG_DATA(cmsg);
-}
-
diff --git a/fuse/fdpass.h b/fuse/fdpass.h
deleted file mode 100644 (file)
index f00a6fb..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-// Modified version of library functions in FUSE
-//
-int send_fd(int sock_fd, int fd);
-int receive_fd(int fd);
-
index 264fcdf..575554b 100644 (file)
@@ -17,6 +17,7 @@ void send_argument(int control_channel_fd, const char *source) {
         exit(1);
     }
 }
+
 int connect_socket() {
   int fd = socket( AF_UNIX, SOCK_STREAM, 0 );
   struct sockaddr_un addr;
@@ -27,44 +28,6 @@ int connect_socket() {
   return fd;
 }
 
-void do_umount( char *const argv[], int n, int fd ) {
-
-  // write the length
-  char buf[1024];
-  sprintf( buf, "%08x\n", n );
-  write( fd, buf, strlen(buf) );
-
-  // now write each arg
-  int i;
-  for( i = 0; i < n; i++ ) {
-    assert( strlen(argv[i]) < 1024 );
-    sprintf( buf, "%s\n", argv[i] );
-    write( fd, buf, strlen(buf) );
-  }
-
-  char inbuf[10];
-  int n2 = read( fd, inbuf, 10 );
-  inbuf[n2] = '\0';
-
-  int r = atoi(inbuf);
-
-}
-
-int umount2( const char *mnt, int flags ) {
-  int fd = connect_socket();
-
-  const char *argv[3];
-  argv[0] = "fusermount";
-  argv[1] = "-u";
-  argv[2] = mnt;
-
-  do_umount( (char **const) argv, 3, fd );
-
-  close(fd);
-}
-
 int get_magic_fd (char *data) {
     char *ptr;
     int fd;
@@ -85,6 +48,7 @@ int get_magic_fd (char *data) {
     else
         return -1;
 }
+
 int mount(const char *source, const char *target, const char *filesystemtype,
         unsigned long mountflags, const void *data) {
   int fd = connect_socket();
@@ -122,35 +86,3 @@ int mount(const char *source, const char *target, const char *filesystemtype,
   return 0;
 
 }
-
-int execv( const char *path, char *const argv[] ) {
-  int fd;
-
-  if( strstr( path, "fusermount" ) == NULL ) {
-    return execv( path, argv );
-  }
-
-  // also make sure this is an unmount . . .
-  int n = 0;
-  char *arg = argv[n];
-  int found_u = 0;
-  while( arg != NULL ) {
-    if( strcmp( arg, "-u" ) == 0 ) {
-      found_u = 1;
-      break;
-    }
-    arg = argv[++n];
-  }
-
-  if( !found_u ) {
-    return execv( path, argv );
-  }
-
-  // Have root do any fusermounts we need done
-  fd = connect_socket();
-
-  do_umount( argv, n, fd );
-  exit(0);
-
-}
-