diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2002-04-19 15:57:02 +0000 |
---|---|---|
committer | Miklos Szeredi <miklos@szeredi.hu> | 2002-04-19 15:57:02 +0000 |
commit | a4b0c77de08fca142ae22c74b3317930af404baa (patch) | |
tree | d5c189a997a77c8d50472206f45bf731e0c1568b /lib/helper.c | |
parent | 4b5006ae116b0e5eacd63bcf3556d5ab336950fe (diff) | |
download | libfuse-a4b0c77de08fca142ae22c74b3317930af404baa.tar.gz |
interface cleanup
Diffstat (limited to 'lib/helper.c')
-rw-r--r-- | lib/helper.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/lib/helper.c b/lib/helper.c index c7c48ae..ff59f4a 100644 --- a/lib/helper.c +++ b/lib/helper.c @@ -41,7 +41,7 @@ static void fuse_unmount() system(getenv(FUSE_UMOUNT_CMD_ENV)); } -static int fuse_mount(int *argcp, char **argv) +static int fuse_mount_obsolete(int *argcp, char **argv) { char *isreexec = getenv(FUSE_MOUNTED_ENV); @@ -111,9 +111,15 @@ int receive_fd(int fd) { return *(int*)CMSG_DATA(cmsg); } -int fuse_mount_ioslave(char *mountpoint) { +int fuse_mount(const char *mountpoint, const char *mount_args) +{ int fds[2], pid; + int rv, fd; char env[10]; + + /* FIXME: parse mount_args (or just pass it to fusermount ???) */ + mount_args = mount_args; + if(socketpair(PF_UNIX,SOCK_DGRAM,0,fds)) { fprintf(stderr,"fuse: failed to socketpair()\n"); return -1; @@ -125,22 +131,23 @@ int fuse_mount_ioslave(char *mountpoint) { close(fds[1]); return -1; } - if(pid) { - int rv, fd = fds[1]; - close(fds[0]); - while((rv = receive_fd(fd)) < 0) - sleep(1); - close(fd); - while(wait(NULL) != pid); /* bury zombie */ - return rv; + if(pid == 0) { + close(fds[1]); + fcntl(fds[0],F_SETFD,0); + snprintf(env,sizeof(env),"%i",fds[0]); + setenv("_FUSE_IOSLAVE_FD",env,1); + execlp("fusermount","fusermount",mountpoint,"fuse_ioslave",NULL); + fprintf(stderr,"fuse: failed to exec fusermount\n"); + exit(1); } - close(fds[1]); - fcntl(fds[0],F_SETFD,0); - snprintf(env,sizeof(env),"%i",fds[0]); - setenv("_FUSE_IOSLAVE_FD",env,1); - execlp("fusermount","fusermount",mountpoint,"fuse_ioslave",NULL); - fprintf(stderr,"fuse: failed to exec fusermount\n"); - exit(1); + + fd = fds[1]; + close(fds[0]); + while((rv = receive_fd(fd)) < 0) + sleep(1); + close(fd); + while(wait(NULL) != pid); /* bury zombie */ + return rv; } static void exit_handler() @@ -180,7 +187,7 @@ void fuse_main(int argc, char *argv[], const struct fuse_operations *op) int multithreaded; struct fuse *fuse; - fd = fuse_mount(&argc, argv); + fd = fuse_mount_obsolete(&argc, argv); if(fd == -1) exit(1); |