View | Details | Raw Unified | Return to bug 207386 | Differences between
and this patch

Collapse All | Expand All

(-)b/sys/compat/linprocfs/linprocfs.c (-42 / +68 lines)
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 *cpl;
1405
	struct plimit *cur_proc_lim;
1402
	struct rlimit rl;
1406
1403
	ssize_t size;
1407
	cur_proc_lim = lim_alloc();
1404
	int res, error;
1408
	lim_copy(cur_proc_lim, p->p_limit);
1405
1409
	sbuf_printf(sb, "%-26s%-21s%-21s%-10s\n", "Limit", "Soft Limit",
1406
	size = sizeof(res);
1407
	cpl = lim_alloc();
1408
	lim_copy(cpl, p->p_limit);
1409
	sbuf_printf(sb, "%-26s%-21s%-21s%-21s\n", "Limit", "Soft Limit",
1410
			"Hard Limit", "Units");
1410
			"Hard Limit", "Units");
1411
	for (li = limits_info; li->desc != NULL; ++li) {
1411
	for (li = linux_rlimits_ident; li->desc != NULL; ++li) {
1412
		if (li->rlim_id != RLIM_INFINITY && li->rlim_id != RLIM_NONE)
1412
		switch (li->rlim_id)
1413
			li_rlimits = cur_proc_lim->pl_rlimit[li->rlim_id];
1413
		{
1414
		else {
1414
		case LINUX_RLIMIT_LOCKS:
1415
			li_rlimits.rlim_cur = 0;
1415
			/* FALLTHROUGH */
1416
			li_rlimits.rlim_max = 0;
1416
		case LINUX_RLIMIT_RTTIME:
1417
			rl.rlim_cur = RLIM_INFINITY;
1418
			break;
1419
		case LINUX_RLIMIT_SIGPENDING:
1420
			error = kernel_sysctlbyname(td,
1421
			    "kern.sigqueue.max_pending_per_proc",
1422
			    &res, &size, 0, 0, 0, 0);
1423
			if (error != 0)
1424
				break;
1425
			rl.rlim_cur = res;
1426
			rl.rlim_max = res;
1427
			break;
1428
		case LINUX_RLIMIT_MSGQUEUE:
1429
			error = kernel_sysctlbyname(td,
1430
			    "kern.ipc.msgmnb", &res, &size, 0, 0, 0, 0);
1431
			if (error != 0)
1432
				break;
1433
			rl.rlim_cur = res;
1434
			rl.rlim_max = res;
1435
			break;
1436
		case LINUX_RLIMIT_NICE:
1437
			/* FALLTHROUGH */
1438
		case LINUX_RLIMIT_RTPRIO:
1439
			rl.rlim_cur = 0;
1440
			rl.rlim_max = 0;
1441
			break;
1442
		default:
1443
			rl = cpl->pl_rlimit[li->rlim_id];
1444
			break;
1417
		}
1445
		}
1418
		if (li->rlim_id == RLIM_INFINITY ||
1446
		if (rl.rlim_cur == RLIM_INFINITY)
1419
		    li_rlimits.rlim_cur == RLIM_INFINITY)
1420
			sbuf_printf(sb, "%-26s%-21s%-21s%-10s\n",
1447
			sbuf_printf(sb, "%-26s%-21s%-21s%-10s\n",
1421
			    li->desc, "unlimited", "unlimited", li->unit);
1448
			    li->desc, "unlimited", "unlimited", li->unit);
1422
		else
1449
		else
1423
			sbuf_printf(sb, "%-26s%-21ld%-21ld%-10s\n",
1450
			sbuf_printf(sb, "%-26s%-21ld%-21ld%-10s\n",
1424
			    li->desc, (long)li_rlimits.rlim_cur,
1451
			    li->desc, (long)rl.rlim_cur,
1425
			    (long)li_rlimits.rlim_max, li->unit);
1452
			    (long)rl.rlim_max, li->unit);
1426
	}
1453
	}
1427
	lim_free(cur_proc_lim);
1454
	lim_free(cpl);
1428
	return (0);
1455
	return (error);
1429
}
1456
}
1430
1457
1431
1432
/*
1458
/*
1433
 * Filler function for proc/sys/kernel/random/uuid
1459
 * Filler function for proc/sys/kernel/random/uuid
1434
 */
1460
 */
(-)b/sys/compat/linux/linux_misc.h (+7 lines)
Lines 150-155 extern int stclohz; Link Here
150
#define	LINUX_P_PID		1
150
#define	LINUX_P_PID		1
151
#define	LINUX_P_PGID		2
151
#define	LINUX_P_PGID		2
152
152
153
#define	LINUX_RLIMIT_LOCKS	RLIM_NLIMITS + 1
154
#define	LINUX_RLIMIT_SIGPENDING	RLIM_NLIMITS + 2
155
#define	LINUX_RLIMIT_MSGQUEUE	RLIM_NLIMITS + 3
156
#define	LINUX_RLIMIT_NICE	RLIM_NLIMITS + 4
157
#define	LINUX_RLIMIT_RTPRIO	RLIM_NLIMITS + 5
158
#define	LINUX_RLIMIT_RTTIME	RLIM_NLIMITS + 6
159
153
#define	LINUX_RLIM_INFINITY	(~0UL)
160
#define	LINUX_RLIM_INFINITY	(~0UL)
154
161
155
int linux_common_wait(struct thread *td, int pid, int *status,
162
int linux_common_wait(struct thread *td, int pid, int *status,

Return to bug 207386