public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Require explicit call to emergency_do_mounts
@ 2012-12-23 15:43 Dave Reisner
  2012-12-23 22:03 ` Karel Zak
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Reisner @ 2012-12-23 15:43 UTC (permalink / raw)
  To: util-linux; +Cc: Dave Reisner

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Require explicit call to emergency_do_mounts
  2012-12-23 15:43 [PATCH] Require explicit call to emergency_do_mounts Dave Reisner
@ 2012-12-23 22:03 ` Karel Zak
  2012-12-24  0:15   ` Bernhard Voelker
  0 siblings, 1 reply; 3+ messages in thread
From: Karel Zak @ 2012-12-23 22:03 UTC (permalink / raw)
  To: Dave Reisner; +Cc: util-linux

On Sun, Dec 23, 2012 at 10:43:30AM -0500, Dave Reisner wrote:
> 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.

 Ah, I've been faster then my fetchmail -- so I have pushed a
 little different patch.

> I'd further vote that the flag which enables this behavior be turned off
> by default.

 Good point, I think for mainstream distros it's unnecessary. 

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Require explicit call to emergency_do_mounts
  2012-12-23 22:03 ` Karel Zak
@ 2012-12-24  0:15   ` Bernhard Voelker
  0 siblings, 0 replies; 3+ messages in thread
From: Bernhard Voelker @ 2012-12-24  0:15 UTC (permalink / raw)
  To: Karel Zak; +Cc: Dave Reisner, util-linux

On 12/23/2012 11:03 PM, Karel Zak wrote:
>  Ah, I've been faster then my fetchmail -- so I have pushed a
>  little different patch.

Hi Karel,

I got a build error, because there's no make rule for
include/consoles.h. I didn't check if this is the correct
fix, but the following "just worked". ;-)


diff --git a/include/Makemodule.am b/include/Makemodule.am
index 4091896..bef118f 100644
--- a/include/Makemodule.am
+++ b/include/Makemodule.am
@@ -8,7 +8,6 @@ dist_noinst_HEADERS += \
        include/canonicalize.h \
        include/carefulputc.h \
        include/closestream.h \
-       include/consoles.h \
        include/cpuset.h \
        include/crc32.h \
        include/env.h \

Have a nice day,
Berny

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-12-24  0:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-23 15:43 [PATCH] Require explicit call to emergency_do_mounts Dave Reisner
2012-12-23 22:03 ` Karel Zak
2012-12-24  0:15   ` Bernhard Voelker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox