Stub for setrlimit
Change-Id: I54c7233d71805711bd72e1e751456aad30fd3e35
This commit is contained in:
		
							parent
							
								
									e39e890e08
								
							
						
					
					
						commit
						ac5b3e53d8
					
				| @ -374,13 +374,10 @@ sig_cleanup(int which_sig) | |||||||
| static int | static int | ||||||
| gen_init(void) | gen_init(void) | ||||||
| { | { | ||||||
| #if !defined(__minix) |  | ||||||
| 	struct rlimit reslimit; | 	struct rlimit reslimit; | ||||||
| #endif /* !defined(__minix) */ |  | ||||||
| 	struct sigaction n_hand; | 	struct sigaction n_hand; | ||||||
| 	struct sigaction o_hand; | 	struct sigaction o_hand; | ||||||
| 
 | 
 | ||||||
| #if !defined(__minix) |  | ||||||
| 	/*
 | 	/*
 | ||||||
| 	 * Really needed to handle large archives. We can run out of memory for | 	 * Really needed to handle large archives. We can run out of memory for | ||||||
| 	 * internal tables really fast when we have a whole lot of files... | 	 * internal tables really fast when we have a whole lot of files... | ||||||
| @ -416,7 +413,6 @@ gen_init(void) | |||||||
| 		(void)setrlimit(RLIMIT_RSS , &reslimit); | 		(void)setrlimit(RLIMIT_RSS , &reslimit); | ||||||
| 	} | 	} | ||||||
| #endif | #endif | ||||||
| #endif /* !defined(__minix) */ |  | ||||||
| 
 | 
 | ||||||
| 	/*
 | 	/*
 | ||||||
| 	 * Handle posix locale | 	 * Handle posix locale | ||||||
|  | |||||||
| @ -22,7 +22,7 @@ SRCS+= 	accept.c access.c adjtime.c bind.c brk.c sbrk.c m_closefrom.c getsid.c \ | |||||||
| 	sync.c syscall.c sysuname.c truncate.c umask.c unlink.c write.c \ | 	sync.c syscall.c sysuname.c truncate.c umask.c unlink.c write.c \ | ||||||
| 	utimensat.c utimes.c futimes.c lutimes.c futimens.c \ | 	utimensat.c utimes.c futimes.c lutimes.c futimens.c \ | ||||||
| 	_exit.c _ucontext.c environ.c __getcwd.c vfork.c sizeup.c init.c \ | 	_exit.c _ucontext.c environ.c __getcwd.c vfork.c sizeup.c init.c \ | ||||||
| 	getrusage.c | 	getrusage.c setrlimit.c | ||||||
| 
 | 
 | ||||||
| # Minix specific syscalls / utils.
 | # Minix specific syscalls / utils.
 | ||||||
| SRCS+= cprofile.c sprofile.c stack_utils.c _mcontext.c | SRCS+= cprofile.c sprofile.c stack_utils.c _mcontext.c | ||||||
|  | |||||||
| @ -20,12 +20,18 @@ int getrlimit(int resource, struct rlimit *rlp) | |||||||
| 	 | 	 | ||||||
| 	switch (resource) | 	switch (resource) | ||||||
| 	{ | 	{ | ||||||
| 		case RLIMIT_CORE: |  | ||||||
| 		case RLIMIT_CPU: | 		case RLIMIT_CPU: | ||||||
| 		case RLIMIT_DATA: |  | ||||||
| 		case RLIMIT_FSIZE: | 		case RLIMIT_FSIZE: | ||||||
|  | 		case RLIMIT_DATA: | ||||||
| 		case RLIMIT_STACK: | 		case RLIMIT_STACK: | ||||||
|  | 		case RLIMIT_CORE: | ||||||
|  | 		case RLIMIT_RSS: | ||||||
|  | 		case RLIMIT_MEMLOCK: | ||||||
|  | 		case RLIMIT_NPROC: | ||||||
|  | 		case RLIMIT_SBSIZE: | ||||||
| 		case RLIMIT_AS: | 		case RLIMIT_AS: | ||||||
|  | 		/* case RLIMIT_VMEM: Same as RLIMIT_AS */ | ||||||
|  | 		case RLIMIT_NTHR: | ||||||
| 			/* no limit enforced (however architectural limits 
 | 			/* no limit enforced (however architectural limits 
 | ||||||
| 			 * may apply)  | 			 * may apply)  | ||||||
| 			 */	 | 			 */	 | ||||||
|  | |||||||
							
								
								
									
										38
									
								
								lib/libc/sys-minix/setrlimit.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								lib/libc/sys-minix/setrlimit.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | |||||||
|  | #include <sys/cdefs.h> | ||||||
|  | #include "namespace.h" | ||||||
|  | 
 | ||||||
|  | #include <errno.h> | ||||||
|  | #include <limits.h> | ||||||
|  | #include <sys/resource.h> | ||||||
|  | #include <unistd.h> | ||||||
|  | 
 | ||||||
|  | /* Simple stub for now. */ | ||||||
|  | int setrlimit(int resource, const struct rlimit *rlp) | ||||||
|  | { | ||||||
|  | 	rlim_t limit; | ||||||
|  | 	 | ||||||
|  | 	switch (resource) | ||||||
|  | 	{ | ||||||
|  | 		case RLIMIT_CPU: | ||||||
|  | 		case RLIMIT_FSIZE: | ||||||
|  | 		case RLIMIT_DATA: | ||||||
|  | 		case RLIMIT_STACK: | ||||||
|  | 		case RLIMIT_CORE: | ||||||
|  | 		case RLIMIT_RSS: | ||||||
|  | 		case RLIMIT_MEMLOCK: | ||||||
|  | 		case RLIMIT_NPROC: | ||||||
|  | 		case RLIMIT_NOFILE: | ||||||
|  | 		case RLIMIT_SBSIZE: | ||||||
|  | 		case RLIMIT_AS: | ||||||
|  | 		/* case RLIMIT_VMEM: Same as RLIMIT_AS */ | ||||||
|  | 		case RLIMIT_NTHR: | ||||||
|  | 			break; | ||||||
|  | 
 | ||||||
|  | 		default: | ||||||
|  | 			errno = EINVAL; | ||||||
|  | 			return -1; | ||||||
|  | 	}		 | ||||||
|  | 
 | ||||||
|  | 	return 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| @ -417,17 +417,13 @@ static struct { | |||||||
| 	{ RLIMIT_FSIZE,		R_CSIZE, "filesize", }, | 	{ RLIMIT_FSIZE,		R_CSIZE, "filesize", }, | ||||||
| 	{ RLIMIT_DATA,		R_CSIZE, "datasize", }, | 	{ RLIMIT_DATA,		R_CSIZE, "datasize", }, | ||||||
| 	{ RLIMIT_STACK,		R_CSIZE, "stacksize", }, | 	{ RLIMIT_STACK,		R_CSIZE, "stacksize", }, | ||||||
| #if !defined(__minix) |  | ||||||
| 	{ RLIMIT_RSS,		R_CSIZE, "memoryuse", }, | 	{ RLIMIT_RSS,		R_CSIZE, "memoryuse", }, | ||||||
| 	{ RLIMIT_MEMLOCK,	R_CSIZE, "memorylocked", }, | 	{ RLIMIT_MEMLOCK,	R_CSIZE, "memorylocked", }, | ||||||
| 	{ RLIMIT_NPROC,		R_CNUMB, "maxproc", }, | 	{ RLIMIT_NPROC,		R_CNUMB, "maxproc", }, | ||||||
| 	{ RLIMIT_NTHR,		R_CNUMB, "maxthread", }, | 	{ RLIMIT_NTHR,		R_CNUMB, "maxthread", }, | ||||||
| #endif /* !defined(__minix) */ |  | ||||||
| 	{ RLIMIT_NOFILE,	R_CNUMB, "openfiles", }, | 	{ RLIMIT_NOFILE,	R_CNUMB, "openfiles", }, | ||||||
| 	{ RLIMIT_CORE,		R_CSIZE, "coredumpsize", }, | 	{ RLIMIT_CORE,		R_CSIZE, "coredumpsize", }, | ||||||
| #ifdef RLIMIT_SBSIZE |  | ||||||
| 	{ RLIMIT_SBSIZE,	R_CSIZE, "sbsize", }, | 	{ RLIMIT_SBSIZE,	R_CSIZE, "sbsize", }, | ||||||
| #endif |  | ||||||
| 	{ -1, 0, 0 } | 	{ -1, 0, 0 } | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| @ -477,13 +473,11 @@ gsetrl(login_cap_t *lc, int what, const char *name, int type) | |||||||
| 		return (-1); | 		return (-1); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| #if !defined(__minix) |  | ||||||
| 	if (setrlimit(what, &rl)) { | 	if (setrlimit(what, &rl)) { | ||||||
| 		syslog(LOG_ERR, "%s: setting resource limit %s: %m", | 		syslog(LOG_ERR, "%s: setting resource limit %s: %m", | ||||||
| 		    lc->lc_class, name); | 		    lc->lc_class, name); | ||||||
| 		return (-1); | 		return (-1); | ||||||
| 	} | 	} | ||||||
| #endif /* !defined(__minix) */ |  | ||||||
| #undef	RCUR | #undef	RCUR | ||||||
| #undef	RMAX | #undef	RMAX | ||||||
| 	return (0); | 	return (0); | ||||||
|  | |||||||
| @ -207,7 +207,6 @@ pw_cont(int sig) | |||||||
| void | void | ||||||
| pw_init(void) | pw_init(void) | ||||||
| { | { | ||||||
| #if !defined(__minix) |  | ||||||
| 	struct rlimit rlim; | 	struct rlimit rlim; | ||||||
| 
 | 
 | ||||||
| 	/* Unlimited resource limits. */ | 	/* Unlimited resource limits. */ | ||||||
| @ -221,7 +220,6 @@ pw_init(void) | |||||||
| 	/* Don't drop core (not really necessary, but GP's). */ | 	/* Don't drop core (not really necessary, but GP's). */ | ||||||
| 	rlim.rlim_cur = rlim.rlim_max = 0; | 	rlim.rlim_cur = rlim.rlim_max = 0; | ||||||
| 	(void)setrlimit(RLIMIT_CORE, &rlim); | 	(void)setrlimit(RLIMIT_CORE, &rlim); | ||||||
| #endif /* !defined(__minix) */ |  | ||||||
| 
 | 
 | ||||||
| 	/* Turn off signals. */ | 	/* Turn off signals. */ | ||||||
| 	(void)signal(SIGALRM, SIG_IGN); | 	(void)signal(SIGALRM, SIG_IGN); | ||||||
|  | |||||||
| @ -219,10 +219,10 @@ main(int argc, char *argv[], char *envp[]) | |||||||
| 	 */ | 	 */ | ||||||
| #if !defined(__minix) | #if !defined(__minix) | ||||||
| 	(void)signal(SIGXCPU, timeoverrun); | 	(void)signal(SIGXCPU, timeoverrun); | ||||||
|  | #endif /* !defined(__minix) */ | ||||||
| 	limit.rlim_max = RLIM_INFINITY; | 	limit.rlim_max = RLIM_INFINITY; | ||||||
| 	limit.rlim_cur = GETTY_TIMEOUT; | 	limit.rlim_cur = GETTY_TIMEOUT; | ||||||
| 	(void)setrlimit(RLIMIT_CPU, &limit); | 	(void)setrlimit(RLIMIT_CPU, &limit); | ||||||
| #endif /* !defined(__minix) */ |  | ||||||
| 
 | 
 | ||||||
| 	/*
 | 	/*
 | ||||||
| 	 * The following is a work around for vhangup interactions | 	 * The following is a work around for vhangup interactions | ||||||
| @ -432,9 +432,7 @@ main(int argc, char *argv[], char *envp[]) | |||||||
| 
 | 
 | ||||||
| 			limit.rlim_max = RLIM_INFINITY; | 			limit.rlim_max = RLIM_INFINITY; | ||||||
| 			limit.rlim_cur = RLIM_INFINITY; | 			limit.rlim_cur = RLIM_INFINITY; | ||||||
| #if !defined(__minix) |  | ||||||
| 			(void)setrlimit(RLIMIT_CPU, &limit); | 			(void)setrlimit(RLIMIT_CPU, &limit); | ||||||
| #endif /* !defined(__minix) */ |  | ||||||
| 			if (NN) | 			if (NN) | ||||||
| 				(void)execle(LO, "login", AL ? "-fp" : "-p", | 				(void)execle(LO, "login", AL ? "-fp" : "-p", | ||||||
| 				    NULL, env); | 				    NULL, env); | ||||||
|  | |||||||
| @ -138,14 +138,12 @@ ATF_TC_BODY(snprintf_float, tc) | |||||||
| 	uint32_t ul, uh; | 	uint32_t ul, uh; | ||||||
| 	time_t now; | 	time_t now; | ||||||
| 	char buf[1000]; | 	char buf[1000]; | ||||||
| #if !defined(__minix) |  | ||||||
| 	struct rlimit rl; | 	struct rlimit rl; | ||||||
| 
 | 
 | ||||||
| 	rl.rlim_cur = rl.rlim_max = 1 * 1024 * 1024; | 	rl.rlim_cur = rl.rlim_max = 1 * 1024 * 1024; | ||||||
| 	ATF_CHECK(setrlimit(RLIMIT_AS, &rl) != -1); | 	ATF_CHECK(setrlimit(RLIMIT_AS, &rl) != -1); | ||||||
| 	rl.rlim_cur = rl.rlim_max = 1 * 1024 * 1024; | 	rl.rlim_cur = rl.rlim_max = 1 * 1024 * 1024; | ||||||
| 	ATF_CHECK(setrlimit(RLIMIT_DATA, &rl) != -1); | 	ATF_CHECK(setrlimit(RLIMIT_DATA, &rl) != -1); | ||||||
| #endif /* !defined(__minix) */ |  | ||||||
| 
 | 
 | ||||||
| 	time(&now); | 	time(&now); | ||||||
| 	srand(now); | 	srand(now); | ||||||
|  | |||||||
| @ -841,7 +841,7 @@ main(int argc, char **argv) | |||||||
| 		progname++; | 		progname++; | ||||||
| 	else | 	else | ||||||
| 		progname = argv[0]; | 		progname = argv[0]; | ||||||
| #if !defined(__minix) && (defined(MAKE_NATIVE) || (defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE))) | #if defined(MAKE_NATIVE) || (defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)) | ||||||
| 	/*
 | 	/*
 | ||||||
| 	 * get rid of resource limit on file descriptors | 	 * get rid of resource limit on file descriptors | ||||||
| 	 */ | 	 */ | ||||||
|  | |||||||
| @ -124,21 +124,17 @@ main(int argc, char *argv[]) | |||||||
| 	struct filelist filelist; | 	struct filelist filelist; | ||||||
| 	int num_input_files; | 	int num_input_files; | ||||||
| 	FILE *outfp = NULL; | 	FILE *outfp = NULL; | ||||||
| #if !defined(__minix) |  | ||||||
| 	struct rlimit rl; | 	struct rlimit rl; | ||||||
| #endif /* !defined(__minix) */ |  | ||||||
| 	struct stat st; | 	struct stat st; | ||||||
| 
 | 
 | ||||||
| 	setlocale(LC_ALL, ""); | 	setlocale(LC_ALL, ""); | ||||||
| 
 | 
 | ||||||
| #if !defined(__minix) |  | ||||||
| 	/* bump RLIMIT_NOFILE to maximum our hard limit allows */ | 	/* bump RLIMIT_NOFILE to maximum our hard limit allows */ | ||||||
| 	if (getrlimit(RLIMIT_NOFILE, &rl) < 0) | 	if (getrlimit(RLIMIT_NOFILE, &rl) < 0) | ||||||
| 		err(2, "getrlimit"); | 		err(2, "getrlimit"); | ||||||
| 	rl.rlim_cur = rl.rlim_max; | 	rl.rlim_cur = rl.rlim_max; | ||||||
| 	if (setrlimit(RLIMIT_NOFILE, &rl) < 0) | 	if (setrlimit(RLIMIT_NOFILE, &rl) < 0) | ||||||
| 		err(2, "setrlimit"); | 		err(2, "setrlimit"); | ||||||
| #endif /* !defined(__minix) */ |  | ||||||
| 	 | 	 | ||||||
| 	d_mask[REC_D = '\n'] = REC_D_F; | 	d_mask[REC_D = '\n'] = REC_D_F; | ||||||
| 	d_mask['\t'] = d_mask[' '] = BLANK | FLD_D; | 	d_mask['\t'] = d_mask[' '] = BLANK | FLD_D; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Lionel Sambuc
						Lionel Sambuc