From: Waldemar Kozaczuk <[email protected]>
Committer: WALDEMAR KOZACZUK <[email protected]>
Branch: master

Implement prlimit syscall

Signed-off-by: Waldemar Kozaczuk <[email protected]>

---
diff --git a/exported_symbols/osv_ld-musl.so.1.symbols 
b/exported_symbols/osv_ld-musl.so.1.symbols
--- a/exported_symbols/osv_ld-musl.so.1.symbols
+++ b/exported_symbols/osv_ld-musl.so.1.symbols
@@ -740,6 +740,8 @@ pread64
 preadv
 preadv64
 printf
+prlimit
+prlimit64
 __progname
 __progname_full
 program_invocation_name
diff --git a/exported_symbols/osv_libc.so.6.symbols 
b/exported_symbols/osv_libc.so.6.symbols
--- a/exported_symbols/osv_libc.so.6.symbols
+++ b/exported_symbols/osv_libc.so.6.symbols
@@ -610,6 +610,8 @@ __pread64_chk
 preadv
 preadv64
 printf
+prlimit
+prlimit64
 __printf_chk
 __progname
 __progname_full
diff --git a/libc/libc.cc b/libc/libc.cc
--- a/libc/libc.cc
+++ b/libc/libc.cc
@@ -102,8 +102,28 @@ int setrlimit(int resource, const struct rlimit *rlim)
     // osv - no limits
     return 0;
 }
+
+int prlimit(pid_t pid, int resource, const struct rlimit *new_limit, struct 
rlimit *old_limit)
+{
+    if (pid != getpid() && pid != 0) {
+        errno = EINVAL;
+        return -1;
+    }
+
+    if (old_limit && getrlimit(resource, old_limit)) {
+        return -1;
+    }
+
+    if (new_limit && setrlimit(resource, new_limit)) {
+        return -1;
+    }
+
+    return 0;
+}
 LFS64(getrlimit);
 LFS64(setrlimit);
+#undef prlimit64
+LFS64(prlimit);
 
 uid_t geteuid()
 {
diff --git a/linux.cc b/linux.cc
--- a/linux.cc
+++ b/linux.cc
@@ -699,6 +699,7 @@ OSV_LIBC_API long syscall(long number, ...)
     SYSCALL5(sys_clone, unsigned long, void *, int *, int *, unsigned long);
     SYSCALL2(sys_clone3, struct clone_args *, size_t);
 #endif
+    SYSCALL4(prlimit64, pid_t, int, const struct rlimit *, struct rlimit *);
     }
 
     debug_always("syscall(): unimplemented system call %d\n", number);

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/000000000000b0a95c0609570724%40google.com.

Reply via email to