MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rctl_rule_remove

Function rctl_rule_remove

freebsd/kern/kern_rctl.c:1435–1474  ·  view source on GitHub ↗

* Remove all rules that match the filter. */

Source from the content-addressed store, hash-verified

1433 * Remove all rules that match the filter.
1434 */
1435int
1436rctl_rule_remove(struct rctl_rule *filter)
1437{
1438 struct proc *p;
1439 int found = 0;
1440
1441 ASSERT_RACCT_ENABLED();
1442
1443 if (filter->rr_subject_type == RCTL_SUBJECT_TYPE_PROCESS &&
1444 filter->rr_subject.rs_proc != NULL) {
1445 p = filter->rr_subject.rs_proc;
1446 RACCT_LOCK();
1447 found = rctl_racct_remove_rules(p->p_racct, filter);
1448 RACCT_UNLOCK();
1449 if (found)
1450 return (0);
1451 return (ESRCH);
1452 }
1453
1454 loginclass_racct_foreach(rctl_rule_remove_callback,
1455 rctl_rule_pre_callback, rctl_rule_post_callback,
1456 filter, (void *)&found);
1457 ui_racct_foreach(rctl_rule_remove_callback,
1458 rctl_rule_pre_callback, rctl_rule_post_callback,
1459 filter, (void *)&found);
1460 prison_racct_foreach(rctl_rule_remove_callback,
1461 rctl_rule_pre_callback, rctl_rule_post_callback,
1462 filter, (void *)&found);
1463
1464 sx_assert(&allproc_lock, SA_LOCKED);
1465 RACCT_LOCK();
1466 FOREACH_PROC_IN_SYSTEM(p) {
1467 found += rctl_racct_remove_rules(p->p_racct, filter);
1468 }
1469 RACCT_UNLOCK();
1470
1471 if (found)
1472 return (0);
1473 return (ESRCH);
1474}
1475
1476/*
1477 * Appends a rule to the sbuf.

Callers 2

rctl_rule_addFunction · 0.85
sys_rctl_remove_ruleFunction · 0.85

Calls 4

rctl_racct_remove_rulesFunction · 0.85
loginclass_racct_foreachFunction · 0.85
ui_racct_foreachFunction · 0.85
prison_racct_foreachFunction · 0.85

Tested by

no test coverage detected