<filename>/etc/</filename> or <filename>/var/</filename> on the
following boot.</para>
- <para><filename>systemd-update-done.service</filename> updates the
- file modification time (mtime) of the stamp files
- <filename>/etc/.updated</filename> and
- <filename>/var/.updated</filename> to the modification time of the
- <filename>/usr/</filename> directory, unless the stamp files are
- already newer.</para>
+ <para><filename>systemd-update-done.service</filename> updates the file modification time (mtime) stored
+ in and "on" the files <filename>/etc/.updated</filename> and <filename>/var/.updated</filename> to the
+ modification time of the <filename>/usr/</filename> directory, unless the stamp files are already newer.
+ (The timestamp is stored as the mtime field on the file, but also <emphasis>in</emphasis> the file
+ to support filesystems that do not store full timestamp precision.)</para>
<para>Services that shall run after offline upgrades of
<filename>/usr/</filename> should order themselves before
#include "alloc-util.h"
#include "fileio.h"
+#include "path-util.h"
#include "selinux-util.h"
#include "time-util.h"
-#define MESSAGE \
- "# This file was created by systemd-update-done. Its only\n" \
- "# purpose is to hold a timestamp of the time this directory\n" \
- "# was updated. See man:systemd-update-done.service(8).\n"
-
-static int apply_timestamp(const char *path, struct timespec *ts) {
- _cleanup_free_ char *message = NULL;
+static int save_timestamp(const char *dir, struct timespec *ts) {
+ _cleanup_free_ char *message = NULL, *path = NULL;
int r;
/*
* to support filesystems which cannot store nanosecond-precision timestamps.
*/
+ path = path_join(dir, ".updated");
+ if (!path)
+ return log_oom();
+
if (asprintf(&message,
- MESSAGE
+ "# This file was created by systemd-update-done. The timestamp below is the\n"
+ "# modification time of /usr/ for which the most recent updates of %s have\n"
+ "# been applied. See man:systemd-update-done.service(8) for details.\n"
"TIMESTAMP_NSEC=" NSEC_FMT "\n",
+ dir,
timespec_load_nsec(ts)) < 0)
return log_oom();
if (r < 0)
return EXIT_FAILURE;
- r = apply_timestamp("/etc/.updated", &st.st_mtim);
- q = apply_timestamp("/var/.updated", &st.st_mtim);
+ r = save_timestamp("/etc/", &st.st_mtim);
+ q = save_timestamp("/var/", &st.st_mtim);
return r < 0 || q < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}