fs-util: Reduce transitive includes
This commit is contained in:
committed by
Yu Watanabe
parent
c034915cb6
commit
fda652117e
@@ -4,6 +4,7 @@
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "btrfs.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "path-util.h"
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "cgroup-util.h"
|
||||
#include "constants.h"
|
||||
#include "dirent-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "extract-word.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "chase.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "btrfs.h"
|
||||
#include "chattr-util.h"
|
||||
#include "dirent-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
@@ -376,6 +377,10 @@ int fd_warn_permissions(const char *path, int fd) {
|
||||
return stat_warn_permissions(path, &st);
|
||||
}
|
||||
|
||||
int access_nofollow(const char *path, mode_t mode) {
|
||||
return RET_NERRNO(faccessat(AT_FDCWD, path, mode, AT_SYMLINK_NOFOLLOW));
|
||||
}
|
||||
|
||||
int touch_fd(int fd, usec_t stamp) {
|
||||
assert(fd >= 0);
|
||||
|
||||
@@ -425,6 +430,10 @@ int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gi
|
||||
return RET_GATHER(ret, touch_fd(fd, stamp));
|
||||
}
|
||||
|
||||
int touch(const char *path) {
|
||||
return touch_file(path, false, USEC_INFINITY, UID_INVALID, GID_INVALID, MODE_INVALID);
|
||||
}
|
||||
|
||||
int symlinkat_idempotent(const char *from, int atfd, const char *to, bool make_relative) {
|
||||
_cleanup_free_ char *relpath = NULL;
|
||||
int r;
|
||||
@@ -676,6 +685,16 @@ int unlink_or_warn(const char *filename) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *rmdir_and_free(char *p) {
|
||||
PROTECT_ERRNO;
|
||||
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
(void) rmdir(p);
|
||||
return mfree(p);
|
||||
}
|
||||
|
||||
int access_fd(int fd, int mode) {
|
||||
assert(fd >= 0);
|
||||
|
||||
|
||||
+4
-19
@@ -10,11 +10,9 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "lock-util.h"
|
||||
#include "memory-util.h"
|
||||
#include "time-util.h"
|
||||
#include "user-util.h"
|
||||
|
||||
#define MODE_INVALID ((mode_t) -1)
|
||||
|
||||
@@ -51,16 +49,11 @@ int futimens_opath(int fd, const struct timespec ts[2]);
|
||||
int fd_warn_permissions(const char *path, int fd);
|
||||
int stat_warn_permissions(const char *path, const struct stat *st);
|
||||
|
||||
#define access_nofollow(path, mode) \
|
||||
RET_NERRNO(faccessat(AT_FDCWD, (path), (mode), AT_SYMLINK_NOFOLLOW))
|
||||
int access_nofollow(const char *path, mode_t mode);
|
||||
|
||||
int touch_fd(int fd, usec_t stamp);
|
||||
|
||||
int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode);
|
||||
|
||||
static inline int touch(const char *path) {
|
||||
return touch_file(path, false, USEC_INFINITY, UID_INVALID, GID_INVALID, MODE_INVALID);
|
||||
}
|
||||
int touch(const char *path);
|
||||
|
||||
int symlinkat_idempotent(const char *from, int atfd, const char *to, bool make_relative);
|
||||
static inline int symlink_idempotent(const char *from, const char *to, bool make_relative) {
|
||||
@@ -90,15 +83,7 @@ int var_tmp_dir(const char **ret);
|
||||
int unlink_or_warn(const char *filename);
|
||||
|
||||
/* Useful for usage with _cleanup_(), removes a directory and frees the pointer */
|
||||
static inline char *rmdir_and_free(char *p) {
|
||||
PROTECT_ERRNO;
|
||||
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
(void) rmdir(p);
|
||||
return mfree(p);
|
||||
}
|
||||
char *rmdir_and_free(char *p);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rmdir_and_free);
|
||||
|
||||
static inline char* unlink_and_free(char *p) {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "lock-util.h"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "alloc-util.h"
|
||||
#include "btrfs.h"
|
||||
#include "chase.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "format-util.h"
|
||||
#include "fs-util.h"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "chase.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "filesystems.h"
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "dirent-util.h"
|
||||
#include "env-file.h"
|
||||
#include "env-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "chase.h"
|
||||
#include "errno-util.h"
|
||||
#include "extract-word.h"
|
||||
#include "fd-util.h"
|
||||
#include "fs-util.h"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "log.h"
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
|
||||
Reference in New Issue
Block a user