@@ -228,7 +228,7 @@ static struct {
228228static struct {
229229 const char * cap ;
230230 rlim_t (* func )(login_cap_t * , const char * , rlim_t , rlim_t );
231- } resources [RLIM_NLIMITS ] = {
231+ } resources [] = {
232232 { "cputime" , login_getcaptime },
233233 { "filesize" , login_getcapsize },
234234 { "datasize" , login_getcapsize },
@@ -245,17 +245,22 @@ static struct {
245245 { "kqueues" , login_getcapnum },
246246 { "umtxp" , login_getcapnum },
247247 { "pipebuf" , login_getcapnum },
248+ { "vmms" , login_getcapnum },
248249};
249250
251+ _Static_assert (nitems (resources ) == RLIM_NLIMITS ,
252+ "Please add entries to resources[] for the new limits" );
253+
250254/*
251255 * One letter for each resource levels.
252256 * NOTE: There is a dependency on the corresponding
253257 * letter index being equal to the resource number.
254258 * If sys/resource.h defines are changed, this needs
255259 * to be modified accordingly!
256260 */
257-
258- #define RCS_STRING "tfdscmlunbvpwkoy"
261+ static const char rcs_string [] = "tfdscmlunbvpwkoyV" ;
262+ _Static_assert (sizeof (rcs_string ) - 1 == RLIM_NLIMITS ,
263+ "Please add letters to rcs_string[] for the new limits" );
259264
260265static rlim_t resource_num (int which , int ch , const char * str );
261266static void usage (void ) __dead2 ;
@@ -266,8 +271,6 @@ static void getrlimit_proc(pid_t pid, int resource, struct rlimit *rlp);
266271static void setrlimit_proc (pid_t pid , int resource , const struct rlimit * rlp );
267272extern char * * environ ;
268273
269- static const char rcs_string [] = RCS_STRING ;
270-
271274int
272275main (int argc , char * argv [])
273276{
@@ -295,7 +298,7 @@ main(int argc, char *argv[])
295298 pid = -1 ;
296299 optarg = NULL ;
297300 while ((ch = getopt (argc , argv ,
298- ":EeC:U:BSHP: ab:c:d:f: l:m:n:s:t:u:v:p:w:k:o :y:" )) != -1 ) {
301+ ":ab:BC: c:d:Eef:Hk: l:m:n:o:P:p:Ss:t:U:u:V:v:w :y:" )) != -1 ) {
299302 switch (ch ) {
300303 case 'a' :
301304 doall = 1 ;
@@ -552,7 +555,7 @@ usage(void)
552555{
553556 (void )fprintf (stderr ,
554557 "usage: limits [-C class|-P pid|-U user] [-eaSHBE] "
555- "[-bcdfklmnostuvpw [val]] [[name=val ...] cmd]\n" );
558+ "[-bcdfklmnostuVvpwy [val]] [[name=val ...] cmd]\n" );
556559 exit (EXIT_FAILURE );
557560}
558561
@@ -664,6 +667,7 @@ resource_num(int which, int ch, const char *str)
664667 case RLIMIT_NPTS :
665668 case RLIMIT_KQUEUES :
666669 case RLIMIT_UMTXP :
670+ case RLIMIT_VMM :
667671 res = strtoq (s , & e , 0 );
668672 s = e ;
669673 break ;
0 commit comments