|
Lines 1370-1434
linprocfs_dofdescfs(PFS_FILL_ARGS)
Link Here
|
| 1370 |
/* |
1370 |
/* |
| 1371 |
* Filler function for proc/pid/limits |
1371 |
* Filler function for proc/pid/limits |
| 1372 |
*/ |
1372 |
*/ |
| 1373 |
|
1373 |
static const struct linux_rlimit_ident { |
| 1374 |
#define RLIM_NONE -1 |
|
|
| 1375 |
|
| 1376 |
static const struct limit_info { |
| 1377 |
const char *desc; |
1374 |
const char *desc; |
| 1378 |
const char *unit; |
1375 |
const char *unit; |
| 1379 |
unsigned long long rlim_id; |
1376 |
unsigned int rlim_id; |
| 1380 |
} limits_info[] = { |
1377 |
} linux_rlimits_ident[] = { |
| 1381 |
{ "Max cpu time", "seconds", RLIMIT_CPU }, |
1378 |
{ "Max cpu time", "seconds", RLIMIT_CPU }, |
| 1382 |
{ "Max file size", "bytes", RLIMIT_FSIZE }, |
1379 |
{ "Max file size", "bytes", RLIMIT_FSIZE }, |
| 1383 |
{ "Max data size", "bytes", RLIMIT_DATA }, |
1380 |
{ "Max data size", "bytes", RLIMIT_DATA }, |
| 1384 |
{ "Max stack size", "bytes", RLIMIT_STACK }, |
1381 |
{ "Max stack size", "bytes", RLIMIT_STACK }, |
| 1385 |
{ "Max core file size", "bytes", RLIMIT_CORE }, |
1382 |
{ "Max core file size", "bytes", RLIMIT_CORE }, |
| 1386 |
{ "Max resident set", "bytes", RLIMIT_RSS }, |
1383 |
{ "Max resident set", "bytes", RLIMIT_RSS }, |
| 1387 |
{ "Max processes", "processes", RLIMIT_NPROC }, |
1384 |
{ "Max processes", "processes", RLIMIT_NPROC }, |
| 1388 |
{ "Max open files", "files", RLIMIT_NOFILE }, |
1385 |
{ "Max open files", "files", RLIMIT_NOFILE }, |
| 1389 |
{ "Max locked memory", "bytes", RLIMIT_MEMLOCK }, |
1386 |
{ "Max locked memory", "bytes", RLIMIT_MEMLOCK }, |
| 1390 |
{ "Max address space", "bytes", RLIMIT_AS }, |
1387 |
{ "Max address space", "bytes", RLIMIT_AS }, |
| 1391 |
{ "Max file locks", "locks", RLIM_INFINITY }, |
1388 |
{ "Max file locks", "locks", LINUX_RLIMIT_LOCKS }, |
| 1392 |
{ "Max pending signals", "signals", RLIM_INFINITY }, |
1389 |
{ "Max pending signals", "signals", LINUX_RLIMIT_SIGPENDING }, |
| 1393 |
{ "Max msgqueue size", "bytes", RLIM_NONE }, |
1390 |
{ "Max msgqueue size", "bytes", LINUX_RLIMIT_MSGQUEUE }, |
| 1394 |
{ "Max nice priority", "", RLIM_NONE }, |
1391 |
{ "Max nice priority", "", LINUX_RLIMIT_NICE }, |
| 1395 |
{ "Max realtime priority", "", RLIM_NONE }, |
1392 |
{ "Max realtime priority", "", LINUX_RLIMIT_RTPRIO }, |
| 1396 |
{ "Max realtime timeout", "us", RLIM_INFINITY }, |
1393 |
{ "Max realtime timeout", "us", LINUX_RLIMIT_RTTIME }, |
| 1397 |
{ 0, 0, 0 } |
1394 |
{ 0, 0, 0 } |
| 1398 |
}; |
1395 |
}; |
| 1399 |
|
1396 |
|
| 1400 |
static int |
1397 |
static int |
| 1401 |
linprocfs_doproclimits(PFS_FILL_ARGS) |
1398 |
linprocfs_doproclimits(PFS_FILL_ARGS) |
| 1402 |
{ |
1399 |
{ |
| 1403 |
const struct limit_info *li; |
1400 |
const struct linux_rlimit_ident *li; |
| 1404 |
struct rlimit li_rlimits; |
1401 |
struct plimit *pl; |
| 1405 |
struct plimit *cur_proc_lim; |
1402 |
struct rlimit rl; |
|
|
1403 |
ssize_t size; |
| 1404 |
int res, error; |
| 1406 |
|
1405 |
|
| 1407 |
cur_proc_lim = lim_alloc(); |
1406 |
PROC_LOCK(p); |
| 1408 |
lim_copy(cur_proc_lim, p->p_limit); |
1407 |
pl = lim_hold(p->p_limit); |
| 1409 |
sbuf_printf(sb, "%-26s%-21s%-21s%-10s\n", "Limit", "Soft Limit", |
1408 |
PROC_UNLOCK(p); |
|
|
1409 |
size = sizeof(res); |
| 1410 |
sbuf_printf(sb, "%-26s%-21s%-21s%-21s\n", "Limit", "Soft Limit", |
| 1410 |
"Hard Limit", "Units"); |
1411 |
"Hard Limit", "Units"); |
| 1411 |
for (li = limits_info; li->desc != NULL; ++li) { |
1412 |
for (li = linux_rlimits_ident; li->desc != NULL; ++li) { |
| 1412 |
if (li->rlim_id != RLIM_INFINITY && li->rlim_id != RLIM_NONE) |
1413 |
switch (li->rlim_id) |
| 1413 |
li_rlimits = cur_proc_lim->pl_rlimit[li->rlim_id]; |
1414 |
{ |
| 1414 |
else { |
1415 |
case LINUX_RLIMIT_LOCKS: |
| 1415 |
li_rlimits.rlim_cur = 0; |
1416 |
/* FALLTHROUGH */ |
| 1416 |
li_rlimits.rlim_max = 0; |
1417 |
case LINUX_RLIMIT_RTTIME: |
|
|
1418 |
rl.rlim_cur = RLIM_INFINITY; |
| 1419 |
break; |
| 1420 |
case LINUX_RLIMIT_SIGPENDING: |
| 1421 |
error = kernel_sysctlbyname(td, |
| 1422 |
"kern.sigqueue.max_pending_per_proc", |
| 1423 |
&res, &size, 0, 0, 0, 0); |
| 1424 |
if (error != 0) |
| 1425 |
break; |
| 1426 |
rl.rlim_cur = res; |
| 1427 |
rl.rlim_max = res; |
| 1428 |
break; |
| 1429 |
case LINUX_RLIMIT_MSGQUEUE: |
| 1430 |
error = kernel_sysctlbyname(td, |
| 1431 |
"kern.ipc.msgmnb", &res, &size, 0, 0, 0, 0); |
| 1432 |
if (error != 0) |
| 1433 |
break; |
| 1434 |
rl.rlim_cur = res; |
| 1435 |
rl.rlim_max = res; |
| 1436 |
break; |
| 1437 |
case LINUX_RLIMIT_NICE: |
| 1438 |
/* FALLTHROUGH */ |
| 1439 |
case LINUX_RLIMIT_RTPRIO: |
| 1440 |
rl.rlim_cur = 0; |
| 1441 |
rl.rlim_max = 0; |
| 1442 |
break; |
| 1443 |
default: |
| 1444 |
rl = pl->pl_rlimit[li->rlim_id]; |
| 1445 |
break; |
| 1417 |
} |
1446 |
} |
| 1418 |
if (li->rlim_id == RLIM_INFINITY || |
1447 |
if (rl.rlim_cur == RLIM_INFINITY) |
| 1419 |
li_rlimits.rlim_cur == RLIM_INFINITY) |
|
|
| 1420 |
sbuf_printf(sb, "%-26s%-21s%-21s%-10s\n", |
1448 |
sbuf_printf(sb, "%-26s%-21s%-21s%-10s\n", |
| 1421 |
li->desc, "unlimited", "unlimited", li->unit); |
1449 |
li->desc, "unlimited", "unlimited", li->unit); |
| 1422 |
else |
1450 |
else |
| 1423 |
sbuf_printf(sb, "%-26s%-21ld%-21ld%-10s\n", |
1451 |
sbuf_printf(sb, "%-26s%-21llu%-21llu%-10s\n", |
| 1424 |
li->desc, (long)li_rlimits.rlim_cur, |
1452 |
li->desc, (unsigned long long)rl.rlim_cur, |
| 1425 |
(long)li_rlimits.rlim_max, li->unit); |
1453 |
(unsigned long long)rl.rlim_max, li->unit); |
| 1426 |
} |
1454 |
} |
| 1427 |
lim_free(cur_proc_lim); |
1455 |
lim_free(pl); |
| 1428 |
return (0); |
1456 |
return (error); |
| 1429 |
} |
1457 |
} |
| 1430 |
|
1458 |
|
| 1431 |
|
|
|
| 1432 |
/* |
1459 |
/* |
| 1433 |
* Filler function for proc/sys/kernel/random/uuid |
1460 |
* Filler function for proc/sys/kernel/random/uuid |
| 1434 |
*/ |
1461 |
*/ |