This package gets the whole systemd repository, compiles it using the bare minimum required stuff, and then installs the udev-specific files. All the remaining generated stuff from systemd, including systemd itself, is ignored in packaging.
Several additional patches were included to enable the compilation of the package with the uClibc toolchain, which lacks several features used within systemd. Signed-off-by: Aleksander Morgado <aleksan...@lanedo.com> --- utils/systemd-udev/Config.in | 58 +++++ utils/systemd-udev/Makefile | 177 ++++++++++++++ ...ine-MS_REC-and-MS_SHARED-if-not-defined-a.patch | 32 +++ .../0002-uclibc-use-plain-getenv-instead.patch | 27 +++ ...0003-uclibc-use-execvp-instead-of-execvpe.patch | 55 +++++ ...04-uclibc-use-mkstemp-instead-of-mkostemp.patch | 258 +++++++++++++++++++++ ...bc-skip-using-unavailable-posix_fallocate.patch | 109 +++++++++ .../0006-uclibc-use-dup2-instead-of-dup3.patch | 86 +++++++ .../patches/0007-test-udev-include-missing.h.patch | 26 +++ 9 files changed, 828 insertions(+) create mode 100644 utils/systemd-udev/Config.in create mode 100644 utils/systemd-udev/Makefile create mode 100644 utils/systemd-udev/patches/0001-missing-define-MS_REC-and-MS_SHARED-if-not-defined-a.patch create mode 100644 utils/systemd-udev/patches/0002-uclibc-use-plain-getenv-instead.patch create mode 100644 utils/systemd-udev/patches/0003-uclibc-use-execvp-instead-of-execvpe.patch create mode 100644 utils/systemd-udev/patches/0004-uclibc-use-mkstemp-instead-of-mkostemp.patch create mode 100644 utils/systemd-udev/patches/0005-uclibc-skip-using-unavailable-posix_fallocate.patch create mode 100644 utils/systemd-udev/patches/0006-uclibc-use-dup2-instead-of-dup3.patch create mode 100644 utils/systemd-udev/patches/0007-test-udev-include-missing.h.patch diff --git a/utils/systemd-udev/Config.in b/utils/systemd-udev/Config.in new file mode 100644 index 0000000..97a89be --- /dev/null +++ b/utils/systemd-udev/Config.in @@ -0,0 +1,58 @@ +# systemd-udev package config + +menu "Configuration" + depends on PACKAGE_systemd-udev + +config SYSTEMD_UDEV_EXTRA_ata_id + bool "Install udev ata_id callout" + default y + help + ata_id - udev callout to read product/serial number + from ATA drives + +config SYSTEMD_UDEV_EXTRA_cdrom_id + bool "Install udev cdrom_id callout" + default y + help + cdrom_id - udev callout to determine the capabilities + of optical drives and media + +config SYSTEMD_UDEV_EXTRA_collect + bool "Install udev collect" + default n + help + Adds ID to the list governed by <checkpoint> + +config SYSTEMD_UDEV_EXTRA_scsi_id + bool "Install udev scsi_id callout" + default y + help + scsi_id - retrieve and generate a unique SCSI identifier + +config SYSTEMD_UDEV_EXTRA_v4l_id + bool "Install udev v4l_id callout" + default y + help + v4l_id - udev callout to identify Video4Linux devices + +config SYSTEMD_UDEV_EXTRA_accelerometer + bool "Install udev accelerometer callout" + default y + help + accelerometer - udev callout to export device orientation + through property + +config SYSTEMD_UDEV_EXTRA_mtd_probe + bool "Install mtd_probe callout" + default y + help + mtd_probe - udev callout to probe mtd devices + +config SYSTEMD_UDEV_EXTRA_qemu + bool "Install qemu specific rules" + default y + help + Install rules for autosuspension of QEMU emulated + USB HID devices + +endmenu diff --git a/utils/systemd-udev/Makefile b/utils/systemd-udev/Makefile new file mode 100644 index 0000000..ffdbe61 --- /dev/null +++ b/utils/systemd-udev/Makefile @@ -0,0 +1,177 @@ +# +# Copyright (C) 2006-2103 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +# Since udev 182, the sources are integrated within the systemd tree. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=systemd +PKG_VERSION:=197 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=http://www.freedesktop.org/software/systemd/ +PKG_MD5SUM:=56a860dceadfafe59f40141eb5223743 + +include $(INCLUDE_DIR)/package.mk + +PKG_INSTALL=1 + +define Package/systemd-udev + SECTION:=utils + CATEGORY:=Utilities + TITLE:=Dynamic device management subsystem + URL:=http://www.freedesktop.org/wiki/Software/systemd/ + MENU:=1 + DEPENDS:=+librt +dbus +libcap +endef + +define Package/systemd-udev/description + udev allows Linux users to have a dynamic /dev directory and it + provides the ability to have persistent device names. +endef + +define Package/systemd-udev/conffiles +/etc/udev/udev.conf +endef + +define Package/systemd-udev/config + source "$(SOURCE)/Config.in" +endef + +CONFIGURE_ARGS += \ + --prefix=/usr \ + --sysconfdir=/etc \ + --without-python \ + --disable-gtk-doc-html \ + --disable-introspection \ + --disable-kmod \ + --disable-blkid \ + --disable-ima \ + --disable-chkconfig \ + --disable-selinux \ + --disable-xz \ + --disable-tcpwrap \ + --disable-pam \ + --disable-acl \ + --disable-xattr \ + --disable-gcrypt \ + --disable-audit \ + --disable-libcryptsetup \ + --disable-qrencode \ + --disable-microhttpd \ + --disable-binfmt \ + --disable-vconsole \ + --disable-readahead \ + --disable-bootchart \ + --disable-quotacheck \ + --disable-randomseed \ + --disable-logind \ + --disable-hostnamed \ + --disable-timedated \ + --disable-localed \ + --disable-coredump \ + --disable-myhostname \ + --disable-gudev \ + --disable-keymap \ + --disable-manpages + +# ata_id callout +systemd-udev-extra-lib-bin-$(CONFIG_SYSTEMD_UDEV_EXTRA_ata_id) += ata_id + +# cdrom_id callout +systemd-udev-extra-lib-bin-$(CONFIG_SYSTEMD_UDEV_EXTRA_cdrom_id) += cdrom_id +systemd-udev-extra-rules-$(CONFIG_SYSTEMD_UDEV_EXTRA_cdrom_id) += 60-cdrom_id.rules + +# collect callout +systemd-udev-extra-lib-bin-$(CONFIG_SYSTEMD_UDEV_EXTRA_collect) += collect + +# scsi_id callout +systemd-udev-extra-lib-bin-$(CONFIG_SYSTEMD_UDEV_EXTRA_scsi_id) += scsi_id + +# v4l_id callout +systemd-udev-extra-lib-bin-$(CONFIG_SYSTEMD_UDEV_EXTRA_v4l_id) += v4l_id +systemd-udev-extra-rules-$(CONFIG_SYSTEMD_UDEV_EXTRA_v4l_id) += 60-persistent-v4l.rules + +# accelerometer callout +systemd-udev-extra-lib-bin-$(CONFIG_SYSTEMD_UDEV_EXTRA_accelerometer) += accelerometer +systemd-udev-extra-rules-$(CONFIG_SYSTEMD_UDEV_EXTRA_accelerometer) += 61-accelerometer.rules + +# mtd_probe callout +systemd-udev-extra-lib-bin-$(CONFIG_SYSTEMD_UDEV_EXTRA_mtd_probe) += mtd_probe +systemd-udev-extra-rules-$(CONFIG_SYSTEMD_UDEV_EXTRA_mtd_probe) += 75-probe_mtd.rules + +# qemu rules +udev-extra-rules-$(CONFIG_SYSTEMD_UDEV_EXTRA_qemu) += 42-usb-hid-pm.rules + +# TODO: keymap + +# TODO: libgudev + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/libudev.h $(1)/usr/include + $(INSTALL_DIR) $(1)/usr/share/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/share/pkgconfig/udev.pc $(1)/usr/share/pkgconfig + $(INSTALL_DIR) $(1)/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libudev.so* $(1)/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsystemd-daemon.so* $(1)/lib + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libudev.pc $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libsystemd-daemon.pc $(1)/usr/lib/pkgconfig +endef + +define Package/systemd-udev/install + $(INSTALL_DIR) $(1)/etc/udev/rules.d + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/udev/udev.conf $(1)/etc/udev + + $(INSTALL_DIR) $(1)/sbin + $(INSTALL_BIN) \ + $(PKG_INSTALL_DIR)/usr/bin/udevadm \ + $(PKG_INSTALL_DIR)/usr/lib/systemd/systemd-udevd \ + $(1)/sbin + + $(INSTALL_DIR) $(1)/lib/udev/rules.d + $(INSTALL_DATA) \ + $(addprefix $(PKG_INSTALL_DIR)/usr/lib/udev/rules.d/, \ + $(udev-extra-rules-y)) \ + $(addprefix $(PKG_INSTALL_DIR)/usr/lib/udev/rules.d/, \ + 50-udev-default.rules \ + 60-persistent-alsa.rules \ + 60-persistent-input.rules \ + 60-persistent-serial.rules \ + 60-persistent-storage.rules \ + 60-persistent-storage-tape.rules \ + 64-btrfs.rules \ + 75-net-description.rules \ + 75-tty-description.rules \ + 78-sound-card.rules \ + 80-net-name-slot.rules \ + 95-udev-late.rules \ + 99-systemd.rules) \ + $(1)/lib/udev/rules.d + + $(INSTALL_DIR) $(1)/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libudev.so* $(1)/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsystemd-daemon.so* $(1)/lib + + $(INSTALL_DIR) $(1)/lib/udev +ifneq ($(systemd-udev-extra-lib-bin-y),) + $(INSTALL_BIN) \ + $(addprefix $(PKG_INSTALL_DIR)/usr/lib/udev/, \ + $(systemd-udev-extra-lib-bin-y)) \ + $(1)/lib/udev/ +endif +ifneq ($(systemd-udev-extra-lib-data-y),) + $(INSTALL_DATA) \ + $(addprefix $(PKG_INSTALL_DIR)/usr/lib/udev/, \ + $(systemd-udev-extra-lib-data-y)) \ + $(1)/lib/udev/ +endif +endef + +$(eval $(call BuildPackage,systemd-udev)) diff --git a/utils/systemd-udev/patches/0001-missing-define-MS_REC-and-MS_SHARED-if-not-defined-a.patch b/utils/systemd-udev/patches/0001-missing-define-MS_REC-and-MS_SHARED-if-not-defined-a.patch new file mode 100644 index 0000000..9df5391 --- /dev/null +++ b/utils/systemd-udev/patches/0001-missing-define-MS_REC-and-MS_SHARED-if-not-defined-a.patch @@ -0,0 +1,32 @@ +From 1125071483e501023ce60f79f27601fba3098cad Mon Sep 17 00:00:00 2001 +From: Aleksander Morgado <aleksan...@lanedo.com> +Date: Tue, 12 Feb 2013 13:07:23 +0100 +Subject: [PATCH 1/7] missing: define MS_REC and MS_SHARED if not defined + already + +--- + src/shared/missing.h | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/src/shared/missing.h b/src/shared/missing.h +index c53579f..d4ba0d3 100644 +--- a/src/shared/missing.h ++++ b/src/shared/missing.h +@@ -196,6 +196,14 @@ static inline pid_t gettid(void) { + #define MS_STRICTATIME (1<<24) + #endif + ++#ifndef MS_REC ++#define MS_REC 16384 ++#endif ++ ++#ifndef MS_SHARED ++#define MS_SHARED (1<<20) ++#endif ++ + #ifndef PR_SET_NO_NEW_PRIVS + #define PR_SET_NO_NEW_PRIVS 38 + #endif +-- +1.8.1.2 + diff --git a/utils/systemd-udev/patches/0002-uclibc-use-plain-getenv-instead.patch b/utils/systemd-udev/patches/0002-uclibc-use-plain-getenv-instead.patch new file mode 100644 index 0000000..f04bb37 --- /dev/null +++ b/utils/systemd-udev/patches/0002-uclibc-use-plain-getenv-instead.patch @@ -0,0 +1,27 @@ +From a2fbd49c5d0b73e2f6c1a0482fc7c3d40b23829e Mon Sep 17 00:00:00 2001 +From: Aleksander Morgado <aleksan...@lanedo.com> +Date: Mon, 11 Feb 2013 14:47:49 +0100 +Subject: [PATCH 2/7] uclibc: use plain getenv() instead + +uclibc doesn't implement secure_getenv(), fallback to getenv() instead just to +get this compiled. +--- + src/shared/missing.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/shared/missing.h b/src/shared/missing.h +index d4ba0d3..865f16b 100644 +--- a/src/shared/missing.h ++++ b/src/shared/missing.h +@@ -254,7 +254,7 @@ static inline int name_to_handle_at(int fd, const char *name, struct file_handle + # ifdef HAVE___SECURE_GETENV + # define secure_getenv __secure_getenv + # else +-# error neither secure_getenv nor __secure_getenv are available ++# define secure_getenv getenv + # endif + #endif + +-- +1.8.1.2 + diff --git a/utils/systemd-udev/patches/0003-uclibc-use-execvp-instead-of-execvpe.patch b/utils/systemd-udev/patches/0003-uclibc-use-execvp-instead-of-execvpe.patch new file mode 100644 index 0000000..e1666e6 --- /dev/null +++ b/utils/systemd-udev/patches/0003-uclibc-use-execvp-instead-of-execvpe.patch @@ -0,0 +1,55 @@ +From e2d2de2ac6a60d2a1bac09dcdb09021961172e93 Mon Sep 17 00:00:00 2001 +From: Aleksander Morgado <aleksan...@lanedo.com> +Date: Tue, 12 Feb 2013 15:04:12 +0100 +Subject: [PATCH 3/7] uclibc: use execvp instead of execvpe + +--- + configure.ac | 1 + + src/nspawn/nspawn.c | 11 +++++++++-- + 2 files changed, 10 insertions(+), 2 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 56694ff..4a481a7 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -193,6 +193,7 @@ CAP_LIBS="$LIBS" + LIBS="$save_LIBS" + AC_SUBST(CAP_LIBS) + ++AC_CHECK_FUNCS([execvpe]) + AC_CHECK_FUNCS([fanotify_init fanotify_mark]) + AC_CHECK_FUNCS([__secure_getenv secure_getenv]) + AC_CHECK_DECLS([gettid, pivot_root, name_to_handle_at], [], [], [[#include <sys/types.h> +diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c +index 4c87371..68f7436 100644 +--- a/src/nspawn/nspawn.c ++++ b/src/nspawn/nspawn.c +@@ -58,6 +58,8 @@ + #include "fdset.h" + #include "build.h" + ++#include "config.h" ++ + typedef enum LinkJournal { + LINK_NO, + LINK_AUTO, +@@ -1468,9 +1470,14 @@ int main(int argc, char *argv[]) { + + a[0] = (char*) "/sbin/init"; + execve(a[0], a, (char**) envp); +- } else if (argc > optind) ++ } else if (argc > optind) { ++#ifdef HAVE_EXECVPE + execvpe(argv[optind], argv + optind, (char**) envp); +- else { ++#else ++ environ = (char **)envp; ++ execvp(argv[optind], argv + optind); ++#endif /* HAVE_EXECVPE */ ++ }else { + chdir(home ? home : "/root"); + execle("/bin/bash", "-bash", NULL, (char**) envp); + } +-- +1.8.1.2 + diff --git a/utils/systemd-udev/patches/0004-uclibc-use-mkstemp-instead-of-mkostemp.patch b/utils/systemd-udev/patches/0004-uclibc-use-mkstemp-instead-of-mkostemp.patch new file mode 100644 index 0000000..40c5c75 --- /dev/null +++ b/utils/systemd-udev/patches/0004-uclibc-use-mkstemp-instead-of-mkostemp.patch @@ -0,0 +1,258 @@ +From b4f13b8f304175b8999fef41685bba73c24d3e4f Mon Sep 17 00:00:00 2001 +From: Aleksander Morgado <aleksan...@lanedo.com> +Date: Tue, 12 Feb 2013 15:16:16 +0100 +Subject: [PATCH 4/7] uclibc: use mkstemp instead of mkostemp + +--- + configure.ac | 2 +- + src/core/manager.c | 10 ++++++++++ + src/journal/coredumpctl.c | 6 ++++++ + src/journal/journal-send.c | 9 +++++++++ + src/journal/journal-verify.c | 23 +++++++++++++++++++++++ + src/journal/journalctl.c | 10 ++++++++++ + src/shared/ask-password-api.c | 10 ++++++++++ + src/shared/util.c | 9 +++++++++ + 8 files changed, 78 insertions(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 4a481a7..f02cfdc 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -193,7 +193,7 @@ CAP_LIBS="$LIBS" + LIBS="$save_LIBS" + AC_SUBST(CAP_LIBS) + +-AC_CHECK_FUNCS([execvpe]) ++AC_CHECK_FUNCS([execvpe mkostemp]) + AC_CHECK_FUNCS([fanotify_init fanotify_mark]) + AC_CHECK_FUNCS([__secure_getenv secure_getenv]) + AC_CHECK_DECLS([gettid, pivot_root, name_to_handle_at], [], [], [[#include <sys/types.h> +diff --git a/src/core/manager.c b/src/core/manager.c +index 4bebb29..84a379b 100644 +--- a/src/core/manager.c ++++ b/src/core/manager.c +@@ -73,6 +73,8 @@ + #include "efivars.h" + #include "env-util.h" + ++#include "config.h" ++ + /* As soon as 16 units are in our GC queue, make sure to run a gc sweep */ + #define GC_QUEUE_ENTRIES_MAX 16 + +@@ -1830,7 +1832,15 @@ int manager_open_serialization(Manager *m, FILE **_f) { + return -ENOMEM; + + saved_umask = umask(0077); ++ ++#ifdef HAVE_MKOSTEMP + fd = mkostemp(path, O_RDWR|O_CLOEXEC); ++#else ++ fd = mkstemp(path); ++ if (fd >= 0) ++ fcntl(fd, F_SETFD, FD_CLOEXEC); ++#endif /* HAVE_MKOSTEMP */ ++ + umask(saved_umask); + + if (fd < 0) { +diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c +index b6e5581..74e1489 100644 +--- a/src/journal/coredumpctl.c ++++ b/src/journal/coredumpctl.c +@@ -35,6 +35,8 @@ + #include "path-util.h" + #include "pager.h" + ++#include "config.h" ++ + static enum { + ACTION_NONE, + ACTION_LIST, +@@ -472,7 +474,11 @@ static int run_gdb(sd_journal *j) { + data = (const uint8_t*) data + 9; + len -= 9; + ++#ifdef HAVE_MKOSTEMP + fd = mkostemp(path, O_WRONLY); ++#else ++ fd = mkstemp(path); ++#endif + if (fd < 0) { + log_error("Failed to create temporary file: %m"); + return -errno; +diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c +index d5ec73e..32f9eba9 100644 +--- a/src/journal/journal-send.c ++++ b/src/journal/journal-send.c +@@ -33,6 +33,8 @@ + #include "util.h" + #include "socket-util.h" + ++#include "config.h" ++ + #define SNDBUF_SIZE (8*1024*1024) + + #define ALLOCA_CODE_FUNC(f, func) \ +@@ -330,7 +332,14 @@ _public_ int sd_journal_sendv(const struct iovec *iov, int n) { + * file and just pass a file descriptor of it to the other + * side */ + ++#ifdef HAVE_MKOSTEMP + buffer_fd = mkostemp(path, O_CLOEXEC|O_RDWR); ++#else ++ buffer_fd = mkstemp(path); ++ if (buffer_fd >= 0) ++ fcntl(buffer_fd, F_SETFD, FD_CLOEXEC); ++#endif /* HAVE_MKOSTEMP */ ++ + if (buffer_fd < 0) { + r = -errno; + goto finish; +diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c +index ed28b45..f9e1dba 100644 +--- a/src/journal/journal-verify.c ++++ b/src/journal/journal-verify.c +@@ -34,6 +34,8 @@ + #include "compress.h" + #include "fsprg.h" + ++#include "config.h" ++ + static int journal_file_object_verify(JournalFile *f, Object *o) { + uint64_t i; + +@@ -701,7 +703,14 @@ int journal_file_verify( + } else if (f->seal) + return -ENOKEY; + ++#ifdef HAVE_MKOSTEMP + data_fd = mkostemp(data_path, O_CLOEXEC); ++#else ++ data_fd = mkstemp(data_path); ++ if (data_fd >= 0) ++ fcntl(data_fd, F_SETFD, FD_CLOEXEC); ++#endif /* HAVE_MKOSTEMP */ ++ + if (data_fd < 0) { + log_error("Failed to create data file: %m"); + r = -errno; +@@ -709,7 +718,14 @@ int journal_file_verify( + } + unlink(data_path); + ++#ifdef HAVE_MKOSTEMP + entry_fd = mkostemp(entry_path, O_CLOEXEC); ++#else ++ entry_fd = mkstemp(entry_path); ++ if (entry_fd >= 0) ++ fcntl(entry_fd, F_SETFD, FD_CLOEXEC); ++#endif /* HAVE_MKOSTEMP */ ++ + if (entry_fd < 0) { + log_error("Failed to create entry file: %m"); + r = -errno; +@@ -717,7 +733,14 @@ int journal_file_verify( + } + unlink(entry_path); + ++#ifdef HAVE_MKOSTEMP + entry_array_fd = mkostemp(entry_array_path, O_CLOEXEC); ++#else ++ entry_array_fd = mkstemp(entry_array_path); ++ if (entry_array_fd >= 0) ++ fcntl(entry_array_fd, F_SETFD, FD_CLOEXEC); ++#endif /* HAVE_MKOSTEMP */ ++ + if (entry_array_fd < 0) { + log_error("Failed to create entry array file: %m"); + r = -errno; +diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c +index 0afeef9..a00010c 100644 +--- a/src/journal/journalctl.c ++++ b/src/journal/journalctl.c +@@ -53,6 +53,8 @@ + #include "unit-name.h" + #include "catalog.h" + ++#include "config.h" ++ + #define DEFAULT_FSS_INTERVAL_USEC (15*USEC_PER_MINUTE) + + static OutputMode arg_output = OUTPUT_SHORT; +@@ -679,7 +681,15 @@ static int setup_keys(void) { + n /= arg_interval; + + close_nointr_nofail(fd); ++ ++#ifdef HAVE_MKOSTEMP + fd = mkostemp(k, O_WRONLY|O_CLOEXEC|O_NOCTTY); ++#else ++ fd = mkstemp(k); ++ if (fd >= 0) ++ fcntl(fd, F_SETFD, FD_CLOEXEC); ++#endif /* HAVE_MKOSTEMP */ ++ + if (fd < 0) { + log_error("Failed to open %s: %m", k); + r = -errno; +diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c +index 8a0fb89..e5e9afd 100644 +--- a/src/shared/ask-password-api.c ++++ b/src/shared/ask-password-api.c +@@ -37,6 +37,8 @@ + + #include "ask-password-api.h" + ++#include "config.h" ++ + static void backspace_chars(int ttyfd, size_t p) { + + if (ttyfd < 0) +@@ -326,7 +328,15 @@ int ask_password_agent( + mkdir_p_label("/run/systemd/ask-password", 0755); + + u = umask(0022); ++ ++#ifdef HAVE_MKOSTEMP + fd = mkostemp(temp, O_CLOEXEC|O_CREAT|O_WRONLY); ++#else ++ fd = mkstemp(temp); ++ if (fd >= 0) ++ fcntl(fd, F_SETFD, FD_CLOEXEC); ++#endif /* HAVE_MKOSTEMP */ ++ + umask(u); + + if (fd < 0) { +diff --git a/src/shared/util.c b/src/shared/util.c +index 24f9e7e..35cee2a 100644 +--- a/src/shared/util.c ++++ b/src/shared/util.c +@@ -72,6 +72,8 @@ + #include "hashmap.h" + #include "env-util.h" + ++#include "config.h" ++ + int saved_argc = 0; + char **saved_argv = NULL; + +@@ -4144,7 +4146,14 @@ int fopen_temporary(const char *path, FILE **_f, char **_temp_path) { + t[k] = '.'; + stpcpy(stpcpy(t+k+1, fn), "XXXXXX"); + ++#ifdef HAVE_MKOSTEMP + fd = mkostemp(t, O_WRONLY|O_CLOEXEC); ++#else ++ fd = mkstemp(t); ++ if (fd >= 0) ++ fcntl(fd, F_SETFD, FD_CLOEXEC); ++#endif /* HAVE_MKOSTEMP */ ++ + if (fd < 0) { + free(t); + return -errno; +-- +1.8.1.2 + diff --git a/utils/systemd-udev/patches/0005-uclibc-skip-using-unavailable-posix_fallocate.patch b/utils/systemd-udev/patches/0005-uclibc-skip-using-unavailable-posix_fallocate.patch new file mode 100644 index 0000000..fbe9838 --- /dev/null +++ b/utils/systemd-udev/patches/0005-uclibc-skip-using-unavailable-posix_fallocate.patch @@ -0,0 +1,109 @@ +From b9f0b9ba87c58a38b8c4116a5cffc5b1cfa4ff34 Mon Sep 17 00:00:00 2001 +From: Aleksander Morgado <aleksan...@lanedo.com> +Date: Tue, 12 Feb 2013 15:25:42 +0100 +Subject: [PATCH 5/7] uclibc: skip using unavailable posix_fallocate() + +--- + configure.ac | 2 +- + src/journal/journal-file.c | 19 ++++++++++++++++++- + src/journal/journald-kmsg.c | 16 ++++++++++++++-- + 3 files changed, 33 insertions(+), 4 deletions(-) + +diff --git a/configure.ac b/configure.ac +index f02cfdc..dbb2680 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -193,7 +193,7 @@ CAP_LIBS="$LIBS" + LIBS="$save_LIBS" + AC_SUBST(CAP_LIBS) + +-AC_CHECK_FUNCS([execvpe mkostemp]) ++AC_CHECK_FUNCS([execvpe mkostemp posix_fallocate]) + AC_CHECK_FUNCS([fanotify_init fanotify_mark]) + AC_CHECK_FUNCS([__secure_getenv secure_getenv]) + AC_CHECK_DECLS([gettid, pivot_root, name_to_handle_at], [], [], [[#include <sys/types.h> +diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c +index 13fc8ed..df4333b 100644 +--- a/src/journal/journal-file.c ++++ b/src/journal/journal-file.c +@@ -38,6 +38,8 @@ + #include "compress.h" + #include "fsprg.h" + ++#include "config.h" ++ + #define DEFAULT_DATA_HASH_TABLE_SIZE (2047ULL*sizeof(HashItem)) + #define DEFAULT_FIELD_HASH_TABLE_SIZE (333ULL*sizeof(HashItem)) + +@@ -276,7 +278,7 @@ static int journal_file_verify_header(JournalFile *f) { + + static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) { + uint64_t old_size, new_size; +- int r; ++ int r = 0; + + assert(f); + +@@ -321,10 +323,25 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) + /* Note that the glibc fallocate() fallback is very + inefficient, hence we try to minimize the allocation area + as we can. */ ++#ifdef HAVE_POSIX_ALLOCATE + r = posix_fallocate(f->fd, old_size, new_size - old_size); + if (r != 0) + return -r; + ++#else ++ /* Use good old method to write zeros into the journal file ++ perhaps very inefficient yet working. */ ++ if(new_size > old_size) { ++ char *buf = alloca(new_size - old_size); ++ off_t oldpos = lseek(f->fd, 0, SEEK_CUR); ++ bzero(buf, new_size - old_size); ++ lseek(f->fd, old_size, SEEK_SET); ++ r = write(f->fd, buf, new_size - old_size); ++ lseek(f->fd, oldpos, SEEK_SET); ++ } ++ if (r < 0) ++ return -errno; ++#endif /* HAVE_POSIX_FALLOCATE */ + if (fstat(f->fd, &f->last_stat) < 0) + return -errno; + +diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c +index b819876..0d18bba 100644 +--- a/src/journal/journald-kmsg.c ++++ b/src/journal/journald-kmsg.c +@@ -404,6 +404,7 @@ int server_open_dev_kmsg(Server *s) { + + int server_open_kernel_seqnum(Server *s) { + int fd; ++ int r = 0; + uint64_t *p; + + assert(s); +@@ -417,8 +418,19 @@ int server_open_kernel_seqnum(Server *s) { + log_error("Failed to open /run/systemd/journal/kernel-seqnum, ignoring: %m"); + return 0; + } +- +- if (posix_fallocate(fd, 0, sizeof(uint64_t)) < 0) { ++#ifdef HAVE_POSIX_ALLOCATE ++ r = posix_fallocate(fd, 0, sizeof(uint64_t)); ++#else ++ /* Use good old method to write zeros into the journal file ++ perhaps very inefficient yet working. */ ++ char *buf = alloca(sizeof(uint64_t)); ++ off_t oldpos = lseek(fd, 0, SEEK_CUR); ++ bzero(buf, sizeof(uint64_t)); ++ lseek(fd, 0, SEEK_SET); ++ r = write(fd, buf, sizeof(uint64_t)); ++ lseek(fd, oldpos, SEEK_SET); ++#endif /* HAVE_POSIX_FALLOCATE */ ++ if (r < 0) { + log_error("Failed to allocate sequential number file, ignoring: %m"); + close_nointr_nofail(fd); + return 0; +-- +1.8.1.2 + diff --git a/utils/systemd-udev/patches/0006-uclibc-use-dup2-instead-of-dup3.patch b/utils/systemd-udev/patches/0006-uclibc-use-dup2-instead-of-dup3.patch new file mode 100644 index 0000000..4844185 --- /dev/null +++ b/utils/systemd-udev/patches/0006-uclibc-use-dup2-instead-of-dup3.patch @@ -0,0 +1,86 @@ +From 868897a6c4af2b8b27805ae097890630bfb202c4 Mon Sep 17 00:00:00 2001 +From: Aleksander Morgado <aleksan...@lanedo.com> +Date: Tue, 12 Feb 2013 15:35:01 +0100 +Subject: [PATCH 6/7] uclibc: use dup2() instead of dup3() + +--- + configure.ac | 2 +- + src/journal/cat.c | 11 +++++++++++ + src/shared/util.c | 6 ++++++ + 3 files changed, 18 insertions(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index dbb2680..98d9413 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -193,7 +193,7 @@ CAP_LIBS="$LIBS" + LIBS="$save_LIBS" + AC_SUBST(CAP_LIBS) + +-AC_CHECK_FUNCS([execvpe mkostemp posix_fallocate]) ++AC_CHECK_FUNCS([execvpe mkostemp posix_fallocate dup3]) + AC_CHECK_FUNCS([fanotify_init fanotify_mark]) + AC_CHECK_FUNCS([__secure_getenv secure_getenv]) + AC_CHECK_DECLS([gettid, pivot_root, name_to_handle_at], [], [], [[#include <sys/types.h> +diff --git a/src/journal/cat.c b/src/journal/cat.c +index a95392c..f631f2b 100644 +--- a/src/journal/cat.c ++++ b/src/journal/cat.c +@@ -32,6 +32,8 @@ + #include "util.h" + #include "build.h" + ++#include "config.h" ++ + static char *arg_identifier = NULL; + static int arg_priority = LOG_INFO; + static bool arg_level_prefix = true; +@@ -143,8 +145,13 @@ int main(int argc, char *argv[]) { + + saved_stderr = fcntl(STDERR_FILENO, F_DUPFD_CLOEXEC, 3); + ++#if HAVE_DUP3 + if (dup3(fd, STDOUT_FILENO, 0) < 0 || + dup3(fd, STDERR_FILENO, 0) < 0) { ++#else ++ if (dup2(fd, STDOUT_FILENO) < 0 || ++ dup2(fd, STDERR_FILENO) < 0) { ++#endif /* HAVE_DUP3 */ + log_error("Failed to duplicate fd: %m"); + r = -errno; + goto finish; +@@ -164,7 +171,11 @@ int main(int argc, char *argv[]) { + + /* Let's try to restore a working stderr, so we can print the error message */ + if (saved_stderr >= 0) ++#if HAVE_DUP3 + dup3(saved_stderr, STDERR_FILENO, 0); ++#else ++ dup2(saved_stderr, STDERR_FILENO); ++#endif /* HAVE_DUP3 */ + + log_error("Failed to execute process: %s", strerror(-r)); + +diff --git a/src/shared/util.c b/src/shared/util.c +index 35cee2a..659f650 100644 +--- a/src/shared/util.c ++++ b/src/shared/util.c +@@ -2600,9 +2600,15 @@ int make_stdio(int fd) { + + assert(fd >= 0); + ++#if HAVE_DUP3 + r = dup3(fd, STDIN_FILENO, 0); + s = dup3(fd, STDOUT_FILENO, 0); + t = dup3(fd, STDERR_FILENO, 0); ++#else ++ r = dup2(fd, STDIN_FILENO); ++ s = dup2(fd, STDOUT_FILENO); ++ t = dup2(fd, STDERR_FILENO); ++#endif /* HAVE_DUP3 */ + + if (fd >= 3) + close_nointr_nofail(fd); +-- +1.8.1.2 + diff --git a/utils/systemd-udev/patches/0007-test-udev-include-missing.h.patch b/utils/systemd-udev/patches/0007-test-udev-include-missing.h.patch new file mode 100644 index 0000000..4f14308 --- /dev/null +++ b/utils/systemd-udev/patches/0007-test-udev-include-missing.h.patch @@ -0,0 +1,26 @@ +From c3b23153355fd3dbcf0a6be300b295c62423377b Mon Sep 17 00:00:00 2001 +From: Aleksander Morgado <aleksan...@lanedo.com> +Date: Tue, 12 Feb 2013 15:38:48 +0100 +Subject: [PATCH 7/7] test-udev: include missing.h + +We need MS_REC and MS_SHARED defined for a proper compilation, so get them from +'missing.h' if not defined already. +--- + src/test/test-udev.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/test/test-udev.c b/src/test/test-udev.c +index 7cb93ed..aee87f7 100644 +--- a/src/test/test-udev.c ++++ b/src/test/test-udev.c +@@ -32,6 +32,7 @@ + #include <sys/mount.h> + #include <sys/signalfd.h> + ++#include "missing.h" + #include "udev.h" + + void udev_main_log(struct udev *udev, int priority, +-- +1.8.1.2 + -- 1.8.1.2 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel