示例#1
0
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, ""));
}
示例#2
0
void
slmzfskstatmthr_main(__unusedx struct psc_thread *thr)
{
	pscfs_main(4, "slmzk");
}