dissect: Set SYSTEMD_DISSECT_DEVICE to path of loop device

For some use cases we want to operate on the loop device that
systemd-dissect has attached the loop device to, so let's make that
easily accessible.
This commit is contained in:
Daan De Meyer
2023-08-17 20:36:51 +02:00
parent 5f22d16bb3
commit 47838b55c8
2 changed files with 7 additions and 1 deletions
+2 -1
View File
@@ -235,7 +235,8 @@
use <option>--read-only</option> to switch to read-only operation. The invoked process will have the
<varname>$SYSTEMD_DISSECT_ROOT</varname> environment variable set, containing the absolute path name
of the temporary mount point, i.e. the same directory that is set as the current working
directory.</para></listitem>
directory. It will also have the <varname>$SYSTEMD_DISSECT_DEVICE</varname> environment variable set,
containing the absolute path name of the loop device the image was attached to.</para></listitem>
</varlistentry>
<varlistentry>
+5
View File
@@ -1577,6 +1577,11 @@ static int action_with(DissectedImage *m, LoopDevice *d) {
_exit(EXIT_FAILURE);
}
if (setenv("SYSTEMD_DISSECT_DEVICE", d->node, /* overwrite= */ true) < 0) {
log_error_errno(errno, "Failed to set $SYSTEMD_DISSECT_DEVICE: %m");
_exit(EXIT_FAILURE);
}
if (strv_isempty(arg_argv)) {
const char *sh;