summaryrefslogtreecommitdiff
path: root/src/shared/loop-util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-04-20 16:08:43 +0200
committerLennart Poettering <lennart@poettering.net>2021-04-20 17:20:38 +0200
commit8ede1e86b2cfdbe7bb1e1913a08e068a82d4532c (patch)
treeaeb7d35d52f2d6433896719d820b941801c55da7 /src/shared/loop-util.h
parent8626b43be42b9db065f8fdf2b057990ef511150e (diff)
downloadsystemd-8ede1e86b2cfdbe7bb1e1913a08e068a82d4532c.tar.gz
loop-util: track CLOCK_MONOTONIC timestamp immediately before attaching a loopback device
This is similar to the preceding work to store the uevent seqnum, but this stores the CLOCK_MONOTONIC timestamp. Why? This allows to validate udev database entries, to determine if they were created *after* we attached the device. The uevent seqnum logic allows us to validate uevent, and the timestamp database entries, hence together we should be able to validate both sources of truth for us. (note that this is all racy, just a bit less racy, since we cannot atomically attach loopback devices and get the timestamp for it, the same way we can't get the uevent seqnum. Thus is shortens the race window, but doesn#t close it).
Diffstat (limited to 'src/shared/loop-util.h')
-rw-r--r--src/shared/loop-util.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/shared/loop-util.h b/src/shared/loop-util.h
index 6df4f91c22..e06dfebb7c 100644
--- a/src/shared/loop-util.h
+++ b/src/shared/loop-util.h
@@ -2,6 +2,7 @@
#pragma once
#include "macro.h"
+#include "time-util.h"
typedef struct LoopDevice LoopDevice;
@@ -14,6 +15,7 @@ struct LoopDevice {
char *node;
bool relinquished;
uint64_t uevent_seqnum_not_before; /* uevent sequm right before we attached the loopback device, or UINT64_MAX if we don't know */
+ usec_t timestamp_not_before; /* CLOCK_MONOTONIC timestamp taken immediately before attaching the loopback device, or USEC_INFINITY if we don't know */
};
int loop_device_make(int fd, int open_flags, uint64_t offset, uint64_t size, uint32_t loop_flags, LoopDevice **ret);