summaryrefslogtreecommitdiffstats
path: root/src/basic
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2024-10-24 19:44:10 +0200
committerGitHub <noreply@github.com>2024-10-24 19:44:10 +0200
commit4e69da071deb1822e2488231ebfd1e57297819ad (patch)
tree69bc4ad405b925b02aa0b4547c50674af64d9cf8 /src/basic
parentman: insert a comma before 'and' (diff)
parentcore: clean up errors for live mounting (diff)
downloadsystemd-4e69da071deb1822e2488231ebfd1e57297819ad.tar.xz
systemd-4e69da071deb1822e2488231ebfd1e57297819ad.zip
Merge pull request #34799 from YHNdnzj/service-followups
core: follow-ups for live mount
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/fs-util.c11
-rw-r--r--src/basic/fs-util.h2
-rw-r--r--src/basic/tmpfile-util.c11
-rw-r--r--src/basic/tmpfile-util.h2
4 files changed, 13 insertions, 13 deletions
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c
index 7c88e9fef7..db0a316e6d 100644
--- a/src/basic/fs-util.c
+++ b/src/basic/fs-util.c
@@ -694,17 +694,6 @@ int access_fd(int fd, int mode) {
return 0;
}
-void unlink_tempfilep(char (*p)[]) {
- assert(p);
-
- /* If the file is created with mkstemp(), it will (almost always)
- * change the suffix. Treat this as a sign that the file was
- * successfully created. We ignore both the rare case where the
- * original suffix is used and unlink failures. */
- if (!endswith(*p, ".XXXXXX"))
- (void) unlink(*p);
-}
-
int unlinkat_deallocate(int fd, const char *name, UnlinkDeallocateFlags flags) {
_cleanup_close_ int truncate_fd = -EBADF;
struct stat st;
diff --git a/src/basic/fs-util.h b/src/basic/fs-util.h
index 93af685eef..028c86a3b2 100644
--- a/src/basic/fs-util.h
+++ b/src/basic/fs-util.h
@@ -112,8 +112,6 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(char*, unlink_and_free);
int access_fd(int fd, int mode);
-void unlink_tempfilep(char (*p)[]);
-
typedef enum UnlinkDeallocateFlags {
UNLINK_REMOVEDIR = 1 << 0,
UNLINK_ERASE = 1 << 1,
diff --git a/src/basic/tmpfile-util.c b/src/basic/tmpfile-util.c
index 3a3f7dcc0f..5addd8e8a9 100644
--- a/src/basic/tmpfile-util.c
+++ b/src/basic/tmpfile-util.c
@@ -118,6 +118,17 @@ int fmkostemp_safe(char *pattern, const char *mode, FILE **ret_f) {
return 0;
}
+void unlink_tempfilep(char (*p)[]) {
+ assert(p);
+
+ /* If the file is created with mkstemp(), it will (almost always) change the suffix.
+ * Treat this as a sign that the file was successfully created. We ignore both the rare case
+ * where the original suffix is used and unlink failures. */
+
+ if (!endswith(*p, ".XXXXXX"))
+ (void) unlink(*p);
+}
+
static int tempfn_build(const char *p, const char *pre, const char *post, bool child, char **ret) {
_cleanup_free_ char *d = NULL, *fn = NULL, *nf = NULL, *result = NULL;
size_t len_pre, len_post, len_add;
diff --git a/src/basic/tmpfile-util.h b/src/basic/tmpfile-util.h
index 8c917c0680..408f80e147 100644
--- a/src/basic/tmpfile-util.h
+++ b/src/basic/tmpfile-util.h
@@ -18,6 +18,8 @@ static inline int fopen_temporary_child(const char *path, FILE **ret_file, char
int mkostemp_safe(char *pattern);
int fmkostemp_safe(char *pattern, const char *mode, FILE**_f);
+void unlink_tempfilep(char (*p)[]);
+
int tempfn_xxxxxx(const char *p, const char *extra, char **ret);
int tempfn_random(const char *p, const char *extra, char **ret);
int tempfn_random_child(const char *p, const char *extra, char **ret);