Bug#840356: initscripts: mountkernfs.sh does not mount configfs

2019-07-25 Thread Dmitry Bogatov


control: tags -1 +patch

[ Sorry for late response ]

[2017-03-30 12:36] Harald Dunkel 
> PS: Attached you can find a suggested fix.
>
> part 2 text/x-patch   334
> diff --git a/init.d/mountkernfs.sh b/init.d/mountkernfs.sh
> index e95cac3..56df7f9 100755
> --- a/init.d/mountkernfs.sh
> +++ b/init.d/mountkernfs.sh
> @@ -60,6 +60,7 @@ case "$1" in
>   mount_filesystems mount_noupdate
>   ;;
>start)
> + modprobe configfs || echo ignored
>   mount_filesystems mount_noupdate
>   ;;
>restart|reload|force-reload)

This patch loads `configfs' module, unconditionally. I find it
unfortunate.

I'd prefer to mount `configfs' after `kmod', if 'configfs' was loaded by
/etc/init.d/kmod; something like following. Opinions?

From 66fc843dc2c852fc47fe9cf1b671cf55d37ea62f Mon Sep 17 00:00:00 2001
From: Dmitry Bogatov 
Date: Thu, 25 Jul 2019 06:28:29 +
Subject: [PATCH] Attempt to mount /sys/kernel/config after `kmod'

Currently, /etc/init.d/mountkernfs attempts to mount `configfs' before
apporiate kernel module could be loaded by `kmod' script.  As such,
`configfs' is only mounted on systems where kernel module is loaded
by initramfs.

With this change `configfs' mount is tried in separate script after
`kmod'.

Closes: #840356
---
 debian/initscripts.conffiles  |  1 +
 debian/initscripts.postinst   |  2 +-
 debian/initscripts.postrm |  2 +-
 .../src/initscripts/etc/init.d/mount-configfs | 34 +++
 .../src/initscripts/etc/init.d/mountkernfs.sh |  4 ---
 5 files changed, 37 insertions(+), 6 deletions(-)
 create mode 100644 debian/src/initscripts/etc/init.d/mount-configfs

diff --git a/debian/initscripts.conffiles b/debian/initscripts.conffiles
index 381e9f66..6d3fa7ec 100644
--- a/debian/initscripts.conffiles
+++ b/debian/initscripts.conffiles
@@ -22,6 +22,7 @@
 /etc/init.d/umountnfs.sh
 /etc/init.d/umountroot
 /etc/init.d/urandom
+/etc/init.d/mount-configfs
 /etc/default/devpts
 /etc/default/halt
 /etc/default/rcS
diff --git a/debian/initscripts.postinst b/debian/initscripts.postinst
index 82ab6a71..b1e3e6c2 100755
--- a/debian/initscripts.postinst
+++ b/debian/initscripts.postinst
@@ -45,7 +45,7 @@ make_rc_local_conffile
 
 umask 022
 
-INITSCRIPTS="mountkernfs.sh brightness hostname.sh mountdevsubfs.sh 
checkroot.sh \
+INITSCRIPTS="mountkernfs.sh mount-configfs brightness hostname.sh 
mountdevsubfs.sh checkroot.sh \
checkroot-bootclean.sh checkfs.sh mountall.sh mountall-bootclean.sh \
mountnfs.sh mountnfs-bootclean.sh bootmisc.sh urandom halt reboot \
umountroot umountfs umountnfs.sh sendsigs killprocs single motd \
diff --git a/debian/initscripts.postrm b/debian/initscripts.postrm
index 6847f9ff..5e232568 100755
--- a/debian/initscripts.postrm
+++ b/debian/initscripts.postrm
@@ -5,7 +5,7 @@
 
 set -e
 
-INITSCRIPTS="mountkernfs.sh brightness hostname.sh mountdevsubfs.sh 
checkroot.sh \
+INITSCRIPTS="mountkernfs.sh mount-configfs brightness hostname.sh 
mountdevsubfs.sh checkroot.sh \
checkroot-bootclean.sh checkfs.sh mountall.sh mountall-bootclean.sh \
mountnfs.sh mountnfs-bootclean.sh bootmisc.sh urandom halt reboot \
umountroot umountfs umountnfs.sh sendsigs killprocs single motd \
diff --git a/debian/src/initscripts/etc/init.d/mount-configfs 
b/debian/src/initscripts/etc/init.d/mount-configfs
new file mode 100644
index ..6cfd16bf
--- /dev/null
+++ b/debian/src/initscripts/etc/init.d/mount-configfs
@@ -0,0 +1,34 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:  mount-configfs
+# Required-Start:mountkernfs
+# Required-Stop:
+# Should-Start:  kmod
+# Default-Start: S
+# Default-Stop:
+# Short-Description: Mount configfs kernel virtual file system.
+# Description:   Mount configfs kernel virtual file system,
+#if "configfs" module is loaded.
+### END INIT INFO
+set -eu
+
+export PATH=/bin:/usr/bin
+
+case ${1:-missing} in
+(start|restart|force-reload)
+   readonly mountpoint='/sys/kernel/config'
+   # This directory exists only if "configfs" module was loaded by "kmod"
+   # script.
+   test -d "${mountpoint}"  || exit 0
+   ! findmnt "${mountpoint}" >/dev/null || exit 0
+
+   mount none -t configfs "${mountpoint}"
+   ;;
+(stop)
+   # No-op
+   ;;
+(*)
+   echo "Usage: mount-configfs [start|stop]" >&2
+   exit 3
+   ;;
+esac
diff --git a/debian/src/initscripts/etc/init.d/mountkernfs.sh 
b/debian/src/initscripts/etc/init.d/mountkernfs.sh
index e95cac3a..146581a6 100755
--- a/debian/src/initscripts/etc/init.d/mountkernfs.sh
+++ b/debian/src/initscripts/etc/init.d/mountkernfs.sh
@@ -48,10 +48,6 @@ mount_filesystems () {
domount "$MNTMODE" pstore "" /sys/fs/pstore pstore ""
fi
 
-   if [ -d /sys/kernel/config ]
-   then
-   domount "$MNTMODE" configfs "" /sys/kernel/config configfs ""
-   fi
 }
 
 case "$1" 

Bug#840356: initscripts: mountkernfs.sh does not mount configfs

2017-03-30 Thread Harald Dunkel
PS: Attached you can find a suggested fix.

diff --git a/init.d/mountkernfs.sh b/init.d/mountkernfs.sh
index e95cac3..56df7f9 100755
--- a/init.d/mountkernfs.sh
+++ b/init.d/mountkernfs.sh
@@ -60,6 +60,7 @@ case "$1" in
 	mount_filesystems mount_noupdate
 	;;
   start)
+	modprobe configfs || echo ignored
 	mount_filesystems mount_noupdate
 	;;
   restart|reload|force-reload)


Bug#840356: initscripts: mountkernfs.sh does not mount configfs

2017-03-30 Thread Harald Dunkel
Are you sure that "Severity: normal" is appropriate? /sys/module/configfs
is essential for targetcli.

Regards
Harri



Bug#840356: initscripts: mountkernfs.sh does not mount configfs

2016-10-10 Thread Ian Jackson
Christophe Vu-Brugier writes ("Bug#840356: initscripts: mountkernfs.sh does not 
mount configfs"):
> Dear Maintainer,

Hi.  FYI, I'm not the maintainer.  But I am interested in sysvinit in
general.

> Maybe we could cut the configfs section from mountkernfs.sh and put it
> in a separate mountconfigfs.sh init script that would start after kmod?

This would be a possibility.  But TBH maybe it would be better to load
kernel modules before trying to mount the kernel filesystems.  I'm not
sure what dependencies there might be in the other direction.  Can
anyone advise ?  I guess maybe modprobe depends on /proc.

Sorry to be vague, but I'm replying to this late at night and not
entirely sober :-).

Thanks,
Ian.

-- 
Ian Jackson <ijack...@chiark.greenend.org.uk>   These opinions are my own.

If I emailed you from an address @fyvzl.net or @evade.org.uk, that is
a private address which bypasses my fierce spamfilter.



Bug#840356: initscripts: mountkernfs.sh does not mount configfs

2016-10-10 Thread Christophe Vu-Brugier
Package: initscripts
Version: 2.88dsf-59.8
Severity: normal

Dear Maintainer,

I am working on the targetcli-fb and python-rtslib-fb packages that
rely on configfs and I think there is an issue in the mountkernfs.sh
script that prevents it from mounting the configfs file system.

The mount_filesystems() function in /etc/init.d/mountkernfs.sh
contains the following code to mount the configfs file system under
/sys/kernel/config:

  if [ -d /sys/kernel/config ]
  then
domount "$MNTMODE" configfs "" /sys/kernel/config configfs ""
  fi

The problem is that the /sys/kernel/config directory does not exist
when the script is invoked because the configfs kernel module is not
loaded at that time. The /sys/kernel/config directory does not exist
until the configfs module is probed. See:

  http://lxr.free-electrons.com/source/fs/configfs/mount.c#L142

Invoking `modprobe configfs` before testing for /sys/kernel/config
being a directory allows to mount configfs as expected. I am not sure
it is the proper fix though.

There was a similar issue reported for systemd: #800521

  systemd: sys-kernel-config.mount not functional
  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=800521

The fix for this bug was to make the package install a configuration
file in a modules-load.d directory to load the configfs module. I
tried to do the same for sysv, expecting that the configfs module
would be loaded before mountkernfs.sh is run, but it is not the case.

Maybe we could cut the configfs section from mountkernfs.sh and put it
in a separate mountconfigfs.sh init script that would start after kmod?

What do you think?

With best regards,

-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, armhf, armel

Kernel: Linux 4.7.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages initscripts depends on:
ii  coreutils   8.25-2
ii  debianutils 4.8
ii  lsb-base9.20160629
ii  mount   2.28.2-1
ii  sysv-rc 2.88dsf-59.8
ii  sysvinit-utils  2.88dsf-59.8

Versions of packages initscripts recommends:
ii  e2fsprogs  1.43.3-1
ii  psmisc 22.21-2.1+b1

initscripts suggests no packages.

-- no debconf information