public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jinseok Kim <always.starving0@gmail.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/2] open: replace getdtablesize with getrlimit
Date: Thu, 12 Feb 2026 22:22:14 +0900	[thread overview]
Message-ID: <20260212132221.4231-2-always.starving0@gmail.com> (raw)
In-Reply-To: <20260212132221.4231-1-always.starving0@gmail.com>

The test currently uses getdtablesize() to determine the maximum
number of file descriptors for the process. This interface is
considered legacy and is not specified by POSIX.

Use getrlimit() instead, which provides a well-defined
and portable way to obtain the per-process file descriptor limit.

Signed-off-by: Jinseok Kim <always.starving0@gmail.com>
---
 testcases/kernel/syscalls/open/open04.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/open/open04.c b/testcases/kernel/syscalls/open/open04.c
index ed5dd27bb..3d8ea2ae8 100644
--- a/testcases/kernel/syscalls/open/open04.c
+++ b/testcases/kernel/syscalls/open/open04.c
@@ -11,6 +11,7 @@

 #include <stdio.h>
 #include <stdlib.h>
+#include <sys/resource.h>
 #include "tst_test.h"

 #define FNAME "open04"
@@ -23,7 +24,10 @@ static void setup(void)
 {
 	int fd;

-	fds_limit = getdtablesize();
+	struct rlimit rlim;
+
+	SAFE_GETRLIMIT(RLIMIT_NOFILE, &rlim);
+	fds_limit = rlim.rlim_cur;
 	first = SAFE_OPEN(FNAME, O_RDWR | O_CREAT, 0777);

 	fds = SAFE_MALLOC(sizeof(int) * (fds_limit - first));
--
2.43.0

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-02-12 13:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-12 13:22 [LTP] [PATCH 1/2] open: fix cleanup condition and use snprintf Jinseok Kim
2026-02-12 13:22 ` Jinseok Kim [this message]
2026-02-17 11:40   ` [LTP] [PATCH 2/2] open: replace getdtablesize with getrlimit Andrea Cervesato via ltp
2026-02-17 12:22     ` [LTP] [PATCH v2 1/2] open: fix cleanup condition and use snprintf Jinseok Kim
2026-02-18 12:34       ` Andrea Cervesato via ltp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260212132221.4231-2-always.starving0@gmail.com \
    --to=always.starving0@gmail.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox