int zfsslash2_init(void) { struct pscfs_args args = PSCFS_ARGS_INIT(0, NULL); extern struct fuse_lowlevel_ops pscfs_fuse_ops; extern struct fuse_session *fuse_session; extern struct pollfd pflfs_fds[]; extern int newfs_fd[2], pflfs_nfds; extern char *fuse_mount_options; int rc; if (pfl_systemf("umount %s", _PATH_KSTAT) == -1) psclog_warn("umount %s", _PATH_KSTAT); if (pipe(newfs_fd) == -1) psc_fatal("pipe"); pflfs_fds[0].fd = newfs_fd[0]; pflfs_fds[0].events = POLLIN; pflfs_nfds = 1; fuse_session = fuse_lowlevel_new(&args.pfa_av, &pscfs_fuse_ops, sizeof(pscfs_fuse_ops), NULL); pscthr_init(SLMTHRT_ZFS_KSTAT, slmzfskstatmthr_main, 0, "slmzfskstatmthr"); fuse_mount_options = ""; rc = libzfs_init_fusesocket(); if (rc == 0) rc = libzfs_init(); atexit(slm_unmount_kstat); return (rc); }
int zfsslash2_init(void) { struct pscfs_args args = PSCFS_ARGS_INIT(0, NULL); extern struct fuse_lowlevel_ops pscfs_fuse_ops; extern struct fuse_session *fuse_session; extern struct pollfd pscfs_fds[]; extern int newfs_fd[2], pscfs_nfds; extern char *fuse_mount_options; char buf[BUFSIZ]; int rc; rc = snprintf(buf, sizeof(buf), "umount %s", _PATH_KSTAT); if (rc == -1) psc_fatal("snprintf: umount %s", _PATH_KSTAT); if (rc >= (int)sizeof(buf)) psc_fatalx("snprintf: umount %s: too long", _PATH_KSTAT); if (system(buf) == -1) psclog_warn("system(%s)", buf); if (pipe(newfs_fd) == -1) psc_fatal("pipe"); pscfs_fds[0].fd = newfs_fd[0]; pscfs_fds[0].events = POLLIN; pscfs_nfds = 1; fuse_session = fuse_lowlevel_new(&args.pfa_av, &pscfs_fuse_ops, sizeof(pscfs_fuse_ops), NULL); pscthr_init(SLMTHRT_ZFS_KSTAT, slmzfskstatmthr_main, NULL, 0, "slmzfskstatmthr"); fuse_mount_options = ""; rc = libzfs_init_fusesocket(); if (rc == 0) rc = libzfs_init(); atexit(slm_unmount_kstat); return (rc); }
int main(int argc, char *argv[]) { char c, *p, *noncanon_mp, *cmd, *path_env, dir[PATH_MAX]; struct pscfs_args args = PSCFS_ARGS_INIT(0, NULL); struct psc_dynarray startup_cmds = DYNARRAY_INIT; const char *progpath = argv[0]; int rc, i, unmount_first = 0; pfl_init(); pscfs_addarg(&args, ""); /* progname/argv[0] */ pscfs_addarg(&args, "-o"); pscfs_addarg(&args, STD_MOUNT_OPTIONS); p = getenv("CTL_SOCK_FILE"); if (p) ctlsockfn = p; while ((c = getopt(argc, argv, "dL:o:S:U")) != -1) switch (c) { case 'd': pscfs_addarg(&args, "-odebug"); break; case 'L': psc_dynarray_add(&startup_cmds, optarg); break; case 'o': if (!opt_lookup(optarg)) { pscfs_addarg(&args, "-o"); pscfs_addarg(&args, optarg); } break; case 'S': ctlsockfn = optarg; break; case 'U': unmount_first = 1; break; default: usage(); } argc -= optind; argv += optind; if (argc != 1) usage(); pscthr_init(PFL_THRT_FSMGR, NULL, 0, "fsmgrthr"); noncanon_mp = argv[0]; if (unmount_first) unmount(noncanon_mp); /* canonicalize mount path */ if (realpath(noncanon_mp, mountpoint) == NULL) psc_fatal("realpath %s", noncanon_mp); pscfs_mount(mountpoint, &args); pscfs_freeargs(&args); ctlthr_spawn(); pfl_opstimerthr_spawn(PFL_THRT_OPSTIMER, "opstimerthr"); pfl_workq_init(128, 1024, 1024); pfl_wkthr_spawn(PFL_THRT_WORKER, 4, 0, "wkthr%d"); pscfs_entry_timeout = 8.; pscfs_attr_timeout = 8.; /* * Here, $p = (directory this daemon binary resides in). * Now we add the following to $PATH: * * 1) $p * 2) $p/../wokctl (for developers) */ pfl_dirname(progpath, dir); p = getenv("PATH"); rc = pfl_asprintf(&path_env, "%s:%s/../wokctl%s%s", dir, dir, p ? ":" : "", p ? p : ""); psc_assert(rc != -1); setenv("PATH", path_env, 1); /* * If wokctl (see file wokctl.c) misbehaves because it is given * a wrong arugment, it is hard to debug from our end because * we won't be receiving anything useful via the socket. This * should be changed to a native call someday. * * If the client does not come up, double/triple checkout * the name of your slash2 shared library. I wish I can * add more verbose debugging information. */ DYNARRAY_FOREACH(cmd, i, &startup_cmds) pfl_systemf("wokctl -S %s %s", ctlsockfn, cmd); exit(pscfs_main(32, "")); }