summaryrefslogtreecommitdiff
path: root/src/test/test-loop-block.c
Commit message (Collapse)AuthorAgeFilesLines
* mkfs-util: Add quiet argument to make_filesystem()Daan De Meyer2023-05-121-4/+4
| | | | | | | | We default to quiet operation everywhere except for repart, where we disable quiet and have the mkfs tools write to stdout. We also make sure --quiet or equivalent is implemented for all mkfs tools.
* tree-wide: hook up image dissection policy logic everywhereLennart Poettering2023-04-051-5/+5
|
* repart: Allow configuring sector sizeDaan De Meyer2023-01-171-4/+4
| | | | | | Let's allow users to configure the (logical) sector size of their image. This is required when building images for a 4k sector size disk on a 512b sector size host or vice-versa.
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-1/+1
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* Implement SYSTEMD_HOME_MKFS_OPTIONS_* envvars to configure mkfs options for ↵Aidan Dang2022-12-151-4/+4
| | | | homed LUKS directories
* test-loop-block: let's explicitly flush buffer cache on whole block deviceLennart Poettering2022-12-011-0/+9
| | | | | | | | | | | | Let's explicitly flush the kernel's buffer cache on the whole block device once we ran "mkfs". This is necessary, because partition and whole block devices maintain separate buffer caches, and thus writing to one will not be visible on the other if cached there already, until the latter's cache is explicitly flushed. This is preparation for later adding support for probing file sytems also if we have no open partition block devices, and hence want to use the whole block device instead.
* test-loop-block: also test dissection without ADD/PIN of partition block devicesLennart Poettering2022-12-011-0/+8
| | | | | | Let's extend the test further, and try the codepaths where we do not pin/add the partition block devices (i.e. which is the codepaths we use when running without privs)
* test-loop-block: tighten tests a bit - check fstype, tooLennart Poettering2022-12-011-1/+10
| | | | | Let's verify that we properly created the file systems once we did so. And tets this way that our dissector works correctly.
* dissect: rework DISSECT_IMAGE_ADD_PARTITION_DEVICES + ↵Lennart Poettering2022-12-011-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DISSECT_IMAGE_OPEN_PARTITION_DEVICES Curently, these two flags were implied by dissect_loop_device(), but that's not right, because this means systemd-gpt-auto-generator will dissect the root block device with these flags set and that's not desirable: the generator should not cause the partition devices to be created (we don't intend to use them right-away after all, but expect udev to find/probe them first, and then mount them though .mount units). And there's no point in opening the partition devices, since we do not intend to mount them via fds either. Hence, rework this: instead of implying the flags, specify them explicitly. While we are at it, let's also rename the flags to make them more descriptive: DISSECT_IMAGE_MANAGE_PARTITION_DEVICES becomes DISSECT_IMAGE_ADD_PARTITION_DEVICES, since that's really all this does: add the partition devices via BLKPG. DISSECT_IMAGE_OPEN_PARTITION_DEVICES becomes DISSECT_IMAGE_PIN_PARTITION_DEVICES, since we not only open the devices, but keep the devices open continously (i.e. we "pin" them). Also, drop the DISSECT_IMAGE_BLOCK_DEVICE combination flag, since it is misleading, i.e. it suggests it was appropriate to specify on all dissected blocking devices, but that's precisely not the case, see the systemd-gpt-auto-generator case. My guess is that the confusion around this was actually the cause for this bug we are addressing here. Fixes: #25528
* Implement --luks-sector-size for homedAidan Dang2022-10-071-2/+2
|
* test: add test for dissect_image_file()Yu Watanabe2022-09-281-53/+59
|
* Merge pull request #24709 from keszybz/partition-table-constantsLennart Poettering2022-09-211-4/+4
|\ | | | | Expose various GPT UUIDs as public contants and link them up in docs
| * headers: export partition uuids and flags in new sd-gpt.h fileZbigniew Jędrzejewski-Szmek2022-09-201-4/+4
| | | | | | | | | | | | I think those constants are generally useful. It's quite easy to make a mistake when copying things from the docs, so let's make them easy and convenient to access.
* | shared: Add squashfs support to make_filesystem()Daan De Meyer2022-09-211-4/+4
|/ | | | | The caveat is that the caller has to provide a source directory to initialize the squashfs filesystem from.
* dissect-image: use backing_file stored in LoopDevice object to generate ↵Yu Watanabe2022-09-071-9/+3
| | | | | | | | image name Follow-up for e374439f4b8def786031ddbbd7dfdae3a335d4d2 (#24322). This also simplify the logic of generating image name from image path.
* loop-util: save backing file of loopback block deviceYu Watanabe2022-09-071-0/+1
| | | | It will be used in later commits.
* loop-util: store sd_device object for the loop deviceYu Watanabe2022-09-061-0/+1
| | | | It will be used in later commits.
* Use original filename for extension name checkKai Lueke2022-09-061-3/+9
| | | | | | | | | | | | | The loading of an extension image from a symlink "NAME.raw" to "NAME-VERSION.raw" failed because the release file name check worked with the backing file of the loop device which already resolves the symlink and thus the found name "NAME-VERSION" mismatched "NAME". Pass the original filename and use it instead of the backing file when available. This fixes the loading of "NAME.raw" extensions which are a symlink to "NAME-VERSION.raw" as, e.g., may be the case when systemd-sysupdate manages multiple versions. Fixes https://github.com/systemd/systemd/issues/24293
* dissect-image: introduce dissect_loop_device() which takes LoopDevice objectYu Watanabe2022-09-031-3/+3
|
* loop-util: rework how we lock loopback block devicesLennart Poettering2022-09-011-10/+2
| | | | | | | | | | | | | | | | | | | | Let's rework how we lock loopback block devices in two ways: 1. Lock a separate fd, instead of the main block device fd. We already did that for our internal locking when allocating loopback block devices, but do so for the exposed locking (i.e. loop_device_flock()), too, so that the lock is independent of the main fd we actually use of IO. 2. Instead of locking the device during allocation of the loopback device, then unlocking it (which will make udev run), and then re-locking things if we need, let's instead just keep the lock the whole time, to make things a bit safer and faster, and not have to wait for udev at all. This is done by adding a "lock_op" parameter to loop device allocation functions that declares the initial state of the lock, and is one of LOCK_UN/LOCK_SH/LOCK_EX. This change also shortens a lot of code, since we allocate + immediately lock loopback devices pretty much everywhere.
* Add sys/file.h for LOCK_Pavel Zhukov2022-06-211-0/+1
| | | | | | | | Fixes build with musl: | ../git/src/shared/dissect-image.c: In function 'mount_image_privately_interactively': | ../git/src/shared/dissect-image.c:2986:34: error: 'LOCK_SH' undeclared (first use in this function) | 2986 | r = loop_device_flock(d, LOCK_SH); | | ^~~~~~~
* tree-wide: take BSD lock on loopback devices we dissect/mount/operate onLennart Poettering2022-04-101-0/+24
| | | | | | | | | | | | | | | | | | | | | So here's something we should always keep in mind: systemd-udevd actually does *two* things with BSD file locks on block devices: 1. While it probes a device it takes a LOCK_SH lock. Thus everyone else taking a LOCK_EX lock will temporarily block udev from probing devices, which is good when making changes to it. 2. Whenever a device is closed after write (detected via inotify), udevd will issue BLKRRPART (requesting the kernel to reread the partition table). It does this while holding a LOCK_EX lock on the block device. Thus anyone else taking LOCK_SH or LOCK_EX will temporarily block udevd from issuing that ioctl. And that's quite relevant, since the kernel will temporarily flush out all partitions while re-reading the partition table and then create them anew. Thus it is smart to take LOCK_SH when dissecting a block device to ensure that no BLKRRPART is issued in the background, until we mounted the devices.
* test-loop-block: reenable test on CILennart Poettering2022-04-101-6/+0
|
* test-loop-block: conditionalize things on HAVE_BLKID correctlyLennart Poettering2022-04-071-5/+12
|
* test: allow specifying test threads/iterations/timeouts via cmdlineLennart Poettering2022-04-071-14/+45
| | | | That's useful when running tests manually.
* test-loop-block: don't spawn threads in case N_THREADS is 1Lennart Poettering2022-04-071-9/+15
| | | | | Let's simplify things if we are only supposed to create a single thread. Makes it easier to debug things with gdb.
* strv: declare iterator of FOREACH_STRING() in the loopZbigniew Jędrzejewski-Szmek2022-03-231-1/+0
| | | | | | | | | | | Same idea as 03677889f0ef42cdc534bf3b31265a054b20a354. No functional change intended. The type of the iterator is generally changed to be 'const char*' instead of 'char*'. Despite the type commonly used, modifying the string was not allowed. I adjusted the naming of some short variables for clarity and reduced the scope of some variable declarations in code that was being touched anyway.
* dissect: use DISKSEQ when waiting for block devicesLuca Boccassi2021-07-281-3/+3
| | | | | | | | DISKSEQ is a reliable way to find out if we missed a uevent or not, as it's monotonically increasing. If we parse an event with a smaller or no sequence number, we know we need to wait longer. If we parse an event with a greater sequence number, we know we missed it and the device was reused.
* dissect-image: add support for optionally mounting images with idmapping onLennart Poettering2021-05-071-2/+2
|
* dissect: ignore udev database entries from before the loopback attachmentLennart Poettering2021-04-201-3/+3
| | | | | | | | | This tries to shorten the race of device reuse a bit more: let's ignore udev database entries that are older than the time where we started to use a loopback device. This doesn't fix the whole loopback device raciness mess, but it makes the race window a bit shorter.
* dissect: ignore old uevents when waiting for loopback partition scanLennart Poettering2021-04-201-3/+3
| | | | | | | | | | | Let's drop all monitor uevent that were enqueued before we actually started setting up the device. This doesn't fix the race, but it makes the race window smaller: since we cannot determine the uevent seqnum and the loopback attachment atomically, there's a tiny window where uevents might be generated by the device which we mistake for being associated with out use of the loopback device.
* test: temporarily skip failing tests on GH ActionsFrantisek Sumsal2021-01-081-2/+2
|
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* test: add heavy load loopback block device testLennart Poettering2020-10-221-0/+250