util-lib: split out all temporary file related calls into tmpfiles-util.c
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.
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#include "strv.h"
|
||||
#include "terminal-util.h"
|
||||
#include "time-util.h"
|
||||
#include "tmpfile-util.h"
|
||||
#include "umask-util.h"
|
||||
#include "utf8.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
#include "id128-util.h"
|
||||
#include "linux-3.13/dm-ioctl.h"
|
||||
#include "missing.h"
|
||||
#include "mountpoint-util.h"
|
||||
#include "mount-util.h"
|
||||
#include "mountpoint-util.h"
|
||||
#include "os-util.h"
|
||||
#include "path-util.h"
|
||||
#include "process-util.h"
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "string-table.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "tmpfile-util.h"
|
||||
#include "user-util.h"
|
||||
#include "xattr-util.h"
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "terminal-util.h"
|
||||
#include "tmpfile-util.h"
|
||||
#include "util.h"
|
||||
|
||||
/* Put this test here for a lack of better place */
|
||||
|
||||
@@ -34,21 +34,6 @@ int write_env_file_label(const char *fname, char **l) {
|
||||
return r;
|
||||
}
|
||||
|
||||
int fopen_temporary_label(const char *target,
|
||||
const char *path, FILE **f, char **temp_path) {
|
||||
int r;
|
||||
|
||||
r = mac_selinux_create_file_prepare(target, S_IFREG);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = fopen_temporary(path, f, temp_path);
|
||||
|
||||
mac_selinux_create_file_clear();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int create_shutdown_run_nologin_or_warn(void) {
|
||||
int r;
|
||||
|
||||
|
||||
@@ -12,6 +12,5 @@ static inline int write_string_file_atomic_label(const char *fn, const char *lin
|
||||
return write_string_file_atomic_label_ts(fn, line, NULL);
|
||||
}
|
||||
int write_env_file_label(const char *fname, char **l);
|
||||
int fopen_temporary_label(const char *target, const char *path, FILE **f, char **temp_path);
|
||||
|
||||
int create_shutdown_run_nologin_or_warn(void);
|
||||
|
||||
@@ -139,6 +139,8 @@ shared_sources = files('''
|
||||
switch-root.h
|
||||
sysctl-util.c
|
||||
sysctl-util.h
|
||||
tmpfile-util-label.c
|
||||
tmpfile-util-label.h
|
||||
tomoyo-util.c
|
||||
tomoyo-util.h
|
||||
udev-util.c
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
#include "install.h"
|
||||
#include "log.h"
|
||||
@@ -18,6 +17,7 @@
|
||||
#include "stat-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "tmpfile-util.h"
|
||||
#include "user-util.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "selinux-util.h"
|
||||
#include "tmpfile-util-label.h"
|
||||
#include "tmpfile-util.h"
|
||||
|
||||
int fopen_temporary_label(
|
||||
const char *target,
|
||||
const char *path,
|
||||
FILE **f,
|
||||
char **temp_path) {
|
||||
|
||||
int r;
|
||||
|
||||
r = mac_selinux_create_file_prepare(target, S_IFREG);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = fopen_temporary(path, f, temp_path);
|
||||
|
||||
mac_selinux_create_file_clear();
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* These functions are split out of tmpfile-util.h (and not for example just flags to the functions they wrap) in order
|
||||
* to optimize linking: This way, -lselinux is needed only for the callers of these functions that need selinux, but
|
||||
* not for all */
|
||||
|
||||
int fopen_temporary_label(const char *target, const char *path, FILE **f, char **temp_path);
|
||||
Reference in New Issue
Block a user