Re: [systemd-devel] [PATCH v2] tools: add static-nodes tool

2013-04-16 Thread Tom Gundersen
On Tue, Apr 16, 2013 at 1:20 AM, Lucas De Marchi
lucas.demar...@profusion.mobi wrote:
 Hi Tom,

Hi Lucas,

Thanks for your review!

 On Fri, Apr 12, 2013 at 9:15 PM, Tom Gundersen t...@jklm.no wrote:
 This tool reads modules.devname from the current kernel directory and outputs
 the information.

 For now only the tmpfiles.d(5) format is supported, but more could easily be
 added in the future if there is a need.

 When booting with systemd, the new tool is called at boot to instruct
 systemd-tmpfiles to create the necessary static modules before starting
 systemd-udevd.

 This means nothing but kmod needs to reads the private files under 
 /lib/modules/.

 For me this would be the main goal of this patch or anything similar to this.

Yeah, I agree.

 Cc: linux-hotp...@vger.kernel.org
 Cc: systemd-devel@lists.freedesktop.org
 ---

 v2: adressed concerns raised by Dave, and made the tool a bit more generic so
 more output formats may be added in the future as suggested by Lucas. Also
 included the systemd unit file to hook this up with systemd.

  Makefile.am|  20 -
  configure.ac   |   8 ++
  tools/kmod-static-nodes.service.in |  16 
  tools/kmod.c   |   1 +
  tools/kmod.h   |   1 +
  tools/static-nodes.c   | 163 
 +
  6 files changed, 207 insertions(+), 2 deletions(-)
  create mode 100644 tools/kmod-static-nodes.service.in
  create mode 100644 tools/static-nodes.c

 diff --git a/Makefile.am b/Makefile.am
 index 9feaf96..333e861 100644
 --- a/Makefile.am
 +++ b/Makefile.am
 @@ -36,6 +36,9 @@ SED_PROCESS = \
  %.pc: %.pc.in Makefile
 $(SED_PROCESS)

 +%.service: %.service.in Makefile
 +   $(SED_PROCESS)
 +
  LIBKMOD_CURRENT=4
  LIBKMOD_REVISION=2
  LIBKMOD_AGE=2
 @@ -88,6 +91,17 @@ pkgconfig_DATA = libkmod/libkmod.pc
  EXTRA_DIST += libkmod/libkmod.pc.in
  CLEANFILES += libkmod/libkmod.pc

 +if HAVE_SYSTEMD
 +systemdsystemunit_DATA = tools/kmod-static-nodes.service
 +EXTRA_DIST += tools/kmod-static-nodes.service.in
 +CLEANFILES += tools/kmod-static-nodes.service
 +
 +install-data-hook:
 +   $(MKDIR_P) $(DESTDIR)$(systemdsystemunitdir)/sysinit.target.wants
 +   ln -sf ../kmod-static-nodes.service \
 +   
 $(DESTDIR)$(systemdsystemunitdir)/sysinit.target.wants/kmod-static-nodes.service
 +endif
 +
  install-exec-hook:
 if test $(libdir) != $(rootlibdir); then \
 $(MKDIR_P) $(DESTDIR)$(rootlibdir)  \
 @@ -109,7 +123,8 @@ noinst_SCRIPTS = tools/insmod tools/rmmod tools/lsmod \
  tools_kmod_SOURCES = tools/kmod.c tools/kmod.h tools/lsmod.c \
  tools/rmmod.c tools/insmod.c \
  tools/modinfo.c tools/modprobe.c \
 -tools/depmod.c tools/log.h tools/log.c
 +tools/depmod.c tools/log.h tools/log.c \
 +tools/static-nodes.c
  tools_kmod_LDADD = libkmod/libkmod-util.la \
libkmod/libkmod.la

 @@ -211,7 +226,8 @@ testsuite-distclean:
  DISTCLEAN_LOCAL_HOOKS += testsuite-distclean
  EXTRA_DIST += testsuite/rootfs-pristine

 -DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc --sysconfdir=/etc --with-zlib
 +DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc --sysconfdir=/etc --with-zlib \
 + 
 --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)

  distclean-local: $(DISTCLEAN_LOCAL_HOOKS)

 diff --git a/configure.ac b/configure.ac
 index 566b317..af5ed52 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -76,6 +76,13 @@ AS_IF([test x$with_zlib != xno], [
 AC_MSG_NOTICE([zlib support not requested])
  ])

 +AC_ARG_WITH([systemdsystemunitdir],
 +AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory 
 for systemd service files]),
 +[], [with_systemdsystemunitdir=$($PKG_CONFIG 
 --variable=systemdsystemunitdir systemd)])
 +if test x$with_systemdsystemunitdir != xno; then
 +AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
 +fi
 +AM_CONDITIONAL(HAVE_SYSTEMD, [test -n $with_systemdsystemunitdir -a 
 x$with_systemdsystemunitdir != xno ])

  #
  # --enable-
 @@ -200,6 +207,7 @@ AC_MSG_RESULT([
 compiler:   ${CC}
 cflags: ${with_cflags} ${CFLAGS}
 ldflags:${with_ldflags} ${LDFLAGS}
 +   systemdsystemunitdir:   ${with_systemdsystemunitdir}

 tools:  ${enable_tools}
 logging:${enable_logging}
 diff --git a/tools/kmod-static-nodes.service.in 
 b/tools/kmod-static-nodes.service.in
 new file mode 100644
 index 000..be8482e
 --- /dev/null
 +++ b/tools/kmod-static-nodes.service.in

 I'm not sure we want the service file to live in kmod repository.
 Maybe we could let this in systemd and in kmod we only add the support
 to create this type of information?

I 

Re: [systemd-devel] [PATCH v2] tools: add static-nodes tool

2013-04-15 Thread Lucas De Marchi
Hi Tom,

On Fri, Apr 12, 2013 at 9:15 PM, Tom Gundersen t...@jklm.no wrote:
 This tool reads modules.devname from the current kernel directory and outputs
 the information.

 For now only the tmpfiles.d(5) format is supported, but more could easily be
 added in the future if there is a need.

 When booting with systemd, the new tool is called at boot to instruct
 systemd-tmpfiles to create the necessary static modules before starting
 systemd-udevd.

 This means nothing but kmod needs to reads the private files under 
 /lib/modules/.

For me this would be the main goal of this patch or anything similar to this.


 Cc: linux-hotp...@vger.kernel.org
 Cc: systemd-devel@lists.freedesktop.org
 ---

 v2: adressed concerns raised by Dave, and made the tool a bit more generic so
 more output formats may be added in the future as suggested by Lucas. Also
 included the systemd unit file to hook this up with systemd.

  Makefile.am|  20 -
  configure.ac   |   8 ++
  tools/kmod-static-nodes.service.in |  16 
  tools/kmod.c   |   1 +
  tools/kmod.h   |   1 +
  tools/static-nodes.c   | 163 
 +
  6 files changed, 207 insertions(+), 2 deletions(-)
  create mode 100644 tools/kmod-static-nodes.service.in
  create mode 100644 tools/static-nodes.c

 diff --git a/Makefile.am b/Makefile.am
 index 9feaf96..333e861 100644
 --- a/Makefile.am
 +++ b/Makefile.am
 @@ -36,6 +36,9 @@ SED_PROCESS = \
  %.pc: %.pc.in Makefile
 $(SED_PROCESS)

 +%.service: %.service.in Makefile
 +   $(SED_PROCESS)
 +
  LIBKMOD_CURRENT=4
  LIBKMOD_REVISION=2
  LIBKMOD_AGE=2
 @@ -88,6 +91,17 @@ pkgconfig_DATA = libkmod/libkmod.pc
  EXTRA_DIST += libkmod/libkmod.pc.in
  CLEANFILES += libkmod/libkmod.pc

 +if HAVE_SYSTEMD
 +systemdsystemunit_DATA = tools/kmod-static-nodes.service
 +EXTRA_DIST += tools/kmod-static-nodes.service.in
 +CLEANFILES += tools/kmod-static-nodes.service
 +
 +install-data-hook:
 +   $(MKDIR_P) $(DESTDIR)$(systemdsystemunitdir)/sysinit.target.wants
 +   ln -sf ../kmod-static-nodes.service \
 +   
 $(DESTDIR)$(systemdsystemunitdir)/sysinit.target.wants/kmod-static-nodes.service
 +endif
 +
  install-exec-hook:
 if test $(libdir) != $(rootlibdir); then \
 $(MKDIR_P) $(DESTDIR)$(rootlibdir)  \
 @@ -109,7 +123,8 @@ noinst_SCRIPTS = tools/insmod tools/rmmod tools/lsmod \
  tools_kmod_SOURCES = tools/kmod.c tools/kmod.h tools/lsmod.c \
  tools/rmmod.c tools/insmod.c \
  tools/modinfo.c tools/modprobe.c \
 -tools/depmod.c tools/log.h tools/log.c
 +tools/depmod.c tools/log.h tools/log.c \
 +tools/static-nodes.c
  tools_kmod_LDADD = libkmod/libkmod-util.la \
libkmod/libkmod.la

 @@ -211,7 +226,8 @@ testsuite-distclean:
  DISTCLEAN_LOCAL_HOOKS += testsuite-distclean
  EXTRA_DIST += testsuite/rootfs-pristine

 -DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc --sysconfdir=/etc --with-zlib
 +DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc --sysconfdir=/etc --with-zlib \
 + 
 --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)

  distclean-local: $(DISTCLEAN_LOCAL_HOOKS)

 diff --git a/configure.ac b/configure.ac
 index 566b317..af5ed52 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -76,6 +76,13 @@ AS_IF([test x$with_zlib != xno], [
 AC_MSG_NOTICE([zlib support not requested])
  ])

 +AC_ARG_WITH([systemdsystemunitdir],
 +AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for 
 systemd service files]),
 +[], [with_systemdsystemunitdir=$($PKG_CONFIG 
 --variable=systemdsystemunitdir systemd)])
 +if test x$with_systemdsystemunitdir != xno; then
 +AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
 +fi
 +AM_CONDITIONAL(HAVE_SYSTEMD, [test -n $with_systemdsystemunitdir -a 
 x$with_systemdsystemunitdir != xno ])

  #
  # --enable-
 @@ -200,6 +207,7 @@ AC_MSG_RESULT([
 compiler:   ${CC}
 cflags: ${with_cflags} ${CFLAGS}
 ldflags:${with_ldflags} ${LDFLAGS}
 +   systemdsystemunitdir:   ${with_systemdsystemunitdir}

 tools:  ${enable_tools}
 logging:${enable_logging}
 diff --git a/tools/kmod-static-nodes.service.in 
 b/tools/kmod-static-nodes.service.in
 new file mode 100644
 index 000..be8482e
 --- /dev/null
 +++ b/tools/kmod-static-nodes.service.in

I'm not sure we want the service file to live in kmod repository.
Maybe we could let this in systemd and in kmod we only add the support
to create this type of information?


 @@ -0,0 +1,16 @@
 +#  This file is part of kmod.
 +#
 +#  kmod is free software; you can redistribute it and/or modify it
 +#  under the terms 

[systemd-devel] [PATCH v2] tools: add static-nodes tool

2013-04-12 Thread Tom Gundersen
This tool reads modules.devname from the current kernel directory and outputs
the information.

For now only the tmpfiles.d(5) format is supported, but more could easily be
added in the future if there is a need.

When booting with systemd, the new tool is called at boot to instruct
systemd-tmpfiles to create the necessary static modules before starting
systemd-udevd.

This means nothing but kmod needs to reads the private files under 
/lib/modules/.

Cc: linux-hotp...@vger.kernel.org
Cc: systemd-devel@lists.freedesktop.org
---

v2: adressed concerns raised by Dave, and made the tool a bit more generic so
more output formats may be added in the future as suggested by Lucas. Also
included the systemd unit file to hook this up with systemd.

 Makefile.am|  20 -
 configure.ac   |   8 ++
 tools/kmod-static-nodes.service.in |  16 
 tools/kmod.c   |   1 +
 tools/kmod.h   |   1 +
 tools/static-nodes.c   | 163 +
 6 files changed, 207 insertions(+), 2 deletions(-)
 create mode 100644 tools/kmod-static-nodes.service.in
 create mode 100644 tools/static-nodes.c

diff --git a/Makefile.am b/Makefile.am
index 9feaf96..333e861 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -36,6 +36,9 @@ SED_PROCESS = \
 %.pc: %.pc.in Makefile
$(SED_PROCESS)
 
+%.service: %.service.in Makefile
+   $(SED_PROCESS)
+
 LIBKMOD_CURRENT=4
 LIBKMOD_REVISION=2
 LIBKMOD_AGE=2
@@ -88,6 +91,17 @@ pkgconfig_DATA = libkmod/libkmod.pc
 EXTRA_DIST += libkmod/libkmod.pc.in
 CLEANFILES += libkmod/libkmod.pc
 
+if HAVE_SYSTEMD
+systemdsystemunit_DATA = tools/kmod-static-nodes.service
+EXTRA_DIST += tools/kmod-static-nodes.service.in
+CLEANFILES += tools/kmod-static-nodes.service
+
+install-data-hook:
+   $(MKDIR_P) $(DESTDIR)$(systemdsystemunitdir)/sysinit.target.wants
+   ln -sf ../kmod-static-nodes.service \
+   
$(DESTDIR)$(systemdsystemunitdir)/sysinit.target.wants/kmod-static-nodes.service
+endif
+
 install-exec-hook:
if test $(libdir) != $(rootlibdir); then \
$(MKDIR_P) $(DESTDIR)$(rootlibdir)  \
@@ -109,7 +123,8 @@ noinst_SCRIPTS = tools/insmod tools/rmmod tools/lsmod \
 tools_kmod_SOURCES = tools/kmod.c tools/kmod.h tools/lsmod.c \
 tools/rmmod.c tools/insmod.c \
 tools/modinfo.c tools/modprobe.c \
-tools/depmod.c tools/log.h tools/log.c
+tools/depmod.c tools/log.h tools/log.c \
+tools/static-nodes.c
 tools_kmod_LDADD = libkmod/libkmod-util.la \
   libkmod/libkmod.la
 
@@ -211,7 +226,8 @@ testsuite-distclean:
 DISTCLEAN_LOCAL_HOOKS += testsuite-distclean
 EXTRA_DIST += testsuite/rootfs-pristine
 
-DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc --sysconfdir=/etc --with-zlib
+DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc --sysconfdir=/etc --with-zlib \
+ 
--with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
 
 distclean-local: $(DISTCLEAN_LOCAL_HOOKS)
 
diff --git a/configure.ac b/configure.ac
index 566b317..af5ed52 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,6 +76,13 @@ AS_IF([test x$with_zlib != xno], [
AC_MSG_NOTICE([zlib support not requested])
 ])
 
+AC_ARG_WITH([systemdsystemunitdir],
+AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for 
systemd service files]),
+[], [with_systemdsystemunitdir=$($PKG_CONFIG 
--variable=systemdsystemunitdir systemd)])
+if test x$with_systemdsystemunitdir != xno; then
+AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
+fi
+AM_CONDITIONAL(HAVE_SYSTEMD, [test -n $with_systemdsystemunitdir -a 
x$with_systemdsystemunitdir != xno ])
 
 #
 # --enable-
@@ -200,6 +207,7 @@ AC_MSG_RESULT([
compiler:   ${CC}
cflags: ${with_cflags} ${CFLAGS}
ldflags:${with_ldflags} ${LDFLAGS}
+   systemdsystemunitdir:   ${with_systemdsystemunitdir}
 
tools:  ${enable_tools}
logging:${enable_logging}
diff --git a/tools/kmod-static-nodes.service.in 
b/tools/kmod-static-nodes.service.in
new file mode 100644
index 000..be8482e
--- /dev/null
+++ b/tools/kmod-static-nodes.service.in
@@ -0,0 +1,16 @@
+#  This file is part of kmod.
+#
+#  kmod is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU Lesser General Public License as published by
+#  the Free Software Foundation; either version 2.1 of the License, or
+#  (at your option) any later version.
+
+[Unit]
+Description=Create list of static nodes to be created in /dev
+DefaultDependencies=no
+Before=sysinit.target systemd-static-nodes.service
+
+[Service]
+Type=oneshot
+ExecStart=/bin/mkdir -p /run/tmpfiles.d
+ExecStart=@prefix@/bin/kmod static-nodes