summaryrefslogtreecommitdiff
path: root/src/shared/btrfs-util.c
Commit message (Collapse)AuthorAgeFilesLines
* copy: Introduce reflink() and reflink_full()Daan De Meyer2023-04-281-34/+0
| | | | | | The kernel has had filesystem independent reflink ioctls for a while now, let's try to use them and fall back to the btrfs specific ones if they're not supported.
* btrfs-util: Add btrfs_get_block_device_at()Daan De Meyer2023-04-011-20/+8
| | | | | | Let's make btrfs_get_block_device_fd() more generic by renaming it to btrfs_get_block_device_at() so it can operate on only paths, dir_fd and path, or only on fd by using xopenat().
* dissect-image: Notify btrfs when we're done using a loop deviceDaan De Meyer2023-01-121-0/+18
| | | | | | | Let's explicitly let btrfs know when we're done using a loop device. Otherwise, btrfs will keep the device UUID cached which will result in mount() failures if we ever generate a device or filesystem with the same UUID again.
* shared: port various shared helpers basename() → path_extract_filename()Lennart Poettering2022-12-231-8/+10
|
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-22/+22
| | | | | | | | | | | | | | | | -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.
* btrfs-util: shorten a bitDavid Tardon2022-12-141-4/+1
|
* btrfs-util: convert O_PATH if necessary, in btrfs quota callLennart Poettering2022-11-291-0/+6
| | | | Fixes: #25468
* blockdev-util: move O_PATH fd conversion into btrfs_get_block_device_fd() to ↵Lennart Poettering2022-11-291-0/+5
| | | | | | | shorten things And let's use a simple call to the new fd_reopen_condition() helper there.
* btrfs-util: convert to fd_reopen_condition()Lennart Poettering2022-11-291-13/+5
|
* btrfs-util: Remove bogus assert()Daan De Meyer2022-11-151-1/+0
| | | | | If size is zero, BTRFS_IOC_CLONE_RANGE will copy until the end of the source file.
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+0
| | | | | util.h is now about logarithms only, so we can rename it. Many files included util.h for no apparent reason… Those includes are dropped.
* btrfs-util: move btrfs_defrag_fd() from fd-util.[ch]Yu Watanabe2022-10-251-0/+12
| | | | | | After d71ece3f0b85c7a3decc50143b68ac07fc5831ae, the function is not used in libbasic or libsystemd anymore. Let's move it to more appropriate place.
* fix typoYu Watanabe2022-04-111-1/+1
|
* tree-wide: use new RET_NERRNO() helper at various placesLennart Poettering2021-11-161-28/+7
|
* shared/copy: add a new flag COPY_ALL_XATTRSAndrej Lajovic2021-08-111-0/+1
| | | | | | | | When the flag COPY_ALL_XATTRS is set, it causes the complete set of xattrs to be copied. If the flag is unset, only xattrs from the "user" namespace are copied. Fixes #17178.
* btrfs-util: expose COPY_SIGTERM for btrfs_snapshot() tooLennart Poettering2021-08-021-3/+10
|
* basic,shared: move a bunch of files to src/shared/Zbigniew Jędrzejewski-Szmek2021-06-241-0/+1989
| | | | | | | | | | | | The goal is to move everything that requires selinux or smack away from src/basic/. This means that src/basic/label.[ch] must move, which implies btrfs-util.[ch], copy.[ch], and a bunch of other files which form a cluster of internal use. This is just moving text around, so there should be no functional difference. test-blockdev-util is new, because path_is_encrypted() is moved to blockdev-util.c, and so far we didn't have any tests for code there.
* build-sys: split internal basic/ library from shared/Kay Sievers2015-06-111-1152/+0
| | | | | | | | | | basic/ can be used by everything cannot use anything outside of basic/ libsystemd/ can use basic/ cannot use shared/ shared/ can use libsystemd/
* btrfs-util: support recursive removal of read-only subvolumesLennart Poettering2015-04-221-0/+9
| | | | | When deleting a read-only subsvolume with a sub-subvolume, we need to mark it writable first, otherwise the removal will not work.
* btrfs-util: fix creating recursive read-only snapshotsLennart Poettering2015-04-221-2/+36
| | | | | | When creating recursive read-only snapshots we need to mark the snapshot writable immediately before creating subsnapshots within it, otherwise the operation for it will fail.
* btrfs-util: be more careful when invoking btrfs file system ioctlsLennart Poettering2015-04-221-0/+77
| | | | | | | | | | | If we get passed an fd that does not refer to a regular file or directory, we should not issue btrfs ioctls on it, since it might end up in a device driver or similar (note that DRM for example uses the same ioctl numbers as some file system ioctls). Hence, let's make sure to always check if something is a regular file or directory, or is on btrfs before invoking the respective ioctls. It's better to be safe than sorry.
* btrfs-util: introduce btrfs_is_filesystem() and make use of it where appropriateLennart Poettering2015-04-221-7/+16
| | | | | | | Let's unify the code that checks whether an fd is on btrfs a bit. (Also, rename btrfs_is_snapshot() to btrfs_is_subvol(), since that's usually how this is referred to in our code)
* btrfs: add support for recursive btrfs snapshottingLennart Poettering2015-04-061-68/+180
|
* btrfs: missing endian conversion fixLennart Poettering2015-04-061-1/+1
|
* btrfs: make btrfs_subvol_snapshot() parameters a flags fieldLennart Poettering2015-04-061-6/+6
|
* btrfs: support recursively removing btrfs snapshotsLennart Poettering2015-04-061-26/+137
|
* fix gcc warnings about uninitialized variablesHarald Hoyer2015-03-271-1/+1
| | | | | | | | | | | | | like: src/shared/install.c: In function ‘unit_file_lookup_state’: src/shared/install.c:1861:16: warning: ‘r’ may be used uninitialized in this function [-Wmaybe-uninitialized] return r < 0 ? r : state; ^ src/shared/install.c:1796:13: note: ‘r’ was declared here int r; ^
* shared: the btrfs quota field is called "referenced" not "referred"Lennart Poettering2015-03-101-11/+11
|
* importd: add API for exporting container/VM imagesLennart Poettering2015-03-091-23/+30
| | | | Also, expose it in machinectl.
* importd: automatically grow /var/lib/machines/ loopback filesystem during ↵Lennart Poettering2015-03-031-4/+13
| | | | | | | | | | | downloads If /var/lib/machines is mounted as btrfs loopback file system in /var/lib/machines.raw with this change we automatically grow the file system as it fills up. After each 10M we write to it during imports, we check the free disk space, and if the fill level grows beyond 66% we increase the size of the file system to 3x the fill level (thus lowering it to 33%).
* machined: if /var/lib/machines is backed by a loop file, resize it on ↵Lennart Poettering2015-02-261-7/+94
| | | | | | | | | "machinectl set-limit" When the pool size limit is altered with "machinectl set-limit", then not only set the subvolume quota of the /var/lib/machine subvolume, but also resize the backing loop file and the btrfs file system on it dynamically.
* machined,machinectl: add calls for changing container/VM quotasLennart Poettering2015-02-251-0/+26
|
* importd: enable btrfs quota in /var/lib/machines, if necessaryLennart Poettering2015-02-241-0/+23
|
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-231-1/+0
| | | | | | This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
* import: port pull-raw to helper tools implemented for pull-tarLennart Poettering2015-01-201-4/+18
| | | | | This allows us to reuse a lot more code, and simplify pull-raw drastically.
* qcow2: when dissecting qcow2, use btrfs clone ioctls for reflinking blocks ↵Lennart Poettering2015-01-191-0/+20
| | | | to target
* btrfs-util: rework how we iterate through the results of the TREE_SEARCH resultsLennart Poettering2015-01-071-32/+95
| | | | | Let's introduce some syntactic sugar with iteration macros, and add correct key increment calls.
* journald: whenever we rotate a file, btrfs defrag itLennart Poettering2015-01-061-0/+19
| | | | | | | Our write pattern is quite awful for CoW file systems (btrfs...), as we keep updating file parts in the beginning of the file. This results in fragmented journal files. Hence: when rotating files, defragment them, since at that point we know that no further write accesses will be made.
* machined: add support for reporting image size via btrfs quotaLennart Poettering2014-12-281-23/+157
|
* tmpfiles: add new line type 'v' for creating btrfs subvolumesLennart Poettering2014-12-281-0/+20
|
* machined: beef up machined image listing with creation/modification times of ↵Lennart Poettering2014-12-251-3/+79
| | | | | | | subvolumes We make use of the btrfs subvol crtime for this, and for gpt images of a manually managed xattr, if we can.
* machined/machinectl: add logic to show list of available imagesLennart Poettering2014-12-191-6/+15
| | | | | | | | | This adds a new bus call to machined that enumerates /var/lib/container and returns all trees stored in it, distuingishing three types: - GPT disk images, which are files suffixed with ".gpt" - directory trees - btrfs subvolumes
* machinectl: add new commands for copying files from/to containersLennart Poettering2014-12-181-1/+1
|
* shared: add new btrfs-util.[ch] helpers for doing common btrfs operationLennart Poettering2014-12-121-0/+294