util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] raw: Add raw.service
@ 2019-05-29 22:30 Stanislav Brabec
  2019-05-30 12:35 ` Karel Zak
  0 siblings, 1 reply; 3+ messages in thread
From: Stanislav Brabec @ 2019-05-29 22:30 UTC (permalink / raw)
  To: util-linux; +Cc: Frederic Crozat

Add raw.service that allows to initialize raw devices on boot.

Author: Frederic Crozat <fcrozat@suse.com>
Author: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
---
 configure.ac                 |  9 +++++++++
 disk-utils/.gitignore        |  3 +++
 disk-utils/Makemodule.am     |  9 ++++++++-
 disk-utils/raw.service.8.in  | 27 +++++++++++++++++++++++++++
 disk-utils/raw.service.in.in | 19 +++++++++++++++++++
 5 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 disk-utils/.gitignore
 create mode 100644 disk-utils/raw.service.8.in
 create mode 100644 disk-utils/raw.service.in.in

diff --git a/configure.ac b/configure.ac
index 4b6cacf88..fc7094cd9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2209,6 +2209,14 @@ AS_IF([test "x$with_systemdsystemunitdir" != "xno"], [
   AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
 ])
 
+# Binaries needed by raw.service
+ac_save_PATH="$PATH"
+PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:$PATH"
+AC_PATH_PROG([MODPROBE], [modprobe], [/sbin/modprobe])
+AC_PATH_PROG([UDEVADM], [udevadm], [/sbin/udevadm])
+AC_SUBST([AT], [@])
+PATH="$ac_save_PATH"
+
 
 AC_ARG_WITH([smack],
   AS_HELP_STRING([--with-smack], [build with SMACK support]),
@@ -2428,6 +2436,7 @@ libmount/src/libmount.h
 libsmartcols/docs/Makefile
 libsmartcols/docs/version.xml
 libsmartcols/src/libsmartcols.h
+disk-utils/raw.service.in
 po/Makefile.in
 ])
 
diff --git a/disk-utils/.gitignore b/disk-utils/.gitignore
new file mode 100644
index 000000000..352d191f9
--- /dev/null
+++ b/disk-utils/.gitignore
@@ -0,0 +1,3 @@
+raw.service
+raw.service.8
+raw.service.in
diff --git a/disk-utils/Makemodule.am b/disk-utils/Makemodule.am
index bea0ed6a6..7121f3fd5 100644
--- a/disk-utils/Makemodule.am
+++ b/disk-utils/Makemodule.am
@@ -82,7 +82,7 @@ if BUILD_LIBUUID
 swaplabel_LDADD += libuuid.la
 swaplabel_CFLAGS += -I$(ul_libuuid_incdir)
 endif
-endif #BUILD_SWAPLABEL
+endif # BUILD_SWAPLABEL
 
 
 if BUILD_FSCK
@@ -98,7 +98,14 @@ if BUILD_RAW
 sbin_PROGRAMS += raw
 dist_man_MANS += disk-utils/raw.8
 raw_SOURCES = disk-utils/raw.c
+if HAVE_SYSTEMD
+systemdsystemunit_DATA += \
+		disk-utils/raw.service
+dist_man_MANS += disk-utils/raw.service.8
 endif
+endif # BUILD_RAW
+
+PATHFILES += disk-utils/raw.service disk-utils/raw.service.8
 
 
 if BUILD_CRAMFS
diff --git a/disk-utils/raw.service.8.in b/disk-utils/raw.service.8.in
new file mode 100644
index 000000000..56a4df702
--- /dev/null
+++ b/disk-utils/raw.service.8.in
@@ -0,0 +1,27 @@
+.TH RAW.SERVICE "util-linux" "System Administration"
+.SH NAME
+raw.service \- bind Linux raw character devices on boot
+.SH SYNOPSIS
+.B raw.service
+.SH DESCRIPTION
+.B raw.service
+is used to bind Linux raw character devices to a block devices on boot.
+.SH FILES
+.TP
+.I @sysconfdir@/raw
+List of raw devices to be initialized. Format of lines:
+.sp
+\fIraw_device\fR:\fIbind_device\fR
+.sp
+Devices are specified without leading \fI /dev/raw/\fR resp. \fI/dev/\fR.
+Lines starting with \fI#\fR are interpreted as comments.
+.SH SEE ALSO
+.BR raw (8)
+.SH AUTHORS
+.nf
+Frederic Crozat <fcrozat@suse.com>
+Stanislav Brabec <sbrabec@suse.cz>
+.fi
+.SH AVAILABILITY
+The raw command is part of the util-linux package and is available from
+https://www.kernel.org/pub/linux/utils/util-linux/.
diff --git a/disk-utils/raw.service.in.in b/disk-utils/raw.service.in.in
new file mode 100644
index 000000000..7f2ce865c
--- /dev/null
+++ b/disk-utils/raw.service.in.in
@@ -0,0 +1,19 @@
+[Unit]
+Description=Initialize raw devices
+After=local-fs.target remote-fs.target
+Documentation=man:raw.service(8)
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/bin/sh -c "\
+	@MODPROBE@ raw;\
+	@UDEVADM@ settle;\
+	for i in `grep -v ^# @AT@sysconfdir@AT@/raw`; do\
+		rawdev=`echo $i | cut -f1 -d:`;\
+		rawbind=`echo $i | cut -f2- -d:`;\
+		@AT@sbindir@AT@/raw /dev/raw/$rawdev /dev/$rawbind;\
+	done"
+
+[Install]
+WantedBy=multi-user.target
-- 
2.21.0

-- 
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                         e-mail: sbrabec@suse.com
Křižíkova 148/34 (Corso IIa)                    tel: +420 284 084 060
186 00 Praha 8-Karlín                          fax:  +420 284 084 001
Czech Republic                                    http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76

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

* Re: [PATCH] raw: Add raw.service
  2019-05-29 22:30 [PATCH] raw: Add raw.service Stanislav Brabec
@ 2019-05-30 12:35 ` Karel Zak
  2019-05-30 13:19   ` Karel Zak
  0 siblings, 1 reply; 3+ messages in thread
From: Karel Zak @ 2019-05-30 12:35 UTC (permalink / raw)
  To: Stanislav Brabec; +Cc: util-linux, Frederic Crozat

On Thu, May 30, 2019 at 12:30:16AM +0200, Stanislav Brabec wrote:
> Add raw.service that allows to initialize raw devices on boot.

And why not udev?

For RHEL we install /usr/lib/udev/rules.d/60-raw.rules, the file
contains only example

        #
        # Enter raw device bindings here.
        #
        # An example would be:
        #   ACTION=="add", KERNEL=="sda", RUN+="/usr/bin/raw /dev/raw/raw1 %N"
        # to bind /dev/raw/raw1 to /dev/sda, or
        #   ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/usr/bin/raw /dev/raw/raw2 %M %m"
        # to bind /dev/raw/raw2 to the device with major 8, minor 1.

and users can add theirs devices to the file.

I have talked (on IRC) about it with systemd guys and suggestion is to
do devices initialization in udev when the device is discovered rather
than later in systemd.

I'm also not sure if introduce an extra config file in service is a
good idea.

Maybe all we need is to add any info about udev configuration to
raw(8).

    Karel

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

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

* Re: [PATCH] raw: Add raw.service
  2019-05-30 12:35 ` Karel Zak
@ 2019-05-30 13:19   ` Karel Zak
  0 siblings, 0 replies; 3+ messages in thread
From: Karel Zak @ 2019-05-30 13:19 UTC (permalink / raw)
  To: Stanislav Brabec; +Cc: util-linux, Frederic Crozat

On Thu, May 30, 2019 at 02:35:35PM +0200, Karel Zak wrote:
> On Thu, May 30, 2019 at 12:30:16AM +0200, Stanislav Brabec wrote:
> > Add raw.service that allows to initialize raw devices on boot.
> 
> And why not udev?
...
> Maybe all we need is to add any info about udev configuration to
> raw(8).

And note ... do we really want to improve anything around raw devices?

All we need is to dig really deep grave and keep it there.

So, don't try to make zombies to look nice and user friendly. Zombies
are ugly, deal with it! :-)

    Karel

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

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

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

end of thread, other threads:[~2019-05-30 13:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-29 22:30 [PATCH] raw: Add raw.service Stanislav Brabec
2019-05-30 12:35 ` Karel Zak
2019-05-30 13:19   ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).