+ /* We do a bit of endianess swapping here, just to be
+ * sure. /var should be machine specific anyway, and
+ * /var/run even mounted from tmpfs, so this
+ * byteswapping should really not be necessary. But
+ * then again, you never know, so let's avoid any
+ * risk. */
+
+ if (loop_read(fd, &counter, sizeof(counter), false) != sizeof(counter))
+ counter = 1;
+ else
+ counter = le64toh(counter) + 1;
+
+ if (lseek(fd, 0, SEEK_SET) == 0) {
+ uint64_t swapped = htole64(counter);
+
+ r = loop_write(fd, &swapped, sizeof(swapped), false);
+
+ if (r != sizeof(swapped))
+ r = -EIO;
+ } else
+ r = -errno;