]> Zhao Yanbai Git Server - minix.git/commitdiff
Stub for setrlimit
authorLionel Sambuc <lionel@minix3.org>
Mon, 28 Apr 2014 08:05:45 +0000 (10:05 +0200)
committerLionel Sambuc <lionel@minix3.org>
Mon, 28 Jul 2014 15:05:23 +0000 (17:05 +0200)
Change-Id: I54c7233d71805711bd72e1e751456aad30fd3e35

bin/pax/pax.c
lib/libc/sys-minix/Makefile.inc
lib/libc/sys-minix/getrlimit.c
lib/libc/sys-minix/setrlimit.c [new file with mode: 0644]
lib/libutil/login_cap.c
lib/libutil/passwd.c
libexec/getty/main.c
tests/lib/libc/stdio/t_printf.c
usr.bin/make/main.c
usr.bin/sort/sort.c

index b8a3232ca71cec1e50436f25553245963fdf2b71..253d5fc94b64de8b219e0c3f9779dc70cb5c43fe 100644 (file)
@@ -374,13 +374,10 @@ sig_cleanup(int which_sig)
 static int
 gen_init(void)
 {
-#if !defined(__minix)
        struct rlimit reslimit;
-#endif /* !defined(__minix) */
        struct sigaction n_hand;
        struct sigaction o_hand;
 
-#if !defined(__minix)
        /*
         * 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...
@@ -416,7 +413,6 @@ gen_init(void)
                (void)setrlimit(RLIMIT_RSS , &reslimit);
        }
 #endif
-#endif /* !defined(__minix) */
 
        /*
         * Handle posix locale
index b7d38d15315ff487c92445e4c98332351ce7495c..7805a9e68111f0615df8d6e290ab36bb8ac52301 100644 (file)
@@ -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 \
        utimensat.c utimes.c futimes.c lutimes.c futimens.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.
 SRCS+= cprofile.c sprofile.c stack_utils.c _mcontext.c
index dce895bdb15f8d96e2bfdc8775ea5f8fdbf29f5b..d3948162599c82193ccae24755c672fd5ec7ad30 100644 (file)
@@ -20,12 +20,18 @@ int getrlimit(int resource, struct rlimit *rlp)
        
        switch (resource)
        {
-               case RLIMIT_CORE:
                case RLIMIT_CPU:
-               case RLIMIT_DATA:
                case RLIMIT_FSIZE:
+               case RLIMIT_DATA:
                case RLIMIT_STACK:
+               case RLIMIT_CORE:
+               case RLIMIT_RSS:
+               case RLIMIT_MEMLOCK:
+               case RLIMIT_NPROC:
+               case RLIMIT_SBSIZE:
                case RLIMIT_AS:
+               /* case RLIMIT_VMEM: Same as RLIMIT_AS */
+               case RLIMIT_NTHR:
                        /* no limit enforced (however architectural limits 
                         * may apply) 
                         */     
diff --git a/lib/libc/sys-minix/setrlimit.c b/lib/libc/sys-minix/setrlimit.c
new file mode 100644 (file)
index 0000000..ffa28ed
--- /dev/null
@@ -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;
+}
+
index 16b26e443558d28a7a20dd626e128241286cde8e..cbc32d25d76af2e859de1acbbcb4653db8a659a4 100644 (file)
@@ -417,17 +417,13 @@ static struct {
        { RLIMIT_FSIZE,         R_CSIZE, "filesize", },
        { RLIMIT_DATA,          R_CSIZE, "datasize", },
        { RLIMIT_STACK,         R_CSIZE, "stacksize", },
-#if !defined(__minix)
        { RLIMIT_RSS,           R_CSIZE, "memoryuse", },
        { RLIMIT_MEMLOCK,       R_CSIZE, "memorylocked", },
        { RLIMIT_NPROC,         R_CNUMB, "maxproc", },
        { RLIMIT_NTHR,          R_CNUMB, "maxthread", },
-#endif /* !defined(__minix) */
        { RLIMIT_NOFILE,        R_CNUMB, "openfiles", },
        { RLIMIT_CORE,          R_CSIZE, "coredumpsize", },
-#ifdef RLIMIT_SBSIZE
        { RLIMIT_SBSIZE,        R_CSIZE, "sbsize", },
-#endif
        { -1, 0, 0 }
 };
 
@@ -477,13 +473,11 @@ gsetrl(login_cap_t *lc, int what, const char *name, int type)
                return (-1);
        }
 
-#if !defined(__minix)
        if (setrlimit(what, &rl)) {
                syslog(LOG_ERR, "%s: setting resource limit %s: %m",
                    lc->lc_class, name);
                return (-1);
        }
-#endif /* !defined(__minix) */
 #undef RCUR
 #undef RMAX
        return (0);
index 826abb14e1aeab3bd7a715a4809c15448157f483..9cc1d481a3499812d53f59ce6d82e4eac1e38a5d 100644 (file)
@@ -207,7 +207,6 @@ pw_cont(int sig)
 void
 pw_init(void)
 {
-#if !defined(__minix)
        struct rlimit rlim;
 
        /* Unlimited resource limits. */
@@ -221,7 +220,6 @@ pw_init(void)
        /* Don't drop core (not really necessary, but GP's). */
        rlim.rlim_cur = rlim.rlim_max = 0;
        (void)setrlimit(RLIMIT_CORE, &rlim);
-#endif /* !defined(__minix) */
 
        /* Turn off signals. */
        (void)signal(SIGALRM, SIG_IGN);
index 2063c7a0390e0cdd31c32b4b8236b9a05dbbca5f..1ca4502599f15d4ce92e9ccbb86b6c3a2eade9be 100644 (file)
@@ -219,10 +219,10 @@ main(int argc, char *argv[], char *envp[])
         */
 #if !defined(__minix)
        (void)signal(SIGXCPU, timeoverrun);
+#endif /* !defined(__minix) */
        limit.rlim_max = RLIM_INFINITY;
        limit.rlim_cur = GETTY_TIMEOUT;
        (void)setrlimit(RLIMIT_CPU, &limit);
-#endif /* !defined(__minix) */
 
        /*
         * 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_cur = RLIM_INFINITY;
-#if !defined(__minix)
                        (void)setrlimit(RLIMIT_CPU, &limit);
-#endif /* !defined(__minix) */
                        if (NN)
                                (void)execle(LO, "login", AL ? "-fp" : "-p",
                                    NULL, env);
index 02b46bfeb8767a72e37e019a2eed205b21401645..95b4b2c9dffe0423bd6804e1df389c8b143815fe 100644 (file)
@@ -138,14 +138,12 @@ ATF_TC_BODY(snprintf_float, tc)
        uint32_t ul, uh;
        time_t now;
        char buf[1000];
-#if !defined(__minix)
        struct rlimit rl;
 
        rl.rlim_cur = rl.rlim_max = 1 * 1024 * 1024;
        ATF_CHECK(setrlimit(RLIMIT_AS, &rl) != -1);
        rl.rlim_cur = rl.rlim_max = 1 * 1024 * 1024;
        ATF_CHECK(setrlimit(RLIMIT_DATA, &rl) != -1);
-#endif /* !defined(__minix) */
 
        time(&now);
        srand(now);
index dd77a52c21199de51d3bbb462453bfd26db07d87..3f5a7493658f4cf99694f955bdd951fdc09b4f7e 100644 (file)
@@ -841,7 +841,7 @@ main(int argc, char **argv)
                progname++;
        else
                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
         */
index 76ea52ce664e59e4420b6b38af2f164c00a5d4d9..ab1303d65294921b788ef47cdbd86ba8634ac223 100644 (file)
@@ -124,21 +124,17 @@ main(int argc, char *argv[])
        struct filelist filelist;
        int num_input_files;
        FILE *outfp = NULL;
-#if !defined(__minix)
        struct rlimit rl;
-#endif /* !defined(__minix) */
        struct stat st;
 
        setlocale(LC_ALL, "");
 
-#if !defined(__minix)
        /* bump RLIMIT_NOFILE to maximum our hard limit allows */
        if (getrlimit(RLIMIT_NOFILE, &rl) < 0)
                err(2, "getrlimit");
        rl.rlim_cur = rl.rlim_max;
        if (setrlimit(RLIMIT_NOFILE, &rl) < 0)
                err(2, "setrlimit");
-#endif /* !defined(__minix) */
        
        d_mask[REC_D = '\n'] = REC_D_F;
        d_mask['\t'] = d_mask[' '] = BLANK | FLD_D;