• Chris Wright's avatar
    [PATCH] consolidate arch specific resource.h headers · cf627bbf
    Chris Wright authored
    Most of the include/asm-*/resource.h headers are the same as one another.
    This patch makes one generic version, include/asm-generic/resource.h, and
    uses that when appropriate.  The only vaguely interesting things here are
    that the generic version introduces a new _STK_LIM_MAX macro, which can be
    populated by an arch (ia64 and parisc needed that).  Also, some arches hid
    RLIM_INFINITY under __KERNEL__, while others did not.  The generic version
    does not, so the following arches will see that change:
    
        arm, arm26, mips, ppc, ppc64, sh (and hence sh64)
    
    And, finally, some arches maintain their own order for the resource
    numbers.  This is now marked by __ARCH_RLIMIT_ORDER, and is used by the
    following arches:
    
        alpha, mips, sparc, and sparc64.
    
    This actually uncovered a mips bug (fix already sent, this patch is
    relative to that fix), where the default RLIMIT_MEMLOCK was set to
    RLIM_INFINITY and RLIMIT_NPROC set to MLOCK_LIMIT (the latter is no big
    deal because RLIMIT_NPROC default is overwritten dynamically during bootup
    in fork_init()).  Also, this change makes alpha's default for RLIMIT_NPROC
    change from RLIM_INFINITY to 0, but again...no problem as it's dynamically
    overwritten during bootup.
    
    The following arches are left untouched:
        m68knommu: untouched (uses m68k/resource.h)
        sh64: untouched (uses asm-sh/resource.h)
        um: untouched (uses arch code already)
    Signed-off-by: default avatarChris Wright <chrisw@osdl.org>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    cf627bbf
resource.h 1.86 KB
#ifndef _ASM_GENERIC_RESOURCE_H
#define _ASM_GENERIC_RESOURCE_H

/*
 * Resource limits
 */

/* Allow arch to control resource order */
#ifndef __ARCH_RLIMIT_ORDER
#define RLIMIT_CPU		0	/* CPU time in ms */
#define RLIMIT_FSIZE		1	/* Maximum filesize */
#define RLIMIT_DATA		2	/* max data size */
#define RLIMIT_STACK		3	/* max stack size */
#define RLIMIT_CORE		4	/* max core file size */
#define RLIMIT_RSS		5	/* max resident set size */
#define RLIMIT_NPROC		6	/* max number of processes */
#define RLIMIT_NOFILE		7	/* max number of open files */
#define RLIMIT_MEMLOCK		8	/* max locked-in-memory address space */
#define RLIMIT_AS		9	/* address space limit */
#define RLIMIT_LOCKS		10	/* maximum file locks held */
#define RLIMIT_SIGPENDING	11	/* max number of pending signals */
#define RLIMIT_MSGQUEUE		12	/* maximum bytes in POSIX mqueues */

#define RLIM_NLIMITS		13
#endif

/*
 * SuS says limits have to be unsigned.
 * Which makes a ton more sense anyway.
 */
#ifndef RLIM_INFINITY
#define RLIM_INFINITY	(~0UL)
#endif

#ifndef _STK_LIM_MAX
#define _STK_LIM_MAX	RLIM_INFINITY
#endif

#ifdef __KERNEL__

#define INIT_RLIMITS							\
{									\
	[RLIMIT_CPU]		= { RLIM_INFINITY, RLIM_INFINITY },	\
	[RLIMIT_FSIZE]		= { RLIM_INFINITY, RLIM_INFINITY },	\
	[RLIMIT_DATA]		= { RLIM_INFINITY, RLIM_INFINITY },	\
	[RLIMIT_STACK]		= {      _STK_LIM, _STK_LIM_MAX  },	\
	[RLIMIT_CORE]		= {             0, RLIM_INFINITY },	\
	[RLIMIT_RSS]		= { RLIM_INFINITY, RLIM_INFINITY },	\
	[RLIMIT_NPROC]		= {             0,             0 },	\
	[RLIMIT_NOFILE]		= {      INR_OPEN,     INR_OPEN  },	\
	[RLIMIT_MEMLOCK]	= {   MLOCK_LIMIT,   MLOCK_LIMIT },	\
	[RLIMIT_AS]		= { RLIM_INFINITY, RLIM_INFINITY },	\
	[RLIMIT_LOCKS]		= { RLIM_INFINITY, RLIM_INFINITY },	\
	[RLIMIT_SIGPENDING]	= { MAX_SIGPENDING, MAX_SIGPENDING },	\
	[RLIMIT_MSGQUEUE]	= { MQ_BYTES_MAX, MQ_BYTES_MAX },	\
}

#endif	/* __KERNEL__ */

#endif