summaryrefslogtreecommitdiffstats
path: root/src/basic/tmpfile-util.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* basic/fs-util: move unlink_tempfilep() to tmpfile-utilMike Yuan2024-10-221-0/+11
|
* tmpfile-util: port link_tmpfile_at() over to linkat_replace()Lennart Poettering2024-03-141-26/+6
|
* fs-util: move link_fd() from tmpfile-util.c into generic fs-util.cLennart Poettering2024-03-141-20/+0
| | | | | It's a generically useful call, let's move it so that we can use it at more places.
* tmpfile-util: add new LINK_TMPFILE_SYNC flag for syncing properly ↵Lennart Poettering2023-06-131-21/+34
| | | | | | | | before/after linking in the file This syncs the data before linking it in, and both data + dir once done. This should give us proper semantics for installing files safely into the fs.
* tmpfile-util: turn last parameter of link_tmpfile() into a proper flagsLennart Poettering2023-06-131-5/+5
| | | | | | | | This changes a boolean param into a proper bitflag field. Given this only defines a single flag for now this doesn't look like much of an improvement. But we'll add another flag shortly, where it starts to make more sense.
* tmpfile-util: Add open_tmpfile_linkable_at() and link_tmpfile_at()Daan De Meyer2023-03-211-10/+11
|
* tmpfile-util: teach link_tmpfile() to optionally replace filesLennart Poettering2023-03-031-11/+59
|
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-3/+3
| | | | | | | | | | | | | | | | -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.
* tmpfile-util: Introduce fopen_temporary_child()Daan De Meyer2022-11-171-22/+50
| | | | | | | Instead of having fopen_temporary() create the file either next to an existing file or in tmp/, let's split this up clearly into two different functions, one for creating temporary files next to existing files, and one for creating a temporary file in a directory.
* tmpfile-util: Add missing assertDaan De Meyer2022-11-111-0/+2
|
* tmpfile-util: Add fopen_temporary_at()Daan De Meyer2022-11-091-9/+9
|
* tmpfile-util: Introduce mkdtemp_open()Daan De Meyer2022-11-091-0/+20
|
* tmpfile-util: truncate original filename if the result filename is too longYu Watanabe2022-09-031-64/+65
| | | | This also verify that the extra string does not contain '/'.
* bootctl: generalize open_tmpfile_linkable() use a bitLennart Poettering2022-03-221-0/+39
| | | | | We want FILE* here, instead of a plain fd. Let's generalize this in tmpfile-util.c, so we can reuse it later easily.
* tree-wide: use new RET_NERRNO() helper at various placesLennart Poettering2021-11-161-20/+5
|
* tree-wide: port things over to FORMAT_PROC_FD_PATH()Lennart Poettering2021-08-191-5/+1
|
* tree-wide: always drop unnecessary dot in pathYu Watanabe2021-05-281-3/+3
|
* tree-wide: make use of path_extend() at many placesLennart Poettering2021-05-271-10/+4
| | | | This is not a comprehensive port, but mostly some low-hanging fruit.
* tree-wide: update comment about unnecessary initializationYu Watanabe2021-04-131-1/+1
|
* tmpfile: port tempfn_*() to path_extract_*()Lennart Poettering2021-03-021-37/+46
|
* treewide: tighten variable scope in loops (#18372)Susant Sahani2021-01-271-4/+2
| | | | Also use _cleanup_free_ in one more place.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* tmpfile-util: typo fixesLennart Poettering2020-06-261-1/+1
|
* *: use _cleanup_close_ with fdopen() where trivialVito Caputo2020-03-311-5/+3
| | | | Also convert these to use take_fdopen().
* *: convert amenable fdopen calls to take_fdopenVito Caputo2020-03-311-3/+1
| | | | | Mechanical change to eliminate some cruft by using the new take_fdopen{_unlocked}() wrappers where trivial.
* basic/tmpfile: avoid maybe-uninitialized warning in mkostemp_safe()Thomas Haller2019-12-161-1/+1
| | | | | | | | | | | | | The variable is always initialized, but the compiler might not notice that. With gcc-9.2.1-1.fc31: $ CFLAGS='-Werror=maybe-uninitialized -Og' meson build $ ninja -C build [...] ../src/basic/tmpfile-util.c: In function ‘mkostemp_safe’: ../src/basic/tmpfile-util.c:76:12: error: ‘fd’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 76 | if (fd < 0) | ^
* tmpfile-util: modernize mkostemp_safe() a bitLennart Poettering2019-12-041-2/+2
|
* tmpfile-util: if no path is passed to fopen_temporary() make one upLennart Poettering2019-12-041-18/+28
| | | | Let's beef up functionality a bit, and modernize the whole function.
* tree-wide: drop stdio.h when stdio-util.h is includedYu Watanabe2019-11-031-1/+0
|
* tree-wide: replace strjoin() with path_join()Yu Watanabe2019-06-201-1/+1
|
* tmpfile-util: simplify umask reset declarationLennart Poettering2019-05-241-3/+1
|
* Add open_memstream_unlocked() wrapperZbigniew Jędrzejewski-Szmek2019-04-121-1/+0
|
* Add fdopen_unlocked() wrapperZbigniew Jędrzejewski-Szmek2019-04-121-6/+5
|
* Make fopen_temporary and fopen_temporary_label unlockedZbigniew Jędrzejewski-Szmek2019-04-121-0/+7
| | | | | | | | This is partially a refactoring, but also makes many more places use unlocked operations implicitly, i.e. all users of fopen_temporary(). AFAICT, the uses are always for short-lived files which are not shared externally, and are just used within the same context. Locking is not necessary.
* basic/tmpfile-util.c: fix build without O_TMPFILEFabrice Fontaine2019-01-111-0/+1
| | | | | | | | | | | | systemd fails to build on kernel without O_TMPFILE (< 3.11) since https://github.com/systemd/systemd/commit/dea72eda9cdbfeedd24cbe8c734ad0639bf96cde To fix this error, include missing_fcntl.h Fixes: - http://autobuild.buildroot.org/results/699c078aa078240c6741da4dbd0871450ceeca92 Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
* tree-wide: Remove O_CLOEXEC from fdopenChris Down2018-12-121-1/+1
| | | | | | | | | | | | fdopen doesn't accept "e", it's ignored. Let's not mislead people into believing that it actually sets O_CLOEXEC. From `man 3 fdopen`: > e (since glibc 2.7): > Open the file with the O_CLOEXEC flag. See open(2) for more information. This flag is ignored for fdopen() As mentioned by @jlebon in #11131.
* util-lib: split out all temporary file related calls into tmpfiles-util.cLennart Poettering2018-12-021-0/+329
This splits out a bunch of functions from fileio.c that have to do with temporary files. Simply to make the header files a bit shorter, and to group things more nicely. No code changes, just some rearranging of source files.