extern "C" {
#endif
+/*
+ * Create a FUSE mountpoint
+ *
+ * Returns a control file descriptor suitable for passing to
+ * fuse_new()
+ *
+ * @param mountpoint the mount point path
+ * @param mount arguments (passed to the fusermount program)
+ * @return the control file descriptor on success, -1 on failure
+ */
+int fuse_mount(const char *mountpoint, const char *mount_args);
+
/**
* Create a new FUSE filesystem.
*
*/
void fuse_main(int argc, char *argv[], const struct fuse_operations *op);
-/*
- * Spawn an I/O slave, creating an fd suitable for passing to fuse_new()
- *
- * This spawns fusermount, and then a small message tosser process to
- * allow access to fuse_new() and fuse_loop() without the limitations
- * of reexecuting the main FUSE process and destroying stdin.
- *
- * @param mountpoint a char pointer to the requested mountpoint
- */
-int fuse_mount_ioslave(char *mountpoint);
-
/* ----------------------------------------------------------- *
* Advanced API for event handling, don't worry about this... *
* ----------------------------------------------------------- */
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);
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;
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()
int multithreaded;
struct fuse *fuse;
- fd = fuse_mount(&argc, argv);
+ fd = fuse_mount_obsolete(&argc, argv);
if(fd == -1)
exit(1);