summaryrefslogtreecommitdiff
path: root/src/basic/copy.c
Commit message (Collapse)AuthorAge
* copy: put a depth limit on copying file system trees recursivelyLennart Poettering2018-08-24
| | | | | | | This is a safety net against bind mount cycles, as such pick it relatively high at 2048 for now. As suggested by @filbranden on #9213
* copy: extend check for mount point crossingLennart Poettering2018-08-24
| | | | | | | | | | | | We do this checks as protection against bind mount cycles on the same file system. However, the check wasn't really effective for that, as it would only detect cycles A → B → A this way. By using fs_is_mount_point() we'll also detect cycles A → A. Also, while we are at it, make these file system boundary checks optional. This is not used anywhere, but might be eventually... Most importantly though add a longer blurb explanation the why.
* copy: only check for traversing mount points on directoriesFilipe Brandenburger2018-08-24
| | | | | | | | | | | | | | | | | | This fixes the copy routines on overlay filesystem, which typically returns the underlying st_dev for files, symlinks, etc. The value of st_dev is guaranteed to be the same for directories, so checking it on directories only fixes this code on overlay filesystem and still keeps it from traversing mount points (which was the original intent.) There's a small side effect here, by which regular (non-directory) files with bind mounts will be copied by the new logic (while they were skipped by the previous logic.) Tested: ./build/test-copy with an overlay on /tmp. Fixes: #9134
* Add macro for checking if some flags are setZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | This way we don't need to repeat the argument twice. I didn't replace all instances. I think it's better to leave out: - asserts - comparisons like x & y == x, which are mathematically equivalent, but here we aren't checking if flags are set, but if the argument fits in the flags.
* basic/copy: fix awkward sentenceZbigniew Jędrzejewski-Szmek2018-08-24
|
* copy: reduce number of checksLennart Poettering2018-08-24
| | | | | We check max_bytes twice here, let's simplify that, and reduce one level of indentation.
* copy: drop _unlikely_() that isn't obviously the caseLennart Poettering2018-08-24
| | | | | | | | If a tool only invokes copy_bytes() a single time the _unlikely_() will always be wrong, and is hence not useful. Let's drop it and let the compiler figure our what to do, instead of misleading it. Also, some coding style imprvoements.
* copy: hide in copy_bytes() the strange way splice() handles O_NONBLOCKLennart Poettering2018-08-24
| | | | | | splice() ignores O_NONBLOCK on pipes but not on other fds. Let's handle that properly, and query O_ONBLOCK manually in that case, ensuring systematic behaviour in either case.
* copy: extend copy_bytes() a bitLennart Poettering2018-08-24
| | | | | | | Optionally, when we copy between fds with simple read/write, let's return any remaining data we already read into the buffer if write fails. This is useful to allow callers to use the read data otherwise, perhaps implementing a different fallback for copying.
* copy: tweak reflink logic in copy_bytes() a bitLennart Poettering2018-08-24
| | | | | Let's use btrfs_clone_range() if partial copies are desired. And use btrfs_reflink() only for full-file reflinks.
* copy: add brief comment to copy_bytes() explaining its return valuesLennart Poettering2018-08-24
|
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* copy: wrap some unlink() calls in (void) castsLennart Poettering2018-05-30
|
* Prep v236 : Add missing SPDX-License-Identifier (2/9) src/basicSven Eden2018-03-26
|
* Apply updates from upstreamSven Eden2017-12-07
|
* copy: a plain unlink() works here tooLennart Poettering2017-07-17
|
* machined: when copying files from/to userns containers chown to rootLennart Poettering2017-07-17
| | | | | | | | This changes the file copy logic of machined to set the UID/GID of all copied files to 0 if the host and container do not share the same user namespace. Fixes: #4078
* copy: change the various copy_xyz() calls to take a unified flags parameterLennart Poettering2017-07-17
| | | | | | | | This adds a unified "copy_flags" parameter to all copy_xyz() function calls, replacing the various boolean flags so far used. This should make many invocations more readable as it is clear what behaviour is precisely requested. This also prepares ground for adding support for more modes later on.
* fs-util: unify code we use to check if dirent's d_name is "." or ".."Lennart Poettering2017-07-17
| | | | | We use different idioms at different places. Let's replace this is the one true new idiom, that is even a bit faster...
* treewide: fix typos and remove accidental repetition of wordsTorstein Husebø2017-06-16
|
* Prep v230: Apply missing upstream fixes and updates (2/8) src/basic.Sven Eden2017-06-16
|
* machined: support non-btrfs file systems with "machinectl clone"Lennart Poettering2017-06-16
| | | | | | | | Fall back to a normal copy operation when the backing file system isn't btrfs, and hence doesn't support cheap snapshotting. Of course, this will be slow, but given that the execution is asynchronous now, this should be OK. Fixes: #1308
* copy: adjust directory times after writing to the directoryLennart Poettering2017-06-16
| | | | | | When recursively copying a directory tree, fix up the file times after having created all contents in it, so that our changes don't end up altering any of the directory times.
* copy: return the right error when we can't open a fileLennart Poettering2017-06-16
|
* copy: also copy AF_UNIX socketsLennart Poettering2017-06-16
| | | | | | | | We previously would fail with EOPNOTSUPP when encountering an AF_UNIX socket in the directory tree to copy. Fix that, and copy them too (even if they are dead in the result). Fixes: #2914
* Prep v229: Add missing fixes from upstream [1/6] src/basicSven Eden2017-05-17
|
* Prep v228: Condense elogind source masks (1/5)Sven Eden2017-04-26
| | | | | | | | | | | | Although having a two line mask like /// UNNEEDED by elogind #if 0 it is much more easier to read (and patch!) if those two lines were condense into a one-line mask start like #if 0 /// UNNEEDED by elogind
* Prep v228: Substitute declaration masks (1/4)Sven Eden2017-04-26
| | | | | | | | | | | | | | | | | Although it looks very ugly, substitute all declaration masks of the form: // UNNEEDED type foo(...); with: /// UNNEEDED by elogind #if 0 type foo(...); #endif // 0 to make future merging of upstream pathes easier, as the relevant lines themselves are not changed any more.
* Prep v228: Add remaining updates from upstream (2/3)Sven Eden2017-04-26
| | | | | Apply remaining fixes and the performed move of utility functions into their own foo-util.[hc] files on libbasic.
* [1/5] Apply missing fixes from upstreamSven Eden2017-03-29
|
* Prep v226: Add src/basic/copy.[hc] to libbasic, the function copy_bytes() is ↵Sven Eden2017-03-14
needed by pager.c