[systemd-commits] 5 commits - Makefile.am man/udevadm.xml shell-completion/systemd-bash-completion.sh shell-completion/systemd-zsh-completion.zsh src/core src/journal src/libudev src/shared src/udev
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Fri Nov 16 16:29:34 PST 2012
Makefile.am | 24 ++++++++++++++++++++----
man/udevadm.xml | 4 ++--
shell-completion/systemd-bash-completion.sh | 2 +-
shell-completion/systemd-zsh-completion.zsh | 4 +++-
src/core/macros.systemd.in | 4 ++--
src/journal/catalog.c | 5 ++---
src/journal/sd-journal.c | 2 +-
src/libudev/libudev-hwdb.c | 10 +++++-----
src/shared/util.c | 18 ++++++++++--------
src/udev/udevadm-hwdb.c | 7 ++++---
10 files changed, 50 insertions(+), 30 deletions(-)
New commits:
commit 12514db7d099bd66ad71cd4684bbf97a200b08fa
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Fri Nov 16 23:41:58 2012 +0100
shell-completion: add catalog options
diff --git a/shell-completion/systemd-bash-completion.sh b/shell-completion/systemd-bash-completion.sh
index 4c8161f..2d425c0 100644
--- a/shell-completion/systemd-bash-completion.sh
+++ b/shell-completion/systemd-bash-completion.sh
@@ -297,7 +297,7 @@ _journalctl() {
[STANDALONE]='-a --all -b --this-boot --disk-usage -f --follow --header
-h --help -l --local --new-id128 -m --merge --no-pager
--no-tail -q --quiet --setup-keys --this-boot --verify
- --version'
+ --version --list-catalog --update-catalog'
[ARG]='-D --directory -F --field -o --output -u --unit'
[ARGUNKNOWN]='-c --cursor --interval -n --lines -p --priority --since --until
--verify-key'
diff --git a/shell-completion/systemd-zsh-completion.zsh b/shell-completion/systemd-zsh-completion.zsh
index 59755e6..5f75bc3 100644
--- a/shell-completion/systemd-zsh-completion.zsh
+++ b/shell-completion/systemd-zsh-completion.zsh
@@ -91,7 +91,9 @@ _ctls()
'--disk-usage[Show total disk usage]' \
{-F,--field=}'[List all values a certain field takes]:Fields:_list_fields' \
'--setup-keys[Generate new FSS key pair]' \
- '--verify[Verify journal file consistency]'
+ '--verify[Verify journal file consistency]' \
+ '--list-catalog[List messages in catalog]' \
+ '--update-catalog[Update binary catalog database]' \
;;
localectl)
_arguments \
commit 0a496c9836cabf6448b3bc08161cdd677092e9ef
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Fri Nov 16 23:19:35 2012 +0100
rpm: udevadm is actually in bindir
diff --git a/src/core/macros.systemd.in b/src/core/macros.systemd.in
index f77082c..647cce6 100644
--- a/src/core/macros.systemd.in
+++ b/src/core/macros.systemd.in
@@ -61,11 +61,11 @@ fi \
%{nil}
%udev_hwdb_update() \
- at rootbindir@/udevadm hwdb --update >/dev/null 2>&1 || : \
+ at bindir@/udevadm hwdb --update >/dev/null 2>&1 || : \
%{nil}
%udev_rules_update() \
- at rootbindir@/udevadm control --reload >/dev/null 2>&1 || : \
+ at bindir@/udevadm control --reload >/dev/null 2>&1 || : \
%{nil}
%journal_catalog_update() \
commit ee623f0d0c04a9c8da4953ddc29862c8c4945458
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Fri Nov 16 23:10:13 2012 +0100
hwdb: use $(localstatedir)/lib/udev/hwdb.bin for the binary database
It's not configuration, so it doesn't belong in udev.
Also, remove the catalog when uninstalling udev.
diff --git a/Makefile.am b/Makefile.am
index f3bda01..1f30ba8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -65,6 +65,8 @@ sysvinitdir=$(SYSTEM_SYSVINIT_PATH)
varlogdir=$(localstatedir)/log
systemdstatedir=$(localstatedir)/lib/systemd
catalogstatedir=$(systemdstatedir)/catalog
+udevstatedir=$(localstatedir)/lib/udev
+hwdb_bin=$(udevstatedir)/hwdb.bin
# Our own, non-special dirs
pkgsysconfdir=$(sysconfdir)/systemd
@@ -130,6 +132,7 @@ AM_CPPFLAGS = \
-DUSER_CONFIG_UNIT_PATH=\"$(pkgsysconfdir)/user\" \
-DUSER_DATA_UNIT_PATH=\"$(userunitdir)\" \
-DCATALOG_PATH=\"$(catalogstatedir)\" \
+ -DHWDB_BIN=\"$(hwdb_bin)\" \
-DSYSTEMD_CGROUP_AGENT_PATH=\"$(rootlibexecdir)/systemd-cgroups-agent\" \
-DSYSTEMD_BINARY_PATH=\"$(rootlibexecdir)/systemd\" \
-DSYSTEMD_SHUTDOWN_BINARY_PATH=\"$(rootlibexecdir)/systemd-shutdown\" \
@@ -1962,11 +1965,14 @@ udevadm_LDADD = \
# Update hwdb on installation. Do not bother if installing
# in DESTDIR, since this is likely for packaging purposes.
hwdb-update-hook:
- -test -n "$(DESTDIR)" || udevadm hwdb --update
+ -test -n "$(DESTDIR)" || $(bindir)/udevadm hwdb --update
INSTALL_DATA_HOOKS += \
hwdb-update-hook
+hwdb-remove-hook:
+ -test -n "$(DESTDIR)" || rm -f $(HWDB_BIN)
+
# ------------------------------------------------------------------------------
TESTS += \
test/udev-test.pl \
diff --git a/man/udevadm.xml b/man/udevadm.xml
index 015980a..43d2f5b 100644
--- a/man/udevadm.xml
+++ b/man/udevadm.xml
@@ -424,13 +424,13 @@
</refsect2>
<refsect2><title>udevadm hwdb <optional>options</optional></title>
- <para>Maintain the hardware database index in /etc/udev/hwdb.bin.</para>
+ <para>Maintain the hardware database index in <filename>$(localstatedir)/lib/udev/hwdb.bin</filename>.</para>
<variablelist>
<varlistentry>
<term><option>--update</option></term>
<listitem>
<para>Compile the hardware dabase information located in /usr/lib/udev/hwdb.d/,
- /etc/udev/hwdb.d/ and store it in /etc/udev/hwdb.bin. This should be done with
+ /etc/udev/hwdb.d/ and store it in <filename>$(localstatedir)/lib/udev/hwdb.bin</filename>. This should be done with
any update to the source files, it will not be called automatically. The running
udev daemon will detect a new database on its own and does not need to be
notified about it.</para>
diff --git a/src/libudev/libudev-hwdb.c b/src/libudev/libudev-hwdb.c
index 6779e45..12c8214 100644
--- a/src/libudev/libudev-hwdb.c
+++ b/src/libudev/libudev-hwdb.c
@@ -271,30 +271,30 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
hwdb->refcount = 1;
udev_list_init(udev, &hwdb->properties_list, true);
- hwdb->f = fopen("/etc/udev/hwdb.bin", "re");
+ hwdb->f = fopen(HWDB_BIN, "re");
if (!hwdb->f) {
- log_debug("error reading /etc/udev/hwdb.bin: %m");
+ log_debug("error reading %s: %m", HWDB_BIN);
udev_hwdb_unref(hwdb);
return NULL;
}
if (fstat(fileno(hwdb->f), &hwdb->st) < 0 ||
(size_t)hwdb->st.st_size < offsetof(struct trie_header_f, strings_len) + 8) {
- log_debug("error reading /etc/udev/hwdb.bin: %m");
+ log_debug("error reading %s: %m", HWDB_BIN);
udev_hwdb_unref(hwdb);
return NULL;
}
hwdb->map = mmap(0, hwdb->st.st_size, PROT_READ, MAP_SHARED, fileno(hwdb->f), 0);
if (hwdb->map == MAP_FAILED) {
- log_debug("error mapping /etc/udev/hwdb.bin: %m");
+ log_debug("error mapping %s: %m", HWDB_BIN);
udev_hwdb_unref(hwdb);
return NULL;
}
if (memcmp(hwdb->map, sig, sizeof(hwdb->head->signature)) != 0 ||
(size_t)hwdb->st.st_size != le64toh(hwdb->head->file_size)) {
- log_debug("error recognizing the format of /etc/udev/hwdb.bin");
+ log_debug("error recognizing the format of %s", HWDB_BIN);
udev_hwdb_unref(hwdb);
return NULL;
}
diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c
index 02d8d01..fd288db 100644
--- a/src/udev/udevadm-hwdb.c
+++ b/src/udev/udevadm-hwdb.c
@@ -565,10 +565,11 @@ static int adm_hwdb(struct udev *udev, int argc, char *argv[]) {
log_debug("strings dedup'ed: %8zu bytes (%8zu)\n",
trie->strings->dedup_len, trie->strings->dedup_count);
- mkdir_parents("/etc/udev/hwdb.bin", 0755);
- err = trie_store(trie, "/etc/udev/hwdb.bin");
+ mkdir_parents(HWDB_BIN, 0755);
+ err = trie_store(trie, HWDB_BIN);
if (err < 0) {
- log_error("Failure writing hardware database '%s': %s", "/etc/udev/hwdb.bin", strerror(-err));
+ log_error("Failure writing hardware database '%s': %s",
+ HWDB_BIN, strerror(-err));
rc = EXIT_FAILURE;
}
}
commit 4ec24515daa780118709e04cd78dae93f25a8428
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Fri Nov 16 23:08:27 2012 +0100
journal: use $(localstatedir)/lib/systemd/catalog for the catalog
The path doesn't change in the standard configuration.
Also, give full path to the journalctl binary in the hook,
since it might be installed outside of $PATH.
Also, add uninstall hook to remove the binary catalog.
diff --git a/Makefile.am b/Makefile.am
index 7860174..f3bda01 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -63,6 +63,8 @@ bashcompletiondir=$(sysconfdir)/bash_completion.d
rpmmacrosdir=$(sysconfdir)/rpm
sysvinitdir=$(SYSTEM_SYSVINIT_PATH)
varlogdir=$(localstatedir)/log
+systemdstatedir=$(localstatedir)/lib/systemd
+catalogstatedir=$(systemdstatedir)/catalog
# Our own, non-special dirs
pkgsysconfdir=$(sysconfdir)/systemd
@@ -94,6 +96,7 @@ BUILT_SOURCES =
INSTALL_EXEC_HOOKS =
UNINSTALL_EXEC_HOOKS =
INSTALL_DATA_HOOKS =
+UNINSTALL_DATA_HOOKS =
DISTCLEAN_LOCAL_HOOKS =
pkginclude_HEADERS =
noinst_LTLIBRARIES =
@@ -126,6 +129,7 @@ AM_CPPFLAGS = \
-DUSER_CONFIG_FILE=\"$(pkgsysconfdir)/user.conf\" \
-DUSER_CONFIG_UNIT_PATH=\"$(pkgsysconfdir)/user\" \
-DUSER_DATA_UNIT_PATH=\"$(userunitdir)\" \
+ -DCATALOG_PATH=\"$(catalogstatedir)\" \
-DSYSTEMD_CGROUP_AGENT_PATH=\"$(rootlibexecdir)/systemd-cgroups-agent\" \
-DSYSTEMD_BINARY_PATH=\"$(rootlibexecdir)/systemd\" \
-DSYSTEMD_SHUTDOWN_BINARY_PATH=\"$(rootlibexecdir)/systemd-shutdown\" \
@@ -2725,11 +2729,17 @@ UNINSTALL_EXEC_HOOKS += \
# Update catalog on installation. Do not bother if installing
# in DESTDIR, since this is likely for packaging purposes.
catalog-update-hook:
- -test -n "$(DESTDIR)" || journalctl --update-catalog
+ -test -n "$(DESTDIR)" || $(rootbindir)/journalctl --update-catalog
INSTALL_DATA_HOOKS += \
catalog-update-hook
+catalog-remove-hook:
+ -test -n "$(DESTDIR)" || rm -f $(catalogstatedir)/database
+
+UNINSTALL_DATA_HOOKS += \
+ catalog-remove-hook
+
noinst_PROGRAMS += \
test-journal \
test-journal-send \
@@ -3596,7 +3606,7 @@ polkitpolicy_files += \
logind-install-data-hook:
$(MKDIR_P) -m 0755 \
$(DESTDIR)$(systemunitdir)/multi-user.target.wants \
- $(DESTDIR)$(localstatedir)/lib/systemd
+ $(DESTDIR)$(systemdstatedir)
( cd $(DESTDIR)$(systemunitdir) && \
rm -f dbus-org.freedesktop.login1.service && \
$(LN_S) systemd-logind.service dbus-org.freedesktop.login1.service)
@@ -4061,7 +4071,7 @@ endif
install-exec-hook: $(INSTALL_EXEC_HOOKS)
-uninstall-hook: $(UNINSTALL_EXEC_HOOKS)
+uninstall-hook: $(UNINSTALL_DATA_HOOKS) $(UNINSTALL_EXEC_HOOKS)
install-data-hook: systemd-install-data-hook $(INSTALL_DATA_HOOKS)
diff --git a/src/journal/catalog.c b/src/journal/catalog.c
index 2812d59..3735ad9 100644
--- a/src/journal/catalog.c
+++ b/src/journal/catalog.c
@@ -269,7 +269,6 @@ static int import_file(Hashmap *h, struct strbuf *sb, const char *path) {
return 0;
}
-#define CATALOG_PATH "/var/lib/systemd/catalog"
#define CATALOG_DATABASE CATALOG_PATH "/database"
int catalog_update(void) {
@@ -414,7 +413,7 @@ static int open_mmap(int *_fd, struct stat *_st, void **_p) {
assert(_st);
assert(_p);
- fd = open("/var/lib/systemd/catalog/database", O_RDONLY|O_CLOEXEC);
+ fd = open(CATALOG_DATABASE, O_RDONLY|O_CLOEXEC);
if (fd < 0)
return -errno;
commit 943aad8ca57a6b5c49c4ea60f9e8c13bf9b20e6c
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Fri Nov 16 17:17:21 2012 +0100
journal, shared: fix warnings during compilation on 32 bits
Some filesystem magics are too big to fit in 31 bits,
and are wrapped to negative. f_type is an int on 32 bits, so
it is signed, and we get a warning on comparison.
diff --git a/src/journal/catalog.c b/src/journal/catalog.c
index 22029da..2812d59 100644
--- a/src/journal/catalog.c
+++ b/src/journal/catalog.c
@@ -384,7 +384,7 @@ int catalog_update(void) {
goto finish;
}
- log_debug("%s: wrote %u items, with %zu bytes of strings, %zu total size.",
+ log_debug("%s: wrote %u items, with %zu bytes of strings, %ld total size.",
CATALOG_DATABASE, n, sb->len, ftell(w));
free(p);
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index c86f1ea..41f0c4d 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -1205,7 +1205,7 @@ static void check_network(sd_journal *j, int fd) {
return;
j->on_network =
- sfs.f_type == CIFS_MAGIC_NUMBER ||
+ (long)sfs.f_type == (long)CIFS_MAGIC_NUMBER ||
sfs.f_type == CODA_SUPER_MAGIC ||
sfs.f_type == NCP_SUPER_MAGIC ||
sfs.f_type == NFS_SUPER_MAGIC ||
diff --git a/src/shared/util.c b/src/shared/util.c
index 6d826b6..4cf928f 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -3400,6 +3400,12 @@ int rm_rf_children_dangerous(int fd, bool only_dirs, bool honour_sticky, struct
return ret;
}
+static int is_temporary_fs(struct statfs *s) {
+ assert(s);
+ return s->f_type == TMPFS_MAGIC ||
+ (long)s->f_type == (long)RAMFS_MAGIC;
+}
+
int rm_rf_children(int fd, bool only_dirs, bool honour_sticky, struct stat *root_dev) {
struct statfs s;
@@ -3413,9 +3419,7 @@ int rm_rf_children(int fd, bool only_dirs, bool honour_sticky, struct stat *root
/* We refuse to clean disk file systems with this call. This
* is extra paranoia just to be sure we never ever remove
* non-state data */
-
- if (s.f_type != TMPFS_MAGIC &&
- s.f_type != RAMFS_MAGIC) {
+ if (!is_temporary_fs(&s)) {
log_error("Attempted to remove disk file system, and we can't allow that.");
close_nointr_nofail(fd);
return -EPERM;
@@ -3448,8 +3452,7 @@ static int rm_rf_internal(const char *path, bool only_dirs, bool delete_root, bo
if (statfs(path, &s) < 0)
return -errno;
- if (s.f_type != TMPFS_MAGIC &&
- s.f_type != RAMFS_MAGIC) {
+ if (!is_temporary_fs(&s)) {
log_error("Attempted to remove disk file system, and we can't allow that.");
return -EPERM;
}
@@ -3468,8 +3471,7 @@ static int rm_rf_internal(const char *path, bool only_dirs, bool delete_root, bo
return -errno;
}
- if (s.f_type != TMPFS_MAGIC &&
- s.f_type != RAMFS_MAGIC) {
+ if (!is_temporary_fs(&s)) {
log_error("Attempted to remove disk file system, and we can't allow that.");
close_nointr_nofail(fd);
return -EPERM;
@@ -5767,7 +5769,7 @@ bool in_initrd(void) {
saved = access("/etc/initrd-release", F_OK) >= 0 &&
statfs("/", &s) >= 0 &&
- (s.f_type == TMPFS_MAGIC || s.f_type == RAMFS_MAGIC);
+ is_temporary_fs(&s);
return saved;
}
More information about the systemd-commits
mailing list