]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: single binary replacing udevd and udevadm
authorNorbert Lange <nolange79@gmail.com>
Tue, 26 May 2020 08:26:12 +0000 (10:26 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 1 Jun 2020 07:41:21 +0000 (09:41 +0200)
Since the separate binaries contain mostly the same code,
this almost halves the size of the installation.

before:
398K /bin/udevadm
391K /lib/systemd/systemd-udevd

after:
431K /bin/udevadm
0    /lib/systemd/systemd-udevd -> ../../bin/udevadm

Fixes: #14200
meson.build
src/udev/meson.build
src/udev/udevadm.c
src/udev/udevd.c
src/udev/udevd.h [new file with mode: 0644]

index 008fd998e97a93d74584e8bb37fd82f0e21e2aa0..1df2ee86481026f97bc73d160005e9792a51ff52 100644 (file)
@@ -2198,6 +2198,10 @@ foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
                                  join_paths(rootsbindir, alias))
 endforeach
 
+meson.add_install_script(meson_make_symlink,
+                         join_paths(rootbindir, 'udevadm'),
+                         join_paths(rootlibexecdir, 'systemd-udevd'))
+
 if conf.get('ENABLE_BACKLIGHT') == 1
         executable(
                 'systemd-backlight',
@@ -2983,24 +2987,6 @@ public_programs += executable(
         install : true,
         install_dir : rootlibexecdir)
 
-public_programs += executable(
-        'systemd-udevd',
-        systemd_udevd_sources,
-        include_directories : includes,
-        c_args : '-DLOG_REALM=LOG_REALM_UDEV',
-        link_with : [libudev_core,
-                     libsystemd_network,
-                     libudev_static],
-        dependencies : [versiondep,
-                        threads,
-                        libkmod,
-                        libidn,
-                        libacl,
-                        libblkid],
-        install_rpath : udev_rpath,
-        install : true,
-        install_dir : rootlibexecdir)
-
 public_programs += executable(
         'udevadm',
         udevadm_sources,
index 173b10be5050b0a97af9d7c78421ded9a1c46afb..aa23b07090458837902e340682e3948774d18452 100644 (file)
@@ -13,10 +13,9 @@ udevadm_sources = files('''
         udevadm-trigger.c
         udevadm-util.c
         udevadm-util.h
+        udevd.c
 '''.split())
 
-systemd_udevd_sources = files('udevd.c')
-
 libudev_core_sources = '''
         udev-ctrl.c
         udev-ctrl.h
index e6dbb111a9a05b349286ca2d2d1ef91f7e2c0a13..f1115bff7a3ebe3c09ad6e677a27e0bad444972c 100644 (file)
@@ -11,6 +11,7 @@
 #include "selinux-util.h"
 #include "string-util.h"
 #include "udevadm.h"
+#include "udevd.h"
 #include "udev-util.h"
 #include "verbs.h"
 #include "util.h"
@@ -110,6 +111,9 @@ static int udevadm_main(int argc, char *argv[]) {
 static int run(int argc, char *argv[]) {
         int r;
 
+        if (strstr(program_invocation_short_name, "udevd"))
+                return run_udevd(argc, argv);
+
         udev_parse_config();
         log_parse_environment();
         log_open();
index 697fd8a043d7aa2d4b8b8f2e3b66ca52a72317ac..5f5c1e0ae4b4d6b9909e566aaa7a89a3ae4a8c5c 100644 (file)
@@ -59,6 +59,7 @@
 #include "strv.h"
 #include "strxcpyx.h"
 #include "syslog-util.h"
+#include "udevd.h"
 #include "udev-builtin.h"
 #include "udev-ctrl.h"
 #include "udev-event.h"
@@ -1713,7 +1714,7 @@ static int main_loop(Manager *manager) {
         return r;
 }
 
-static int run(int argc, char *argv[]) {
+int run_udevd(int argc, char *argv[]) {
         _cleanup_free_ char *cgroup = NULL;
         _cleanup_(manager_freep) Manager *manager = NULL;
         int fd_ctrl = -1, fd_uevent = -1;
@@ -1828,5 +1829,3 @@ static int run(int argc, char *argv[]) {
 
         return main_loop(manager);
 }
-
-DEFINE_MAIN_FUNCTION(run);
diff --git a/src/udev/udevd.h b/src/udev/udevd.h
new file mode 100644 (file)
index 0000000..848ffc2
--- /dev/null
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+#pragma once
+
+int run_udevd(int argc, char *argv[]);