[PATCH] raw: Add raw.service

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Author: Frederic Crozat <fcrozat@xxxxxxxx>
Author: Stanislav Brabec <sbrabec@xxxxxxx>
Signed-off-by: Stanislav Brabec <sbrabec@xxxxxxx>
---
 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@xxxxxxxx>
+Stanislav Brabec <sbrabec@xxxxxxx>
+.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@xxxxxxxx
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



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux