Exemplo n.º 1
0
static const char *
swap_on_off(const char *name, int doingall, char *mntops)
{
	char base[PATH_MAX];

	/* Swap on vnode-backed md(4) device. */
	if (mntops != NULL &&
	    (fnmatch(_PATH_DEV MD_NAME "[0-9]*", name, 0) == 0 ||
	     fnmatch(MD_NAME "[0-9]*", name, 0) == 0 ||
	     strncmp(_PATH_DEV MD_NAME, name,
		sizeof(_PATH_DEV) + sizeof(MD_NAME)) == 0 ||
	     strncmp(MD_NAME, name, sizeof(MD_NAME)) == 0))
		return (swap_on_off_md(name, mntops, doingall));

	basename_r(name, base);

	/* Swap on encrypted device by GEOM_BDE. */
	if (fnmatch("*.bde", base, 0) == 0)
		return (swap_on_off_gbde(name, doingall));

	/* Swap on encrypted device by GEOM_ELI. */
	if (fnmatch("*.eli", base, 0) == 0)
		return (swap_on_off_geli(name, mntops, doingall));

	/* Swap on special file. */
	return (swap_on_off_sfile(name, doingall));
}
Exemplo n.º 2
0
static const char *
swap_on_off( const char *name, int doingall, char *mntops ) {
	char base[PATH_MAX];
	
	if ( mntops != NULL &&
	(fnmatch(_PATH_DEV MD_NAME "[0-9]*", name, 0) == 0 ||
			fnmatch(MD_NAME "[0-9]*", name, 0) == 0 ||
			strncmp(_PATH_DEV MD_NAME, name,
					sizeof(_PATH_DEV) + sizeof(MD_NAME)) == 0 ||
			strncmp(MD_NAME, name, sizeof(MD_NAME)) == 0) ) return ( swap_on_off_md( name, mntops, doingall ) );
	
	basename_r( name, base );
	
	if ( fnmatch( "*.bde", base, 0 ) == 0 ) return ( swap_on_off_gbde( name, doingall ) );
	
	if ( fnmatch( "*.eli", base, 0 ) == 0 ) return ( swap_on_off_geli( name, mntops, doingall ) );
	
	return ( swap_on_off_sfile( name, doingall ) );
}