Skip to contentSkip to conversation

Require explicit call to emergency_do_mounts

PATCH In review Dave Reisner 3 participants 3 messages Dec 23, 2012 – Dec 24, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Require explicit call to emergency_do_mounts

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.

---
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(-)
include/consoles.h +5 -0
index 2544263..db2e500 100644
@@ -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
lib/consoles.c +0 -2
index 7175a08..7930e7c 100644
@@ -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;
login-utils/sulogin.c +5 -0
index 8416e3e..42b1b73 100644
@@ -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.
 	 */
Signature · 1 line
1.8.0.2
maintainer
#1 lore raw
Quoted 5 lines · 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.

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

Quoted 2 lines

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

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#2 lore raw
Quoted 2 lines · Karel Zak

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". ;-)

include/Makemodule.am +0 -1
index 4091896..bef118f 100644
@@ -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