mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 09:21:26 +03:00
loop-util: store device major/minor in LoopDevice object
Let's store this away. It's useful when matching up mounts (i.e. struct stat's .st_dev field) with loopback devices.
This commit is contained in:
parent
d83d804863
commit
f3859d5f55
@ -353,6 +353,7 @@ int loop_device_make(
|
||||
.nr = nr,
|
||||
.node = TAKE_PTR(loopdev),
|
||||
.relinquished = true, /* It's not allocated by us, don't destroy it when this object is freed */
|
||||
.devno = st.st_rdev,
|
||||
};
|
||||
|
||||
*ret = d;
|
||||
@ -425,6 +426,10 @@ int loop_device_make(
|
||||
UINT64_C(240) * USEC_PER_MSEC * n_attempts/64));
|
||||
}
|
||||
|
||||
if (fstat(loop_with_fd, &st) < 0)
|
||||
return -errno;
|
||||
assert(S_ISBLK(st.st_mode));
|
||||
|
||||
d = new(LoopDevice, 1);
|
||||
if (!d)
|
||||
return -ENOMEM;
|
||||
@ -432,6 +437,7 @@ int loop_device_make(
|
||||
.fd = TAKE_FD(loop_with_fd),
|
||||
.node = TAKE_PTR(loopdev),
|
||||
.nr = nr,
|
||||
.devno = st.st_rdev,
|
||||
};
|
||||
|
||||
*ret = d;
|
||||
|
@ -10,6 +10,7 @@ typedef struct LoopDevice LoopDevice;
|
||||
struct LoopDevice {
|
||||
int fd;
|
||||
int nr;
|
||||
dev_t devno;
|
||||
char *node;
|
||||
bool relinquished;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user