2015-02-13 10:43:21 +01:00
|
|
|
---
|
2015-02-16 12:36:25 +01:00
|
|
|
Makefile.am | 19 +++++
|
|
|
|
src/udev/rootsymlink_generator/rootsymlink_generator.c | 57 +++++++++++++++++
|
2015-02-13 10:43:21 +01:00
|
|
|
units/systemd-udev-root-symlink.service | 10 ++
|
|
|
|
units/systemd-udev-root-symlink.service.in | 10 ++
|
2015-02-16 12:36:25 +01:00
|
|
|
4 files changed, 96 insertions(+)
|
2015-02-13 10:43:21 +01:00
|
|
|
|
2015-06-23 14:56:50 +02:00
|
|
|
Index: systemd-221/Makefile.am
|
2014-11-14 13:19:40 +01:00
|
|
|
===================================================================
|
2015-06-23 14:56:50 +02:00
|
|
|
--- systemd-221.orig/Makefile.am
|
|
|
|
+++ systemd-221/Makefile.am
|
|
|
|
@@ -3754,6 +3754,25 @@ EXTRA_DIST += \
|
2015-02-16 12:36:25 +01:00
|
|
|
|
2014-11-14 13:19:40 +01:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
+rootsymlink_generator_SOURCES = \
|
|
|
|
+ src/udev/rootsymlink_generator/rootsymlink_generator.c
|
|
|
|
+
|
|
|
|
+rootsymlink_generator_CFLAGS = \
|
|
|
|
+ $(AM_CFLAGS)
|
|
|
|
+
|
|
|
|
+udevlibexec_PROGRAMS += \
|
|
|
|
+ rootsymlink-generator
|
|
|
|
+
|
|
|
|
+nodist_systemunit_DATA += \
|
|
|
|
+ units/systemd-udev-root-symlink.service
|
|
|
|
+
|
|
|
|
+SYSINIT_TARGET_WANTS += \
|
|
|
|
+ systemd-udev-root-symlink.service
|
|
|
|
+
|
|
|
|
+EXTRA_DIST += \
|
|
|
|
+ units/systemd-udev-root-symlink.service.in
|
|
|
|
+
|
|
|
|
+# ------------------------------------------------------------------------------
|
|
|
|
ata_id_SOURCES = \
|
|
|
|
src/udev/ata_id/ata_id.c
|
|
|
|
|
2015-06-23 14:56:50 +02:00
|
|
|
Index: systemd-221/src/udev/rootsymlink_generator/rootsymlink_generator.c
|
2014-11-14 13:19:40 +01:00
|
|
|
===================================================================
|
|
|
|
--- /dev/null
|
2015-06-23 14:56:50 +02:00
|
|
|
+++ systemd-221/src/udev/rootsymlink_generator/rootsymlink_generator.c
|
2015-02-16 12:36:25 +01:00
|
|
|
@@ -0,0 +1,57 @@
|
2014-11-14 13:19:40 +01:00
|
|
|
+/*
|
|
|
|
+ * Copyright (C) 2014-2015 Robert Milasan <rmilasan@suse.com>
|
|
|
|
+ *
|
|
|
|
+ * This program is free software: you can redistribute it and/or modify
|
|
|
|
+ * it under the terms of the GNU General Public License as published by
|
|
|
|
+ * the Free Software Foundation, either version 2 of the License, or
|
|
|
|
+ * (at your option) any later version.
|
|
|
|
+ *
|
|
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
+ * GNU General Public License for more details.
|
|
|
|
+ *
|
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
|
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+#include <stdio.h>
|
|
|
|
+#include <string.h>
|
|
|
|
+#include <errno.h>
|
|
|
|
+#include <sys/stat.h>
|
|
|
|
+#include <sys/types.h>
|
|
|
|
+#include <fcntl.h>
|
|
|
|
+#include <unistd.h>
|
|
|
|
+
|
|
|
|
+#define BUFFER_SIZE 128
|
|
|
|
+
|
|
|
|
+#define _ROOTDEV_ "/"
|
|
|
|
+#define _PATH_ "/run/udev/rules.d"
|
|
|
|
+#define _FILE_ "10-root-symlink.rules"
|
|
|
|
+
|
2015-02-13 10:43:21 +01:00
|
|
|
+int main(void)
|
2014-11-14 13:19:40 +01:00
|
|
|
+{
|
2015-02-16 12:36:25 +01:00
|
|
|
+ char filename[BUFFER_SIZE], buf[BUFFER_SIZE];
|
2014-11-14 13:19:40 +01:00
|
|
|
+ struct stat statbuf;
|
2015-02-16 12:36:25 +01:00
|
|
|
+ int fd;
|
2014-11-14 13:19:40 +01:00
|
|
|
+
|
2015-02-16 12:36:25 +01:00
|
|
|
+ if (stat(_ROOTDEV_, &statbuf) < 0)
|
2014-11-25 10:47:17 +01:00
|
|
|
+ return 1;
|
2015-02-16 12:36:25 +01:00
|
|
|
+ if (major(statbuf.st_dev) <= 0)
|
|
|
|
+ return 0;
|
|
|
|
+ if (mkdir(_PATH_, 0755) < 0 && errno != EEXIST)
|
|
|
|
+ return errno;
|
|
|
|
+ snprintf(filename, BUFFER_SIZE, "%s/%s", _PATH_, _FILE_);
|
|
|
|
+ fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644);
|
|
|
|
+ if (fd < 0)
|
|
|
|
+ return errno;
|
|
|
|
+ snprintf(buf, BUFFER_SIZE,
|
|
|
|
+ "ACTION==\"add|change\", SUBSYSTEM==\"block\", "
|
|
|
|
+ "ENV{MAJOR}==\"%d\", ENV{MINOR}==\"%d\", SYMLINK+=\"root\"\n",
|
|
|
|
+ major(statbuf.st_dev), minor(statbuf.st_dev));
|
|
|
|
+ if (write(fd, buf, strlen(buf)) < 0)
|
|
|
|
+ return errno;
|
|
|
|
+ if (close(fd) < 0)
|
|
|
|
+ return errno;
|
2014-11-14 13:19:40 +01:00
|
|
|
+ return 0;
|
|
|
|
+}
|
2015-06-23 14:56:50 +02:00
|
|
|
Index: systemd-221/units/systemd-udev-root-symlink.service
|
2014-11-14 13:19:40 +01:00
|
|
|
===================================================================
|
|
|
|
--- /dev/null
|
2015-06-23 14:56:50 +02:00
|
|
|
+++ systemd-221/units/systemd-udev-root-symlink.service
|
2014-11-14 13:19:40 +01:00
|
|
|
@@ -0,0 +1,10 @@
|
|
|
|
+[Unit]
|
|
|
|
+Description=Rule generator for /dev/root symlink
|
|
|
|
+Before=systemd-udevd.service
|
|
|
|
+DefaultDependencies=no
|
|
|
|
+ConditionPathIsReadWrite=/run/udev
|
|
|
|
+
|
|
|
|
+[Service]
|
|
|
|
+Type=oneshot
|
|
|
|
+RemainAfterExit=yes
|
2015-02-13 10:43:21 +01:00
|
|
|
+ExecStart=/usr/lib/udev/rootsymlink-generator
|
2015-06-23 14:56:50 +02:00
|
|
|
Index: systemd-221/units/systemd-udev-root-symlink.service.in
|
2014-11-14 13:19:40 +01:00
|
|
|
===================================================================
|
|
|
|
--- /dev/null
|
2015-06-23 14:56:50 +02:00
|
|
|
+++ systemd-221/units/systemd-udev-root-symlink.service.in
|
2014-11-14 13:19:40 +01:00
|
|
|
@@ -0,0 +1,10 @@
|
|
|
|
+[Unit]
|
|
|
|
+Description=Rule generator for /dev/root symlink
|
|
|
|
+Before=systemd-udevd.service
|
|
|
|
+DefaultDependencies=no
|
|
|
|
+ConditionPathIsReadWrite=/run/udev
|
|
|
|
+
|
|
|
|
+[Service]
|
|
|
|
+Type=oneshot
|
|
|
|
+RemainAfterExit=yes
|
2015-02-13 10:43:21 +01:00
|
|
|
+ExecStart=@udevlibexec@/rootsymlink-generator
|