コード例 #1
0
ファイル: pseudofs.c プロジェクト: edgar-pek/PerspicuOS
/*
 * Initialize a pseudofs instance
 */
int
pfs_init(struct pfs_info *pi, struct vfsconf *vfc)
{
	struct pfs_node *root;
	int error;

	mtx_assert(&Giant, MA_OWNED);

	pfs_fileno_init(pi);

	/* set up the root diretory */
	root = pfs_alloc_node(pi, "/", pfstype_root);
	pi->pi_root = root;
	pfs_fileno_alloc(root);
	pfs_fixup_dir(root);

	/* construct file hierarchy */
	error = (pi->pi_init)(pi, vfc);
	if (error) {
		pfs_destroy(root);
		pi->pi_root = NULL;
		return (error);
	}

	if (bootverbose)
		printf("%s registered\n", pi->pi_name);
	return (0);
}
コード例 #2
0
ファイル: pseudofs.c プロジェクト: derekmarcotte/freebsd
/*
 * Destroy a pseudofs instance
 */
int
pfs_uninit(struct pfs_info *pi, struct vfsconf *vfc)
{
	int error;

	pfs_destroy(pi->pi_root);
	pi->pi_root = NULL;
	pfs_fileno_uninit(pi);
	if (bootverbose)
		printf("%s unregistered\n", pi->pi_name);
	error = (pi->pi_uninit)(pi, vfc);
	return (error);
}
コード例 #3
0
ファイル: pseudofs.c プロジェクト: edgar-pek/PerspicuOS
/*
 * Destroy a node and all its descendants.  If the node to be destroyed
 * has a parent, the parent's mutex must be held.
 */
int
pfs_destroy(struct pfs_node *pn)
{
	struct pfs_node *iter;

	KASSERT(pn != NULL,
	    ("%s(): node is NULL", __func__));
	KASSERT(pn->pn_info != NULL,
	    ("%s(): node has no pn_info", __func__));

	if (pn->pn_parent)
		pfs_detach_node(pn);

	/* destroy children */
	if (pn->pn_type == pfstype_dir ||
	    pn->pn_type == pfstype_procdir ||
	    pn->pn_type == pfstype_root) {
		pfs_lock(pn);
		while (pn->pn_nodes != NULL) {
			iter = pn->pn_nodes;
			pn->pn_nodes = iter->pn_next;
			iter->pn_parent = NULL;
			pfs_unlock(pn);
			pfs_destroy(iter);
			pfs_lock(pn);
		}
		pfs_unlock(pn);
	}

	/* revoke vnodes and fileno */
	pfs_purge(pn);

	/* callback to free any private resources */
	if (pn->pn_destroy != NULL)
		pn_destroy(pn);

	/* destroy the node */
	pfs_fileno_free(pn);
	mtx_destroy(&pn->pn_mutex);
	free(pn, M_PFSNODES);

	return (0);
}
コード例 #4
0
ファイル: pfsd.c プロジェクト: spolu/pfs
int pfsd_destroy ()
{ 
  pfsd_updt_log (pfsd);
  pfsd_write_back_log (pfsd);

  printf ("sending signal to %d\n", pfsd->tun_pid);
  kill (pfsd->tun_pid, SIGTSTP);

  sleep (2);

  pfs_mutex_destroy (&pfsd->log_lock);
  pfs_mutex_destroy (&pfsd->updt_lock);
  pfs_mutex_destroy (&pfsd->sd_lock);

  pfs_destroy (pfsd->pfs);
  

  return 0;
}