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

Function chglimit

freebsd/kern/kern_resource.c:1491–1506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1489#endif
1490
1491static inline int
1492chglimit(struct uidinfo *uip, long *limit, int diff, rlim_t max, const char *name)
1493{
1494 long new;
1495
1496 /* Don't allow them to exceed max, but allow subtraction. */
1497 new = atomic_fetchadd_long(limit, (long)diff) + diff;
1498 if (diff > 0 && max != 0) {
1499 if (new < 0 || new > max) {
1500 atomic_subtract_long(limit, (long)diff);
1501 return (0);
1502 }
1503 } else if (new < 0)
1504 printf("negative %s for uid = %d\n", name, uip->ui_uid);
1505 return (1);
1506}
1507
1508/*
1509 * Change the count associated with number of processes

Callers 5

chgproccntFunction · 0.70
chgsbsizeFunction · 0.70
chgptscntFunction · 0.70
chgkqcntFunction · 0.70
chgumtxcntFunction · 0.70

Calls 3

atomic_subtract_longFunction · 0.85
printfFunction · 0.70
atomic_fetchadd_longFunction · 0.50

Tested by

no test coverage detected