All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Reisner <dreisner@archlinux.org>
To: util-linux@vger.kernel.org
Cc: Dave Reisner <dreisner@archlinux.org>
Subject: [PATCH] Require explicit call to emergency_do_mounts
Date: Sun, 23 Dec 2012 10:43:30 -0500	[thread overview]
Message-ID: <1356277410-29666-1-git-send-email-dreisner@archlinux.org> (raw)

Keeping these functions in lib/ with constructor and destructor
attributes causes the code to be run in invocation of a large number of
programs in the util-linux tree. Remove the attributes and call it
explicitly from sulogin, the only place where it (currently) makes sense
to be called from.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
---
I'd further vote that the flag which enables this behavior be turned off
by default.

 include/consoles.h    | 5 +++++
 lib/consoles.c        | 2 --
 login-utils/sulogin.c | 5 +++++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/consoles.h b/include/consoles.h
index 2544263..db2e500 100644
--- a/include/consoles.h
+++ b/include/consoles.h
@@ -49,3 +49,8 @@ struct console {
 
 extern int detect_consoles(const char *device, int fallback,
 			   struct list_head *consoles);
+
+#ifdef USE_SULOGIN_EMERGENCY_MOUNT
+void emergency_do_umounts(void);
+void emergency_do_mounts(void);
+#endif
diff --git a/lib/consoles.c b/lib/consoles.c
index 7175a08..7930e7c 100644
--- a/lib/consoles.c
+++ b/lib/consoles.c
@@ -98,7 +98,6 @@ static uint32_t emergency_flags;
 # define MNT_PROCFS    0x0001
 # define MNT_DEVTMPFS  0x0002
 
-static __attribute__((__destructor__))
 void emergency_do_umounts(void)
 {
 	if (emergency_flags & MNT_DEVTMPFS)
@@ -107,7 +106,6 @@ void emergency_do_umounts(void)
 		umount2("/proc", MNT_DETACH);
 }
 
-static __attribute__((__constructor__))
 void emergency_do_mounts(void)
 {
 	struct stat rt, xt;
diff --git a/login-utils/sulogin.c b/login-utils/sulogin.c
index 8416e3e..42b1b73 100644
--- a/login-utils/sulogin.c
+++ b/login-utils/sulogin.c
@@ -834,6 +834,11 @@ int main(int argc, char **argv)
 	mask_signal(SIGINT,  SIG_IGN, &saved_sigint);
 	mask_signal(SIGHUP,  SIG_IGN, &saved_sighup);
 
+#ifdef USE_SULOGIN_EMERGENCY_MOUNT
+	emergency_do_mounts();
+	atexit(emergency_do_umounts);
+#endif
+
 	/*
 	 * See if we need to open an other tty device.
 	 */
-- 
1.8.0.2


             reply	other threads:[~2012-12-23 15:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-23 15:43 Dave Reisner [this message]
2012-12-23 22:03 ` [PATCH] Require explicit call to emergency_do_mounts Karel Zak
2012-12-24  0:15   ` Bernhard Voelker

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=1356277410-29666-1-git-send-email-dreisner@archlinux.org \
    --to=dreisner@archlinux.org \
    --cc=util-linux@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.