public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Mike Gilbert" <floppym@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/sandbox:master commit in: libsandbox/, libsbutil/
Date: Sun, 09 Mar 2025 18:27:21 +0000 (UTC)	[thread overview]
Message-ID: <1741544541.b794dc4c4fc421713d82c75d8a14be9b85ba2482.floppym@gentoo> (raw)

commit:     b794dc4c4fc421713d82c75d8a14be9b85ba2482
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sun Mar  9 05:16:54 2025 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sun Mar  9 18:22:21 2025 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=b794dc4c

libsbutil: move sb_close_all_fds into libsandbox

Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 libsandbox/trace.c   | 25 ++++++++++++++++++++++++-
 libsbutil/local.mk   |  1 -
 libsbutil/sb_close.c | 35 -----------------------------------
 libsbutil/sbutil.h   |  1 -
 4 files changed, 24 insertions(+), 38 deletions(-)

diff --git a/libsandbox/trace.c b/libsandbox/trace.c
index 40d83cd..b9a9470 100644
--- a/libsandbox/trace.c
+++ b/libsandbox/trace.c
@@ -524,6 +524,29 @@ static void trace_loop(void)
 	} while (1);
 }
 
+static void close_all_fds(void)
+{
+	DIR *dirp;
+	struct dirent *de;
+	int dfd, fd;
+	const char *fd_dir = sb_get_fd_dir();
+
+	dirp = opendir(fd_dir);
+	if (!dirp)
+		sb_ebort("could not process %s\n", fd_dir);
+	dfd = dirfd(dirp);
+
+	while ((de = readdir(dirp)) != NULL) {
+		if (de->d_name[0] == '.')
+			continue;
+		fd = atoi(de->d_name);
+		if (fd != dfd)
+			close(fd);
+	}
+
+	closedir(dirp);
+}
+
 void trace_main(void)
 {
 	struct sigaction old_sa, sa = { .sa_handler = SIG_DFL, };
@@ -545,7 +568,7 @@ void trace_main(void)
 				PTRACE_O_TRACEEXIT |
 				PTRACE_O_TRACESYSGOOD
 			));
-		sb_close_all_fds();
+		close_all_fds();
 		trace_loop();
 		sb_ebort("ISE: child should have quit, as should we\n");
 	}

diff --git a/libsbutil/local.mk b/libsbutil/local.mk
index 12d6526..b1980de 100644
--- a/libsbutil/local.mk
+++ b/libsbutil/local.mk
@@ -25,7 +25,6 @@ noinst_LIBRARIES += %D%/libsbutil.a
 	%D%/sb_stat.c                             \
 	%D%/sb_write.c                            \
 	%D%/sb_write_fd.c                         \
-	%D%/sb_close.c                            \
 	%D%/sb_printf.c                           \
 	%D%/sb_proc.c                             \
 	%D%/sb_memory.c                           \

diff --git a/libsbutil/sb_close.c b/libsbutil/sb_close.c
deleted file mode 100644
index 5f7def7..0000000
--- a/libsbutil/sb_close.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * sb_close.c
- *
- * IO functions.
- *
- * Copyright 1999-2012 Gentoo Foundation
- * Licensed under the GPL-2
- */
-
-#include "headers.h"
-#include "sbutil.h"
-
-/* Quickly close all the open fds (good for daemonization) */
-void sb_close_all_fds(void)
-{
-	DIR *dirp;
-	struct dirent *de;
-	int dfd, fd;
-	const char *fd_dir = sb_get_fd_dir();
-
-	dirp = opendir(fd_dir);
-	if (!dirp)
-		sb_ebort("could not process %s\n", fd_dir);
-	dfd = dirfd(dirp);
-
-	while ((de = readdir(dirp)) != NULL) {
-		if (de->d_name[0] == '.')
-			continue;
-		fd = atoi(de->d_name);
-		if (fd != dfd)
-			close(fd);
-	}
-
-	closedir(dirp);
-}

diff --git a/libsbutil/sbutil.h b/libsbutil/sbutil.h
index d092868..5d74c93 100644
--- a/libsbutil/sbutil.h
+++ b/libsbutil/sbutil.h
@@ -107,7 +107,6 @@ extern const char sbio_fallback_path[];
 int sb_open(const char *path, int flags, mode_t mode);
 size_t sb_read(int fd, void *buf, size_t count);
 size_t sb_write(int fd, const void *buf, size_t count);
-void sb_close_all_fds(void);
 int sb_copy_file_to_fd(const char *file, int ofd);
 int sb_exists(int dirfd, const char *pathname, int flags);
 int sb_fstat(int fd, mode_t *mode, int64_t *size);


             reply	other threads:[~2025-03-09 18:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-09 18:27 Mike Gilbert [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-01-13 17:50 [gentoo-commits] proj/sandbox:stable-2.x commit in: libsandbox/, libsbutil/ Mike Gilbert
2025-01-14  4:38 ` [gentoo-commits] proj/sandbox:master " Mike Gilbert
2025-01-08  2:12 [gentoo-commits] proj/sandbox:stable-2.x commit in: libsbutil/, libsandbox/ Mike Gilbert
2025-01-14  4:38 ` [gentoo-commits] proj/sandbox:master commit in: libsandbox/, libsbutil/ Mike Gilbert
2021-10-21  8:06 Mike Frysinger

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=1741544541.b794dc4c4fc421713d82c75d8a14be9b85ba2482.floppym@gentoo \
    --to=floppym@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /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