summaryrefslogtreecommitdiff
path: root/src/basic/copy.h
Commit message (Collapse)AuthorAgeFilesLines
* copy: move sync_rights() to copy.c and rename copy_rights()Lennart Poettering2021-03-041-0/+1
| | | | | | | It's so similar to copy_access(), hence let's move it over and rename it in similar style to the rest of the functions. No change in behaviour, just moving things over.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* basic: include stddef.h since we use NULL in headerLennart Poettering2020-10-071-0/+1
|
* copy: optionally, reproduce hardlinks from source in destinationLennart Poettering2020-09-091-0/+1
| | | | | | | | | | This is useful for duplicating trees that contain hardlinks: we keep track of potential hardlinks and try to reproduce them within the destination tree. (We do not hardlink between source and destination!). This is useful for trees like ostree images which heavily use hardlinks and which are otherwise exploded into separate copies of all files when we duplicate the trees.
* copy: add copy_access() helper for copying access modeLennart Poettering2020-08-111-0/+1
|
* copy: add flag COPY_MAC_CREATE to create with correct labelChristian Göttsche2019-11-281-0/+1
| | | | Useful for MAC aware file creation like in systemd-tmpfiles.
* copy: optionally check for SIGINT regularly, and abort operation safelyLennart Poettering2019-07-171-0/+1
|
* util-lib: when copying files make sure to apply some chattrs early, some lateLennart Poettering2019-03-281-6/+6
| | | | | | | Some chattrs only work sensible if you set them right after opening a file for create (think: FS_NOCOW_FL). Others only work when they are applied when the file is fully written (think: FS_IMMUTABLE_FL). Let's take that into account when copying files and applying a chattr to them.
* copy: don't synthesize a 'user.crtime_usec' xattr on copy unless explicitly ↵Lennart Poettering2019-03-011-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | requested Previously, when we'd copy an individual file we'd synthesize a user.crtime_usec xattr with the source's creation time if we can determine it. As the creation/birth time was until recently not queriable form userspace this effectively just propagated the same xattr on the source to the same xattr on the destination. However, current kernels now allow to query the birthtime using statx() and we do make use of that now. Which means that suddenly we started synthesizing these xattrs much more regularly. Doing this actually does make sense, but only in very few cases: not for the typical regular files we copy, but certainly when dealing with disk images. Hence, let's keep this kind of propagation, but let's make it a flag and default to off. Then turn it on whenever we deal with disk images, and leave it off otherwise. This is particularly relevant as overlayfs combining a real fs, and a tmpfs on top will result in EOPNOTSUPP when it is attempted to open a file with xattrs for writing, as tmpfs does not support xattrs, and hence the copy-up cannot work. Hence, let's avoid synthesizing this needlessly, to increase compat with overlayfs.
* copy: Add a COPY_MERGE_EMPTY flag to merge only if the target is emptyRyan Gonzalez2019-01-081-4/+5
|
* copy: support getting progress feedback from the various copy functionsLennart Poettering2018-11-261-9/+41
| | | | | | | | | This adds two optional functions that may be passed to the various copy functions. One is invoked whenever we start copying a new file object, the other while we copy file payload in each loop iteration. When the caller passes one or both they can get notifications about copy progress, for example to log where things are.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-4/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: unify how we define bit mak enumsLennart Poettering2018-06-121-4/+4
| | | | | | Let's always write "1 << 0", "1 << 1" and so on, except where we need more than 31 flag bits, where we write "UINT64(1) << 0", and so on to force 64bit values.
* copy: extend check for mount point crossingLennart Poettering2018-06-071-3/+4
| | | | | | | | | | | | 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: rearrange flags field definitionLennart Poettering2018-04-131-3/+3
| | | | Let's use the usual 1U << 0,1,2,3,4 spelling for definiting flags enums.
* copy: extend copy_bytes() a bitLennart Poettering2018-04-131-1/+4
| | | | | | | 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.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | 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.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* machined: when copying files from/to userns containers chown to rootLennart Poettering2017-02-171-2/+2
| | | | | | | | 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-02-171-8/+14
| | | | | | | | 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.
* machined: support non-btrfs file systems with "machinectl clone"Lennart Poettering2016-05-021-0/+1
| | | | | | | | 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
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* basic: include only what we useThomas Hindoe Paaboel Andersen2015-11-301-0/+1
| | | | | This is a cleaned up result of running iwyu but without forward declarations on src/basic.
* tree-wide: never use the off_t unless glibc makes us use itLennart Poettering2015-09-101-1/+2
| | | | | | | | | | | off_t is a really weird type as it is usually 64bit these days (at least in sane programs), but could theoretically be 32bit. We don't support off_t as 32bit builds though, but still constantly deal with safely converting from off_t to other types and back for no point. Hence, never use the type anymore. Always use uint64_t instead. This has various benefits, including that we can expose these values directly as D-Bus properties, and also that the values parse the same in all cases.
* build-sys: split internal basic/ library from shared/Kay Sievers2015-06-111-0/+35
basic/ can be used by everything cannot use anything outside of basic/ libsystemd/ can use basic/ cannot use shared/ shared/ can use libsystemd/