FreeBSD/usr.sbin/jail/jail.c
/*
 * Set a jail's parameters.
 */
Set a jail's parameters.
Set a jail ' s parameters .
static int
update_jail(struct cfjail *j)
{
	struct jailparam *jp, *setparams, *sjp;
	int ns, jid;
	ns = 0;
	for (jp = j->jp; jp < j->jp + j->njp; jp++)
		if (!JP_RDTUN(jp))
			ns++;
	if (ns == 0)
		return 0;
	sjp = setparams = alloca(++ns * sizeof(struct jailparam));
	if (jailparam_init(sjp, "jid") < 0 ||
	    jailparam_import_raw(sjp, &j->jid, sizeof j->jid) < 0) {
		jail_warnx(j, "%s", jail_errmsg);
		failed(j);
		return -1;
	}
	for (jp = j->jp; jp < j->jp + j->njp; jp++)
		if (!JP_RDTUN(jp))
			*++sjp = *jp;
	jid = jailparam_set_note(j, setparams, ns,
	    bool_param(j->intparams[IP_ALLOW_DYING])
	    ? JAIL_UPDATE | JAIL_DYING : JAIL_UPDATE);
	if (jid < 0) {
		jail_warnx(j, "%s", jail_errmsg);
		failed(j);
	}
	jailparam_free(setparams, 1);
	return jid;
}
static int update_jail ( struct cfjail * j ) { struct jailparam * jp , * setparams , * sjp ; int ns , jid ; ns = 0 ; for ( jp = j -> jp ; jp < j -> jp + j -> njp ; jp ++ ) if ( ! JP_RDTUN ( jp ) ) ns ++ ; if ( ns == 0 ) return 0 ; sjp = setparams = alloca ( ++ ns * sizeof ( struct jailparam ) ) ; if ( jailparam_init ( sjp , " " ) < 0 || jailparam_import_raw ( sjp , & j -> jid , sizeof j -> jid ) < 0 ) { jail_warnx ( j , " " , jail_errmsg ) ; failed ( j ) ; return -1 ; } for ( jp = j -> jp ; jp < j -> jp + j -> njp ; jp ++ ) if ( ! JP_RDTUN ( jp ) ) * ++ sjp = * jp ; jid = jailparam_set_note ( j , setparams , ns , bool_param ( j -> intparams [ IP_ALLOW_DYING ] ) ? JAIL_UPDATE | JAIL_DYING : JAIL_UPDATE ) ; if ( jid < 0 ) { jail_warnx ( j , " " , jail_errmsg ) ; failed ( j ) ; } jailparam_free ( setparams , 1 ) ; return jid ; }
Set a jail's parameters.
Set a jail ' s parameters .