diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..de0956d
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,117 @@
+---
+BasedOnStyle: GNU
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveMacros: false
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlines: Left
+AlignOperands: true
+AlignTrailingComments: true
+AllowAllArgumentsOnNextLine: true
+AllowAllConstructorInitializersOnNextLine: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: Never
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: All
+AllowShortLambdasOnASingleLine: All
+AllowShortIfStatementsOnASingleLine: Never
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: All
+AlwaysBreakAfterReturnType: AllDefinitions
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: MultiLine
+BinPackArguments: true
+BinPackParameters: true
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: false
+AllowShortBlocksOnASingleLine: false
+BreakBeforeBraces: Allman
+BraceWrapping:
+ AfterCaseLabel: true
+ AfterClass: true
+ AfterControlStatement: true
+ AfterEnum: true
+ AfterFunction: true
+ AfterNamespace: true
+ AfterObjCDeclaration: true
+ AfterStruct: true
+ AfterUnion: true
+ BeforeCatch: true
+ BeforeElse: true
+ IndentBraces: true
+ SplitEmptyFunction: true
+ SplitEmptyRecord: true
+ SplitEmptyNamespace: true
+BreakBeforeBinaryOperators: All
+BreakBeforeBraces: Custom
+BreakBeforeInheritanceComma: false
+BreakInheritanceList: BeforeColon
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: false
+BreakConstructorInitializers: BeforeColon
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: true
+ColumnLimit: 0
+ContinuationIndentWidth: 4
+DeriveLineEnding: true
+DerivePointerAlignment: false
+DisableFormat: false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: false
+ForEachMacros:
+ - foreach
+ - Q_FOREACH
+ - BOOST_FOREACH
+IncludeBlocks: Preserve
+IncludeIsMainRegex: '(Test)?$'
+IncludeIsMainSourceRegex: ''
+IndentCaseLabels: false
+IndentGotoLabels: true
+IndentPPDirectives: AfterHash
+IndentWidth: 2
+IndentWrappedFunctionNames: false
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBinPackProtocolList: Auto
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakAssignment: 2
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+PointerAlignment: Right
+ReflowComments: true
+SortIncludes: false
+SortUsingDeclarations: true
+SpaceAfterCStyleCast: true
+SpaceAfterLogicalNot: true
+SpaceAfterTemplateKeyword: true
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: Always
+SpaceInEmptyBlock: false
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInConditionalStatement: false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+SpaceBeforeSquareBrackets: false
+TabWidth: 8
+UseCRLF: false
+UseTab: Never
+...
diff --git a/Makefile.am b/Makefile.am
index 9dfe8c6..9708b51 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -36,3 +36,6 @@ srpm: dist-gzip fuse-overlayfs.spec
echo $(VERSION)
$(MAKE) -C $(WD) dist-xz
rpmbuild -bs --define "_sourcedir $(WD)" --define "_specdir $(WD)" --define "_builddir $(WD)" --define "_srcrpmdir $(WD)" --define "_rpmdir $(WD)" --define "_buildrootdir $(WD)/.build" fuse-overlayfs.spec
+
+clang-format:
+ git ls-files | grep -E "\\.[hc]$$" | grep -v "^lib/" | xargs clang-format -style=file -i
diff --git a/direct.c b/direct.c
index 2c562ca..a1a5d7d 100644
--- a/direct.c
+++ b/direct.c
@@ -76,7 +76,7 @@ direct_fstat (struct ovl_layer *l, int fd, const char *path, unsigned int mask,
#ifdef HAVE_STATX
struct statx stx;
- ret = statx (fd, "", AT_STATX_DONT_SYNC|AT_EMPTY_PATH, mask, &stx);
+ ret = statx (fd, "", AT_STATX_DONT_SYNC | AT_EMPTY_PATH, mask, &stx);
if (ret < 0 && (errno == ENOSYS || errno == EINVAL))
goto fallback;
if (ret == 0)
@@ -88,7 +88,7 @@ direct_fstat (struct ovl_layer *l, int fd, const char *path, unsigned int mask,
return ret;
#endif
- fallback:
+fallback:
ret = fstat (fd, st);
if (ret != 0)
return ret;
@@ -103,7 +103,7 @@ direct_statat (struct ovl_layer *l, const char *path, struct stat *st, int flags
#ifdef HAVE_STATX
struct statx stx;
- ret = statx (l->fd, path, AT_STATX_DONT_SYNC|flags, mask, &stx);
+ ret = statx (l->fd, path, AT_STATX_DONT_SYNC | flags, mask, &stx);
if (ret < 0 && (errno == ENOSYS || errno == EINVAL))
goto fallback;
if (ret == 0)
@@ -114,7 +114,7 @@ direct_statat (struct ovl_layer *l, const char *path, struct stat *st, int flags
return ret;
#endif
- fallback:
+fallback:
ret = fstatat (l->fd, path, st, flags);
if (ret != 0)
return ret;
@@ -212,24 +212,22 @@ direct_support_acls (struct ovl_layer *l)
char value[32];
return fgetxattr (l->fd, ACL_XATTR, value, sizeof (value)) >= 0
- || errno != ENOTSUP;
+ || errno != ENOTSUP;
}
-
-struct data_source direct_access_ds =
- {
- .num_of_layers = direct_num_of_layers,
- .load_data_source = direct_load_data_source,
- .cleanup = direct_cleanup,
- .file_exists = direct_file_exists,
- .statat = direct_statat,
- .fstat = direct_fstat,
- .opendir = direct_opendir,
- .readdir = direct_readdir,
- .closedir = direct_closedir,
- .openat = direct_openat,
- .getxattr = direct_getxattr,
- .listxattr = direct_listxattr,
- .readlinkat = direct_readlinkat,
- .support_acls = direct_support_acls,
- };
+struct data_source direct_access_ds = {
+ .num_of_layers = direct_num_of_layers,
+ .load_data_source = direct_load_data_source,
+ .cleanup = direct_cleanup,
+ .file_exists = direct_file_exists,
+ .statat = direct_statat,
+ .fstat = direct_fstat,
+ .opendir = direct_opendir,
+ .readdir = direct_readdir,
+ .closedir = direct_closedir,
+ .openat = direct_openat,
+ .getxattr = direct_getxattr,
+ .listxattr = direct_listxattr,
+ .readlinkat = direct_readlinkat,
+ .support_acls = direct_support_acls,
+};
diff --git a/fuse-overlayfs.h b/fuse-overlayfs.h
index 695446f..39274f4 100644
--- a/fuse-overlayfs.h
+++ b/fuse-overlayfs.h
@@ -16,15 +16,15 @@
along with this program. If not, see .
*/
#ifndef FUSE_OVERLAYFS_H
-# define FUSE_OVERLAYFS_H
-# define _GNU_SOURCE
+#define FUSE_OVERLAYFS_H
+#define _GNU_SOURCE
-# include
-# include
-# include
-# include
+#include
+#include
+#include
+#include
-# define ACL_XATTR "system.posix_acl_default"
+#define ACL_XATTR "system.posix_acl_default"
typedef struct hash_table Hash_table;
@@ -143,39 +143,39 @@ struct ovl_layer
struct data_source
{
int (*num_of_layers) (const char *opaque, const char *path);
- int (*load_data_source)(struct ovl_layer *l, const char *opaque, const char *path, int n_layer);
- int (*cleanup)(struct ovl_layer *l);
- int (*file_exists)(struct ovl_layer *l, const char *pathname);
- int (*statat)(struct ovl_layer *l, const char *path, struct stat *st, int flags, unsigned int mask);
- int (*fstat)(struct ovl_layer *l, int fd, const char *path, unsigned int mask, struct stat *st);
- void *(*opendir)(struct ovl_layer *l, const char *path);
- struct dirent *(*readdir)(void *dirp);
- int (*closedir)(void *dirp);
- int (*openat)(struct ovl_layer *l, const char *path, int flags, mode_t mode);
- int (*listxattr)(struct ovl_layer *l, const char *path, char *buf, size_t size);
- int (*getxattr)(struct ovl_layer *l, const char *path, const char *name, char *buf, size_t size);
- ssize_t (*readlinkat)(struct ovl_layer *l, const char *path, char *buf, size_t bufsiz);
- bool (*support_acls)(struct ovl_layer *l);
+ int (*load_data_source) (struct ovl_layer *l, const char *opaque, const char *path, int n_layer);
+ int (*cleanup) (struct ovl_layer *l);
+ int (*file_exists) (struct ovl_layer *l, const char *pathname);
+ int (*statat) (struct ovl_layer *l, const char *path, struct stat *st, int flags, unsigned int mask);
+ int (*fstat) (struct ovl_layer *l, int fd, const char *path, unsigned int mask, struct stat *st);
+ void *(*opendir) (struct ovl_layer *l, const char *path);
+ struct dirent *(*readdir) (void *dirp);
+ int (*closedir) (void *dirp);
+ int (*openat) (struct ovl_layer *l, const char *path, int flags, mode_t mode);
+ int (*listxattr) (struct ovl_layer *l, const char *path, char *buf, size_t size);
+ int (*getxattr) (struct ovl_layer *l, const char *path, const char *name, char *buf, size_t size);
+ ssize_t (*readlinkat) (struct ovl_layer *l, const char *path, char *buf, size_t bufsiz);
+ bool (*support_acls) (struct ovl_layer *l);
};
/* passthrough to the file system. */
extern struct data_source direct_access_ds;
-# ifndef HAVE_STATX
-# define STATX_TYPE 0x00000001U /* Want/got stx_mode & S_IFMT */
-# define STATX_MODE 0x00000002U /* Want/got stx_mode & ~S_IFMT */
-# define STATX_NLINK 0x00000004U /* Want/got stx_nlink */
-# define STATX_UID 0x00000008U /* Want/got stx_uid */
-# define STATX_GID 0x00000010U /* Want/got stx_gid */
-# define STATX_ATIME 0x00000020U /* Want/got stx_atime */
-# define STATX_MTIME 0x00000040U /* Want/got stx_mtime */
-# define STATX_CTIME 0x00000080U /* Want/got stx_ctime */
-# define STATX_INO 0x00000100U /* Want/got stx_ino */
-# define STATX_SIZE 0x00000200U /* Want/got stx_size */
-# define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */
-# define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */
-# define STATX_BTIME 0x00000800U /* Want/got stx_btime */
-# define STATX_ALL 0x00000fffU /* All currently supported flags */
-# endif
+#ifndef HAVE_STATX
+# define STATX_TYPE 0x00000001U /* Want/got stx_mode & S_IFMT */
+# define STATX_MODE 0x00000002U /* Want/got stx_mode & ~S_IFMT */
+# define STATX_NLINK 0x00000004U /* Want/got stx_nlink */
+# define STATX_UID 0x00000008U /* Want/got stx_uid */
+# define STATX_GID 0x00000010U /* Want/got stx_gid */
+# define STATX_ATIME 0x00000020U /* Want/got stx_atime */
+# define STATX_MTIME 0x00000040U /* Want/got stx_mtime */
+# define STATX_CTIME 0x00000080U /* Want/got stx_ctime */
+# define STATX_INO 0x00000100U /* Want/got stx_ino */
+# define STATX_SIZE 0x00000200U /* Want/got stx_size */
+# define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */
+# define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */
+# define STATX_BTIME 0x00000800U /* Want/got stx_btime */
+# define STATX_ALL 0x00000fffU /* All currently supported flags */
+#endif
#endif
diff --git a/fuse_overlayfs_error.h b/fuse_overlayfs_error.h
index bced0b2..5e7d128 100644
--- a/fuse_overlayfs_error.h
+++ b/fuse_overlayfs_error.h
@@ -17,24 +17,26 @@
*/
#ifndef FUSE_OVERLAYFS_ERROR_H
-# define FUSE_OVERLAYFS_ERROR_H
+#define FUSE_OVERLAYFS_ERROR_H
-# include
+#include
-# ifdef HAVE_ERROR_H
+#ifdef HAVE_ERROR_H
# include
-# else
-# define error(status, errno, fmt, ...) do { \
- if (errno == 0) \
- fprintf (stderr, "fuse-overlayfs: " fmt "\n", ##__VA_ARGS__); \
- else \
+#else
+# define error(status, errno, fmt, ...) \
+ do \
{ \
- fprintf (stderr, "fuse-overlayfs: " fmt, ##__VA_ARGS__); \
- fprintf (stderr, ": %s\n", strerror (errno)); \
- } \
- if (status) \
- exit (status); \
- } while(0)
-# endif
+ if (errno == 0) \
+ fprintf (stderr, "fuse-overlayfs: " fmt "\n", ##__VA_ARGS__); \
+ else \
+ { \
+ fprintf (stderr, "fuse-overlayfs: " fmt, ##__VA_ARGS__); \
+ fprintf (stderr, ": %s\n", strerror (errno)); \
+ } \
+ if (status) \
+ exit (status); \
+ } while (0)
+#endif
#endif
diff --git a/main.c b/main.c
index a69ea48..47c13bd 100644
--- a/main.c
+++ b/main.c
@@ -42,7 +42,7 @@
#include
#include
#ifdef HAVE_SYS_SENDFILE_H
-# include
+# include
#endif
#include
@@ -67,9 +67,8 @@
#include
#ifndef TEMP_FAILURE_RETRY
-#define TEMP_FAILURE_RETRY(expression) \
- (__extension__ \
- ({ long int __result; \
+# define TEMP_FAILURE_RETRY(expression) \
+ (__extension__ ({ long int __result; \
do __result = (long int) (expression); \
while (__result == -1L && errno == EINTR); \
__result; }))
@@ -108,15 +107,15 @@ cleanup_lockp (int *l)
*l = 0;
}
-#define cleanup_lock __attribute__((cleanup (cleanup_lockp)))
+#define cleanup_lock __attribute__ ((cleanup (cleanup_lockp)))
#ifndef HAVE_OPEN_BY_HANDLE_AT
struct file_handle
{
- unsigned int handle_bytes; /* Size of f_handle [in, out] */
- int handle_type; /* Handle type [out] */
- unsigned char f_handle[0]; /* File identifier (sized by
- caller) [out] */
+ unsigned int handle_bytes; /* Size of f_handle [in, out] */
+ int handle_type; /* Handle type [out] */
+ unsigned char f_handle[0]; /* File identifier (sized by
+ caller) [out] */
};
int
@@ -127,15 +126,15 @@ open_by_handle_at (int mount_fd, struct file_handle *handle, int flags)
#endif
#ifndef RENAME_NOREPLACE
-# define RENAME_NOREPLACE (1 << 0)
+# define RENAME_NOREPLACE (1 << 0)
#endif
#ifndef RENAME_EXCHANGE
-# define RENAME_EXCHANGE (1 << 1)
+# define RENAME_EXCHANGE (1 << 1)
#endif
#ifndef RENAME_WHITEOUT
-# define RENAME_WHITEOUT (1 << 2)
+# define RENAME_WHITEOUT (1 << 2)
#endif
#define XATTR_PREFIX "user.fuseoverlayfs."
@@ -148,20 +147,19 @@ open_by_handle_at (int mount_fd, struct file_handle *handle, int flags)
#define PRIVILEGED_OPAQUE_XATTR "trusted.overlay.opaque"
#define PRIVILEGED_ORIGIN_XATTR "trusted.overlay.origin"
#define OPAQUE_WHITEOUT ".wh..wh..opq"
-#define WHITEOUT_MAX_LEN (sizeof (".wh.")-1)
+#define WHITEOUT_MAX_LEN (sizeof (".wh.") - 1)
-#if !defined FICLONE && defined __linux__
-# define FICLONE _IOW (0x94, 9, int)
+#if ! defined FICLONE && defined __linux__
+# define FICLONE _IOW (0x94, 9, int)
#endif
-#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && !defined __cplusplus
+#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && ! defined __cplusplus
_Static_assert (sizeof (fuse_ino_t) >= sizeof (uintptr_t),
- "fuse_ino_t too small to hold uintptr_t values!");
+ "fuse_ino_t too small to hold uintptr_t values!");
#else
struct _uintptr_to_must_hold_fuse_ino_t_dummy_struct
{
- unsigned _uintptr_to_must_hold_fuse_ino_t:
- ((sizeof (fuse_ino_t) >= sizeof (uintptr_t)) ? 1 : -1);
+ unsigned _uintptr_to_must_hold_fuse_ino_t : ((sizeof (fuse_ino_t) >= sizeof (uintptr_t)) ? 1 : -1);
};
#endif
@@ -194,48 +192,48 @@ get_timeout (struct ovl_data *lo)
}
static const struct fuse_opt ovl_opts[] = {
- {"redirect_dir=%s",
- offsetof (struct ovl_data, redirect_dir), 0},
- {"context=%s",
- offsetof (struct ovl_data, context), 0},
- {"lowerdir=%s",
- offsetof (struct ovl_data, lowerdir), 0},
- {"upperdir=%s",
- offsetof (struct ovl_data, upperdir), 0},
- {"workdir=%s",
- offsetof (struct ovl_data, workdir), 0},
- {"uidmapping=%s",
- offsetof (struct ovl_data, uid_str), 0},
- {"gidmapping=%s",
- offsetof (struct ovl_data, gid_str), 0},
- {"timeout=%s",
- offsetof (struct ovl_data, timeout_str), 0},
- {"threaded=%d",
- offsetof (struct ovl_data, threaded), 0},
- {"fsync=%d",
- offsetof (struct ovl_data, fsync), 1},
- {"fast_ino=%d",
- offsetof (struct ovl_data, fast_ino_check), 0},
- {"writeback=%d",
- offsetof (struct ovl_data, writeback), 1},
- {"noxattrs=%d",
- offsetof (struct ovl_data, disable_xattrs), 1},
- {"plugins=%s",
- offsetof (struct ovl_data, plugins), 0},
- {"xattr_permissions=%d",
- offsetof (struct ovl_data, xattr_permissions), 0},
- {"squash_to_root",
- offsetof (struct ovl_data, squash_to_root), 1},
- {"squash_to_uid=%d",
- offsetof (struct ovl_data, squash_to_uid), 1},
- {"squash_to_gid=%d",
- offsetof (struct ovl_data, squash_to_gid), 1},
- {"static_nlink",
- offsetof (struct ovl_data, static_nlink), 1},
- {"volatile", /* native overlay supports "volatile" to mean fsync=0. */
- offsetof (struct ovl_data, volatile_mode), 1},
- {"noacl",
- offsetof (struct ovl_data, noacl), 1},
+ { "redirect_dir=%s",
+ offsetof (struct ovl_data, redirect_dir), 0 },
+ { "context=%s",
+ offsetof (struct ovl_data, context), 0 },
+ { "lowerdir=%s",
+ offsetof (struct ovl_data, lowerdir), 0 },
+ { "upperdir=%s",
+ offsetof (struct ovl_data, upperdir), 0 },
+ { "workdir=%s",
+ offsetof (struct ovl_data, workdir), 0 },
+ { "uidmapping=%s",
+ offsetof (struct ovl_data, uid_str), 0 },
+ { "gidmapping=%s",
+ offsetof (struct ovl_data, gid_str), 0 },
+ { "timeout=%s",
+ offsetof (struct ovl_data, timeout_str), 0 },
+ { "threaded=%d",
+ offsetof (struct ovl_data, threaded), 0 },
+ { "fsync=%d",
+ offsetof (struct ovl_data, fsync), 1 },
+ { "fast_ino=%d",
+ offsetof (struct ovl_data, fast_ino_check), 0 },
+ { "writeback=%d",
+ offsetof (struct ovl_data, writeback), 1 },
+ { "noxattrs=%d",
+ offsetof (struct ovl_data, disable_xattrs), 1 },
+ { "plugins=%s",
+ offsetof (struct ovl_data, plugins), 0 },
+ { "xattr_permissions=%d",
+ offsetof (struct ovl_data, xattr_permissions), 0 },
+ { "squash_to_root",
+ offsetof (struct ovl_data, squash_to_root), 1 },
+ { "squash_to_uid=%d",
+ offsetof (struct ovl_data, squash_to_uid), 1 },
+ { "squash_to_gid=%d",
+ offsetof (struct ovl_data, squash_to_gid), 1 },
+ { "static_nlink",
+ offsetof (struct ovl_data, static_nlink), 1 },
+ { "volatile", /* native overlay supports "volatile" to mean fsync=0. */
+ offsetof (struct ovl_data, volatile_mode), 1 },
+ { "noacl",
+ offsetof (struct ovl_data, noacl), 1 },
FUSE_OPT_END
};
@@ -248,7 +246,7 @@ typedef unsigned char u8;
typedef unsigned char uuid_t[16];
/* The type returned by overlay exportfs ops when encoding an ovl_fh handle */
-#define OVL_FILEID 0xfb
+#define OVL_FILEID 0xfb
/* On-disk and in-memory format for redirect by file handle */
struct ovl_fh
@@ -333,7 +331,7 @@ check_can_mknod (struct ovl_data *lo)
sprintf (path, "%lu", get_next_wd_counter ());
- ret = mknodat (lo->workdir_fd, path, S_IFCHR|0700, makedev (0, 0));
+ ret = mknodat (lo->workdir_fd, path, S_IFCHR | 0700, makedev (0, 0));
if (ret == 0)
unlinkat (lo->workdir_fd, path, 0);
if (ret < 0 && errno == EPERM)
@@ -528,9 +526,9 @@ has_prefix (const char *str, const char *pref)
static bool
can_access_xattr (const char *name)
{
- return !has_prefix (name, XATTR_PREFIX)
- && !has_prefix (name, PRIVILEGED_XATTR_PREFIX)
- && !has_prefix (name, UNPRIVILEGED_XATTR_PREFIX);
+ return ! has_prefix (name, XATTR_PREFIX)
+ && ! has_prefix (name, PRIVILEGED_XATTR_PREFIX)
+ && ! has_prefix (name, UNPRIVILEGED_XATTR_PREFIX);
}
static ssize_t
@@ -547,8 +545,8 @@ write_permission_xattr (struct ovl_data *lo, int fd, const char *path, uid_t uid
return 0;
case 1:
- name = XATTR_PRIVILEGED_OVERRIDE_STAT;
- break;
+ name = XATTR_PRIVILEGED_OVERRIDE_STAT;
+ break;
case 2:
name = XATTR_OVERRIDE_STAT;
@@ -609,7 +607,7 @@ do_fchownat (struct ovl_data *lo, int dfd, const char *path, uid_t uid, gid_t gi
if (lo->xattr_permissions)
{
char proc_path[32];
- cleanup_close int fd = openat (dfd, path, O_NOFOLLOW|O_PATH);
+ cleanup_close int fd = openat (dfd, path, O_NOFOLLOW | O_PATH);
if (fd < 0)
return fd;
@@ -703,10 +701,10 @@ set_fd_opaque (int fd)
if (errno == ENOTSUP)
goto create_opq_whiteout;
if (errno != EPERM || (fsetxattr (fd, OPAQUE_XATTR, "y", 1, 0) < 0 && errno != ENOTSUP))
- return -1;
+ return -1;
}
- create_opq_whiteout:
- opq_whiteout_fd = TEMP_FAILURE_RETRY (safe_openat (fd, OPAQUE_WHITEOUT, O_CREAT|O_WRONLY|O_NONBLOCK, 0700));
+create_opq_whiteout:
+ opq_whiteout_fd = TEMP_FAILURE_RETRY (safe_openat (fd, OPAQUE_WHITEOUT, O_CREAT | O_WRONLY | O_NONBLOCK, 0700));
return (opq_whiteout_fd >= 0 || ret == 0) ? 0 : -1;
}
@@ -766,17 +764,17 @@ create_whiteout (struct ovl_data *lo, struct ovl_node *parent, const char *name,
break;
}
/* Not present in the lower layers, do not do anything. */
- if (!found)
+ if (! found)
return 0;
}
- if (!skip_mknod && can_mknod)
+ if (! skip_mknod && can_mknod)
{
char whiteout_path[PATH_MAX];
strconcat3 (whiteout_path, PATH_MAX, parent->path, "/", name);
- ret = mknodat (get_upper_layer (lo)->fd, whiteout_path, S_IFCHR|0700, makedev (0, 0));
+ ret = mknodat (get_upper_layer (lo)->fd, whiteout_path, S_IFCHR | 0700, makedev (0, 0));
if (ret == 0)
return 0;
@@ -804,7 +802,7 @@ create_whiteout (struct ovl_data *lo, struct ovl_node *parent, const char *name,
strconcat3 (whiteout_wh_path, PATH_MAX, parent->path, "/.wh.", name);
- fd = get_upper_layer (lo)->ds->openat (get_upper_layer (lo), whiteout_wh_path, O_CREAT|O_WRONLY|O_NONBLOCK, 0700);
+ fd = get_upper_layer (lo)->ds->openat (get_upper_layer (lo), whiteout_wh_path, O_CREAT | O_WRONLY | O_NONBLOCK, 0700);
if (fd < 0 && errno != EEXIST)
return -1;
@@ -835,7 +833,7 @@ delete_whiteout (struct ovl_data *lo, int dirfd, struct ovl_node *parent, const
strconcat3 (whiteout_path, PATH_MAX, parent->path, "/", name);
- if (get_upper_layer (lo)->ds->statat (get_upper_layer (lo), whiteout_path, &st, AT_SYMLINK_NOFOLLOW, STATX_MODE|STATX_TYPE) == 0
+ if (get_upper_layer (lo)->ds->statat (get_upper_layer (lo), whiteout_path, &st, AT_SYMLINK_NOFOLLOW, STATX_MODE | STATX_TYPE) == 0
&& (st.st_mode & S_IFMT) == S_IFCHR
&& major (st.st_rdev) == 0
&& minor (st.st_rdev) == 0)
@@ -875,11 +873,11 @@ find_mapping (unsigned int id, const struct ovl_data *data,
bool direct, bool uid)
{
const struct ovl_mapping *mapping = (uid ? data->uid_mappings
- : data->gid_mappings);
+ : data->gid_mappings);
if (direct && uid && data->squash_to_uid != -1)
return data->squash_to_uid;
- if (direct && !uid && data->squash_to_gid != -1)
+ if (direct && ! uid && data->squash_to_gid != -1)
return data->squash_to_gid;
if (direct && data->squash_to_root)
return 0;
@@ -922,7 +920,7 @@ rpl_stat (fuse_req_t req, struct ovl_node *node, int fd, const char *path, struc
struct ovl_data *data = ovl_data (req);
if (st_in)
- memcpy (st, st_in, sizeof (* st));
+ memcpy (st, st_in, sizeof (*st));
else if (fd >= 0)
ret = l->ds->fstat (l, fd, path, STATX_BASIC_STATS, st);
else if (path != NULL)
@@ -1043,7 +1041,7 @@ inode_free (void *p)
tmp->ino = NULL;
node_free (tmp);
- }
+ }
stats.inodes--;
free (i);
@@ -1110,7 +1108,7 @@ hide_node (struct ovl_data *lo, struct ovl_node *node, bool unlink_src)
bool needs_whiteout;
needs_whiteout = (node->last_layer != get_upper_layer (lo)) && (node->parent && node->parent->last_layer != get_upper_layer (lo));
- if (!needs_whiteout && node_dirp (node))
+ if (! needs_whiteout && node_dirp (node))
{
ret = is_directory_opaque (get_upper_layer (lo), node->path);
if (ret < 0)
@@ -1121,7 +1119,7 @@ hide_node (struct ovl_data *lo, struct ovl_node *node, bool unlink_src)
// if the parent directory is opaque, there's no need to put a whiteout in it.
if (node->parent != NULL)
- needs_whiteout = needs_whiteout && (is_directory_opaque (get_upper_layer(lo), node->parent->path) < 1);
+ needs_whiteout = needs_whiteout && (is_directory_opaque (get_upper_layer (lo), node->parent->path) < 1);
if (needs_whiteout)
{
@@ -1132,7 +1130,7 @@ hide_node (struct ovl_data *lo, struct ovl_node *node, bool unlink_src)
moved = true;
}
- if (!whiteout_created)
+ if (! whiteout_created)
{
if (node->parent)
{
@@ -1145,7 +1143,7 @@ hide_node (struct ovl_data *lo, struct ovl_node *node, bool unlink_src)
}
}
- if (!moved)
+ if (! moved)
{
if (renameat (node_dirfd (node), node->path, lo->workdir_fd, newpath) < 0)
return -1;
@@ -1169,7 +1167,7 @@ hide_node (struct ovl_data *lo, struct ovl_node *node, bool unlink_src)
node->hidden_dirfd = lo->workdir_fd;
free (node->path);
node->path = newpath;
- newpath = NULL; /* Do not auto cleanup. */
+ newpath = NULL; /* Do not auto cleanup. */
node->hidden = 1;
if (node->parent)
@@ -1334,7 +1332,7 @@ ovl_forget (fuse_req_t req, fuse_ino_t ino, uint64_t nlookup)
if (UNLIKELY (ovl_debug (req)))
fprintf (stderr, "ovl_forget(ino=%" PRIu64 ", nlookup=%lu)\n",
- ino, nlookup);
+ ino, nlookup);
do_forget (lo, ino, nlookup);
fuse_reply_none (req);
}
@@ -1348,7 +1346,7 @@ ovl_forget_multi (fuse_req_t req, size_t count, struct fuse_forget_data *forgets
if (UNLIKELY (ovl_debug (req)))
fprintf (stderr, "ovl_forget_multi(count=%zu, forgets=%p)\n",
- count, forgets);
+ count, forgets);
for (i = 0; i < count; i++)
do_forget (lo, forgets[i].ino, forgets[i].nlookup);
@@ -1371,7 +1369,7 @@ cleanup_node_initp (struct ovl_node **p)
free (n);
}
-#define cleanup_node_init __attribute__((cleanup (cleanup_node_initp)))
+#define cleanup_node_init __attribute__ ((cleanup (cleanup_node_initp)))
static void
node_set_name (struct ovl_node *node, char *name)
@@ -1492,7 +1490,7 @@ make_ovl_node (struct ovl_data *lo, const char *path, struct ovl_layer *layer, c
if (ret->path == NULL)
return NULL;
- if (!dir_p)
+ if (! dir_p)
ret->children = NULL;
else
{
@@ -1533,18 +1531,18 @@ make_ovl_node (struct ovl_data *lo, const char *path, struct ovl_layer *layer, c
break;
if (r < 0 && errno != ENOENT && errno != ENOTDIR && errno != ENAMETOOLONG)
- return NULL;
+ return NULL;
if (r == 0)
break;
}
if (! fast_ino_check)
- fd = it->ds->openat (it, npath, O_RDONLY|O_NONBLOCK|O_NOFOLLOW, 0755);
+ fd = it->ds->openat (it, npath, O_RDONLY | O_NONBLOCK | O_NOFOLLOW, 0755);
if (fd < 0)
{
- if (it->ds->statat (it, npath, &st, AT_SYMLINK_NOFOLLOW, STATX_TYPE|STATX_MODE|STATX_INO) == 0)
+ if (it->ds->statat (it, npath, &st, AT_SYMLINK_NOFOLLOW, STATX_TYPE | STATX_MODE | STATX_INO) == 0)
{
if (has_origin)
{
@@ -1560,7 +1558,7 @@ make_ovl_node (struct ovl_data *lo, const char *path, struct ovl_layer *layer, c
}
/* It is an open FD, stat the file and read the origin xattrs. */
- if (it->ds->fstat (it, fd, npath, STATX_TYPE|STATX_MODE|STATX_INO, &st) == 0)
+ if (it->ds->fstat (it, fd, npath, STATX_TYPE | STATX_MODE | STATX_INO, &st) == 0)
{
if (has_origin)
{
@@ -1580,7 +1578,7 @@ make_ovl_node (struct ovl_data *lo, const char *path, struct ovl_layer *layer, c
size_t s = ofh->len - sizeof (*ofh);
struct file_handle *fh = (struct file_handle *) buf;
- if (s < sizeof (buf) - sizeof(int) * 2)
+ if (s < sizeof (buf) - sizeof (int) * 2)
{
cleanup_close int originfd = -1;
@@ -1596,7 +1594,7 @@ make_ovl_node (struct ovl_data *lo, const char *path, struct ovl_layer *layer, c
originfd = open_by_handle_at (AT_FDCWD, fh, O_RDONLY);
if (originfd >= 0)
{
- if (it->ds->fstat (it, originfd, npath, STATX_TYPE|STATX_MODE|STATX_INO, &st) == 0)
+ if (it->ds->fstat (it, originfd, npath, STATX_TYPE | STATX_MODE | STATX_INO, &st) == 0)
{
ret->tmp_ino = st.st_ino;
ret->tmp_dev = st.st_dev;
@@ -1618,7 +1616,7 @@ make_ovl_node (struct ovl_data *lo, const char *path, struct ovl_layer *layer, c
origin = NULL;
}
-no_fd:
+ no_fd:
if (parent && parent->last_layer == it)
break;
}
@@ -1689,7 +1687,7 @@ load_dir (struct ovl_data *lo, struct ovl_node *n, struct ovl_layer *layer, char
struct ovl_layer *it, *upper_layer = get_upper_layer (lo);
char parent_whiteout_path[PATH_MAX];
- if (!n)
+ if (! n)
{
n = make_ovl_node (lo, path, layer, name, 0, 0, true, NULL, lo->fast_ino_check);
if (n == NULL)
@@ -1704,7 +1702,7 @@ load_dir (struct ovl_data *lo, struct ovl_node *n, struct ovl_layer *layer, char
else
strconcat3 (parent_whiteout_path, PATH_MAX, ".wh.", name, NULL);
- for (it = lo->layers; it && !stop_lookup; it = it->next)
+ for (it = lo->layers; it && ! stop_lookup; it = it->next)
{
struct stat st;
DIR *dp = NULL;
@@ -1764,7 +1762,7 @@ load_dir (struct ovl_data *lo, struct ovl_node *n, struct ovl_layer *layer, char
if (child)
{
child->last_layer = it;
- if (!child->whiteout || it != upper_layer)
+ if (! child->whiteout || it != upper_layer)
continue;
else
{
@@ -1903,7 +1901,7 @@ cleanup_layerp (struct ovl_layer **p)
free_layers (l);
}
-#define cleanup_layer __attribute__((cleanup (cleanup_layerp)))
+#define cleanup_layer __attribute__ ((cleanup (cleanup_layerp)))
static struct ovl_layer *
read_dirs (struct ovl_data *lo, char *path, bool low, struct ovl_layer *layers)
@@ -2064,14 +2062,14 @@ do_lookup_file (struct ovl_data *lo, fuse_ino_t parent, const char *name)
node_set_name (&key, (char *) name);
node = hash_lookup (pnode->children, &key);
- if (node == NULL && !pnode->loaded)
+ if (node == NULL && ! pnode->loaded)
{
int ret;
struct ovl_layer *it;
struct stat st;
bool stop_lookup = false;
- for (it = lo->layers; it && !stop_lookup; it = it->next)
+ for (it = lo->layers; it && ! stop_lookup; it = it->next)
{
char path[PATH_MAX];
char whpath[PATH_MAX];
@@ -2082,7 +2080,7 @@ do_lookup_file (struct ovl_data *lo, fuse_ino_t parent, const char *name)
strconcat3 (path, PATH_MAX, pnode->path, "/", name);
- ret = it->ds->statat (it, path, &st, AT_SYMLINK_NOFOLLOW, STATX_TYPE|STATX_MODE|STATX_INO);
+ ret = it->ds->statat (it, path, &st, AT_SYMLINK_NOFOLLOW, STATX_TYPE | STATX_MODE | STATX_INO);
if (ret < 0)
{
int saved_errno = errno;
@@ -2127,7 +2125,7 @@ do_lookup_file (struct ovl_data *lo, fuse_ino_t parent, const char *name)
if (ret < 0 && errno != ENOENT && errno != ENOTDIR && errno != ENAMETOOLONG)
return NULL;
if (ret == 0)
- node = make_whiteout_node (path, name);
+ node = make_whiteout_node (path, name);
else
{
wh_name = get_whiteout_name (name, &st);
@@ -2156,7 +2154,7 @@ do_lookup_file (struct ovl_data *lo, fuse_ino_t parent, const char *name)
stop_lookup = true;
}
}
-insert_node:
+ insert_node:
if (insert_node (pnode, node, false) == NULL)
{
node_free (node);
@@ -2180,7 +2178,7 @@ ovl_lookup (fuse_req_t req, fuse_ino_t parent, const char *name)
if (UNLIKELY (ovl_debug (req)))
fprintf (stderr, "ovl_lookup(parent=%" PRIu64 ", name=%s)\n",
- parent, name);
+ parent, name);
memset (&e, 0, sizeof (e));
@@ -2194,7 +2192,7 @@ ovl_lookup (fuse_req_t req, fuse_ino_t parent, const char *name)
return;
}
- if (!lo->static_nlink && node_dirp (node))
+ if (! lo->static_nlink && node_dirp (node))
{
node = reload_dir (lo, node);
if (node == NULL)
@@ -2405,7 +2403,7 @@ create_missing_whiteouts (struct ovl_data *lo, struct ovl_node *node, const char
static void
ovl_do_readdir (fuse_req_t req, fuse_ino_t ino, size_t size,
- off_t offset, struct fuse_file_info *fi, int plus)
+ off_t offset, struct fuse_file_info *fi, int plus)
{
struct ovl_data *lo = ovl_data (req);
struct ovl_dirp *d = ovl_dirp (fi);
@@ -2431,82 +2429,82 @@ ovl_do_readdir (fuse_req_t req, fuse_ino_t ino, size_t size,
p = buffer;
for (; remaining > 0 && offset < d->tbl_size; offset++)
- {
- int ret;
- size_t entsize;
- const char *name;
- struct ovl_node *node = d->tbl[offset];
- struct fuse_entry_param e;
- struct stat *st = &e.attr;
+ {
+ int ret;
+ size_t entsize;
+ const char *name;
+ struct ovl_node *node = d->tbl[offset];
+ struct fuse_entry_param e;
+ struct stat *st = &e.attr;
- if (node == NULL || node->whiteout || node->hidden)
- continue;
+ if (node == NULL || node->whiteout || node->hidden)
+ continue;
- if (offset == 0)
- name = ".";
- else if (offset == 1)
- name = "..";
- else
- {
- if (node->parent != d->parent)
- continue;
- name = node->name;
- }
+ if (offset == 0)
+ name = ".";
+ else if (offset == 1)
+ name = "..";
+ else
+ {
+ if (node->parent != d->parent)
+ continue;
+ name = node->name;
+ }
- if (!plus)
- {
- /* From the 'stbuf' argument the st_ino field and bits 12-15 of the
- * st_mode field are used. The other fields are ignored.
- */
- st->st_ino = node->tmp_ino;
- st->st_dev = node->tmp_dev;
- st->st_mode = node->ino->mode;
+ if (! plus)
+ {
+ /* From the 'stbuf' argument the st_ino field and bits 12-15 of the
+ * st_mode field are used. The other fields are ignored.
+ */
+ st->st_ino = node->tmp_ino;
+ st->st_dev = node->tmp_dev;
+ st->st_mode = node->ino->mode;
- entsize = fuse_add_direntry (req, p, remaining, name, st, offset + 1);
- }
- else
- {
- if (!lo->static_nlink && node_dirp (node))
- {
- node = reload_dir (lo, node);
- if (node == NULL)
- {
- fuse_reply_err (req, errno);
- return;
- }
- }
- memset (&e, 0, sizeof (e));
- ret = rpl_stat (req, node, -1, NULL, NULL, st);
- if (ret < 0)
- {
- fuse_reply_err (req, errno);
- return;
- }
+ entsize = fuse_add_direntry (req, p, remaining, name, st, offset + 1);
+ }
+ else
+ {
+ if (! lo->static_nlink && node_dirp (node))
+ {
+ node = reload_dir (lo, node);
+ if (node == NULL)
+ {
+ fuse_reply_err (req, errno);
+ return;
+ }
+ }
+ memset (&e, 0, sizeof (e));
+ ret = rpl_stat (req, node, -1, NULL, NULL, st);
+ if (ret < 0)
+ {
+ fuse_reply_err (req, errno);
+ return;
+ }
- e.attr_timeout = get_timeout (lo);
- e.entry_timeout = get_timeout (lo);
- e.ino = node_to_inode (node);
- entsize = fuse_add_direntry_plus (req, p, remaining, name, &e, offset + 1);
- if (entsize <= remaining)
- {
- /* First two entries are . and .. */
- if (offset >= 2)
- node->ino->lookups++;
- }
- }
+ e.attr_timeout = get_timeout (lo);
+ e.entry_timeout = get_timeout (lo);
+ e.ino = node_to_inode (node);
+ entsize = fuse_add_direntry_plus (req, p, remaining, name, &e, offset + 1);
+ if (entsize <= remaining)
+ {
+ /* First two entries are . and .. */
+ if (offset >= 2)
+ node->ino->lookups++;
+ }
+ }
- if (entsize > remaining)
- break;
+ if (entsize > remaining)
+ break;
- p += entsize;
- remaining -= entsize;
- }
+ p += entsize;
+ remaining -= entsize;
+ }
fuse_reply_buf (req, buffer, size - remaining);
}
static void
ovl_readdir (fuse_req_t req, fuse_ino_t ino, size_t size,
- off_t offset, struct fuse_file_info *fi)
+ off_t offset, struct fuse_file_info *fi)
{
cleanup_lock int l = enter_big_lock ();
if (UNLIKELY (ovl_debug (req)))
@@ -2516,7 +2514,7 @@ ovl_readdir (fuse_req_t req, fuse_ino_t ino, size_t size,
static void
ovl_readdirplus (fuse_req_t req, fuse_ino_t ino, size_t size,
- off_t offset, struct fuse_file_info *fi)
+ off_t offset, struct fuse_file_info *fi)
{
cleanup_lock int l = enter_big_lock ();
if (UNLIKELY (ovl_debug (req)))
@@ -2749,7 +2747,7 @@ ovl_access (fuse_req_t req, fuse_ino_t ino, int mask)
if (UNLIKELY (ovl_debug (req)))
fprintf (stderr, "ovl_access(ino=%" PRIu64 ", mask=%d)\n",
- ino, mask);
+ ino, mask);
if ((mask & n->ino->mode) == mask)
fuse_reply_err (req, 0);
@@ -2776,11 +2774,11 @@ copy_xattr (int sfd, int dfd, char *buf, size_t buf_size)
s = safe_read_xattr (&v, sfd, it, 256);
if (s < 0)
- {
- if (errno == EOVERFLOW)
- continue;
- return -1;
- }
+ {
+ if (errno == EOVERFLOW)
+ continue;
+ return -1;
+ }
if (fsetxattr (dfd, it, v, s, 0) < 0)
{
@@ -2871,7 +2869,7 @@ create_directory (struct ovl_data *lo, int dirfd, const char *name, const struct
mode |= 0755;
need_rename = set_opaque || times || xattr_sfd >= 0 || uid != lo->uid || gid != lo->gid;
- if (!need_rename)
+ if (! need_rename)
{
/* mkdir can be used directly without a temporary directory in the working directory. */
ret = mkdirat (dirfd, name, mode);
@@ -2982,7 +2980,7 @@ create_directory (struct ovl_data *lo, int dirfd, const char *name, const struct
out:
saved_errno = errno;
if (ret < 0)
- unlinkat (lo->workdir_fd, wd_tmp_file_name, AT_REMOVEDIR);
+ unlinkat (lo->workdir_fd, wd_tmp_file_name, AT_REMOVEDIR);
errno = saved_errno;
return ret;
@@ -3002,7 +3000,7 @@ create_node_directory (struct ovl_data *lo, struct ovl_node *src)
if (src->layer == get_upper_layer (lo))
return 0;
- ret = sfd = src->layer->ds->openat (src->layer, src->path, O_RDONLY|O_NONBLOCK, 0755);
+ ret = sfd = src->layer->ds->openat (src->layer, src->path, O_RDONLY | O_NONBLOCK, 0755);
if (ret < 0)
return ret;
@@ -3050,8 +3048,7 @@ copy_fd_to_fd (int sfd, int dfd, char *buf, size_t buf_size)
return ret;
nread -= ret;
written += ret;
- }
- while (nread);
+ } while (nread);
}
return 0;
}
@@ -3127,11 +3124,11 @@ copyup (struct ovl_data *lo, struct ovl_node *node)
goto success;
}
- ret = sfd = node->layer->ds->openat (node->layer, node->path, O_RDONLY|O_NONBLOCK, 0);
+ ret = sfd = node->layer->ds->openat (node->layer, node->path, O_RDONLY | O_NONBLOCK, 0);
if (sfd < 0)
goto exit;
- ret = dfd = TEMP_FAILURE_RETRY (safe_openat (lo->workdir_fd, wd_tmp_file_name, O_CREAT|O_WRONLY, mode));
+ ret = dfd = TEMP_FAILURE_RETRY (safe_openat (lo->workdir_fd, wd_tmp_file_name, O_CREAT | O_WRONLY, mode));
if (dfd < 0)
goto exit;
@@ -3175,7 +3172,7 @@ copyup (struct ovl_data *lo, struct ovl_node *node)
break;
}
copied += n;
- }
+ }
data_copied = true;
}
#endif
@@ -3216,12 +3213,12 @@ copyup (struct ovl_data *lo, struct ovl_node *node)
goto exit;
}
- success:
+success:
ret = 0;
node->layer = get_upper_layer (lo);
- exit:
+exit:
saved_errno = errno;
if (ret < 0)
unlinkat (lo->workdir_fd, wd_tmp_file_name, 0);
@@ -3434,7 +3431,7 @@ ovl_unlink (fuse_req_t req, fuse_ino_t parent, const char *name)
cleanup_lock int l = enter_big_lock ();
if (UNLIKELY (ovl_debug (req)))
fprintf (stderr, "ovl_unlink(parent=%" PRIu64 ", name=%s)\n",
- parent, name);
+ parent, name);
do_rm (req, parent, name, false);
}
@@ -3444,7 +3441,7 @@ ovl_rmdir (fuse_req_t req, fuse_ino_t parent, const char *name)
cleanup_lock int l = enter_big_lock ();
if (UNLIKELY (ovl_debug (req)))
fprintf (stderr, "ovl_rmdir(parent=%" PRIu64 ", name=%s)\n",
- parent, name);
+ parent, name);
do_rm (req, parent, name, true);
}
@@ -3468,7 +3465,7 @@ direct_setxattr (struct ovl_layer *l, const char *path, const char *name, const
static void
ovl_setxattr (fuse_req_t req, fuse_ino_t ino, const char *name,
- const char *value, size_t size, int flags)
+ const char *value, size_t size, int flags)
{
cleanup_lock int l = enter_big_lock ();
struct ovl_data *lo = ovl_data (req);
@@ -3485,7 +3482,7 @@ ovl_setxattr (fuse_req_t req, fuse_ino_t ino, const char *name,
return;
}
- if (has_prefix (name, PRIVILEGED_XATTR_PREFIX) || has_prefix (name, XATTR_PREFIX) || has_prefix (name, XATTR_CONTAINERS_PREFIX))
+ if (has_prefix (name, PRIVILEGED_XATTR_PREFIX) || has_prefix (name, XATTR_PREFIX) || has_prefix (name, XATTR_CONTAINERS_PREFIX))
{
fuse_reply_err (req, EPERM);
return;
@@ -3657,7 +3654,7 @@ ovl_do_open (fuse_req_t req, fuse_ino_t parent, const char *name, int flags, mod
if (name && has_prefix (name, ".wh."))
{
errno = EINVAL;
- return - 1;
+ return -1;
}
n = do_lookup_file (lo, parent, name);
@@ -3668,7 +3665,7 @@ ovl_do_open (fuse_req_t req, fuse_ino_t parent, const char *name, int flags, mod
return openat (n->hidden_dirfd, n->path, flags, mode);
}
- if (n && !n->whiteout && (flags & O_CREAT))
+ if (n && ! n->whiteout && (flags & O_CREAT))
{
errno = EEXIST;
return -1;
@@ -3679,7 +3676,7 @@ ovl_do_open (fuse_req_t req, fuse_ino_t parent, const char *name, int flags, mod
is_whiteout = true;
}
- if (!n)
+ if (! n)
{
int ret;
struct ovl_node *p;
@@ -3704,7 +3701,7 @@ ovl_do_open (fuse_req_t req, fuse_ino_t parent, const char *name, int flags, mod
if (p == NULL)
return -1;
- if (p->loaded && !is_whiteout)
+ if (p->loaded && ! is_whiteout)
need_delete_whiteout = false;
sprintf (wd_tmp_file_name, "%lu", get_next_wd_counter ());
@@ -3739,7 +3736,7 @@ ovl_do_open (fuse_req_t req, fuse_ino_t parent, const char *name, int flags, mod
errno = ENOMEM;
return -1;
}
- if (!is_whiteout)
+ if (! is_whiteout)
n->last_layer = get_upper_layer (lo);
n = insert_node (p, n, true);
@@ -3782,12 +3779,13 @@ ovl_do_open (fuse_req_t req, fuse_ino_t parent, const char *name, int flags, mod
static void
ovl_read (fuse_req_t req, fuse_ino_t ino, size_t size,
- off_t offset, struct fuse_file_info *fi)
+ off_t offset, struct fuse_file_info *fi)
{
struct fuse_bufvec buf = FUSE_BUFVEC_INIT (size);
if (UNLIKELY (ovl_debug (req)))
fprintf (stderr, "ovl_read(ino=%" PRIu64 ", size=%zd, "
- "off=%lu)\n", ino, size, (unsigned long) offset);
+ "off=%lu)\n",
+ ino, size, (unsigned long) offset);
buf.buf[0].flags = FUSE_BUF_IS_FD | FUSE_BUF_FD_SEEK | FUSE_BUF_FD_RETRY;
buf.buf[0].fd = fi->fh;
buf.buf[0].pos = offset;
@@ -3796,8 +3794,8 @@ ovl_read (fuse_req_t req, fuse_ino_t ino, size_t size,
static void
ovl_write_buf (fuse_req_t req, fuse_ino_t ino,
- struct fuse_bufvec *in_buf, off_t off,
- struct fuse_file_info *fi)
+ struct fuse_bufvec *in_buf, off_t off,
+ struct fuse_file_info *fi)
{
struct ovl_data *lo = ovl_data (req);
ssize_t res;
@@ -3811,7 +3809,7 @@ ovl_write_buf (fuse_req_t req, fuse_ino_t ino,
if (UNLIKELY (ovl_debug (req)))
fprintf (stderr, "ovl_write_buf(ino=%" PRIu64 ", size=%zd, off=%lu, fd=%d)\n",
- ino, out_buf.buf[0].size, (unsigned long) off, (int) fi->fh);
+ ino, out_buf.buf[0].size, (unsigned long) off, (int) fi->fh);
inode = lookup_inode (lo, ino);
@@ -3820,7 +3818,7 @@ ovl_write_buf (fuse_req_t req, fuse_ino_t ino,
saved_errno = errno;
/* if it is a writepage request, make sure to restore the setuid bit. */
- if (fi->writepage && (inode->mode & (S_ISUID|S_ISGID)))
+ if (fi->writepage && (inode->mode & (S_ISUID | S_ISGID)))
{
if (do_fchmod (lo, fi->fh, inode->mode) < 0)
{
@@ -3906,7 +3904,7 @@ get_fs_namemax (struct ovl_data *lo)
static void
ovl_create (fuse_req_t req, fuse_ino_t parent, const char *name,
- mode_t mode, struct fuse_file_info *fi)
+ mode_t mode, struct fuse_file_info *fi)
{
cleanup_lock int l = enter_big_lock ();
cleanup_close int fd = -1;
@@ -3917,7 +3915,7 @@ ovl_create (fuse_req_t req, fuse_ino_t parent, const char *name,
if (UNLIKELY (ovl_debug (req)))
fprintf (stderr, "ovl_create(parent=%" PRIu64 ", name=%s)\n",
- parent, name);
+ parent, name);
if (strlen (name) > get_fs_namemax (lo))
{
@@ -3949,7 +3947,7 @@ ovl_create (fuse_req_t req, fuse_ino_t parent, const char *name,
}
fi->fh = fd;
- fd = -1; /* Do not clean it up. */
+ fd = -1; /* Do not clean it up. */
node->ino->lookups++;
fuse_reply_create (req, &e, fi);
@@ -3974,7 +3972,7 @@ ovl_open (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
fi->fh = fd;
if (get_timeout (lo) > 0)
fi->keep_cache = 1;
- fd = -1; /* Do not clean it up. */
+ fd = -1; /* Do not clean it up. */
fuse_reply_open (req, fi);
}
@@ -4050,7 +4048,7 @@ ovl_setattr (fuse_req_t req, fuse_ino_t ino, struct stat *attr, int to_set, stru
gid = get_gid (lo, attr->st_gid);
if (fi != NULL)
- fd = fi->fh; // use existing fd if fuse_file_info is available
+ fd = fi->fh; // use existing fd if fuse_file_info is available
else
{
mode_t mode = node->ino->mode;
@@ -4072,13 +4070,13 @@ ovl_setattr (fuse_req_t req, fuse_ino_t ino, struct stat *attr, int to_set, stru
switch (mode & S_IFMT)
{
case S_IFREG:
- cleaned_up_fd = fd = TEMP_FAILURE_RETRY (safe_openat (dirfd, node->path, O_NOFOLLOW|O_NONBLOCK|(to_set & FUSE_SET_ATTR_SIZE ? O_WRONLY : 0), 0));
+ cleaned_up_fd = fd = TEMP_FAILURE_RETRY (safe_openat (dirfd, node->path, O_NOFOLLOW | O_NONBLOCK | (to_set & FUSE_SET_ATTR_SIZE ? O_WRONLY : 0), 0));
if (fd < 0)
strconcat3 (path, PATH_MAX, get_upper_layer (lo)->path, "/", node->path);
break;
case S_IFDIR:
- cleaned_up_fd = fd = TEMP_FAILURE_RETRY (safe_openat (dirfd, node->path, O_NOFOLLOW|O_NONBLOCK, 0));
+ cleaned_up_fd = fd = TEMP_FAILURE_RETRY (safe_openat (dirfd, node->path, O_NOFOLLOW | O_NONBLOCK, 0));
if (fd < 0)
{
if (errno != ELOOP)
@@ -4087,7 +4085,7 @@ ovl_setattr (fuse_req_t req, fuse_ino_t ino, struct stat *attr, int to_set, stru
break;
case S_IFLNK:
- cleaned_up_fd = TEMP_FAILURE_RETRY (safe_openat (dirfd, node->path, O_PATH|O_NOFOLLOW|O_NONBLOCK, 0));
+ cleaned_up_fd = TEMP_FAILURE_RETRY (safe_openat (dirfd, node->path, O_PATH | O_NOFOLLOW | O_NONBLOCK, 0));
if (cleaned_up_fd < 0)
{
fuse_reply_err (req, errno);
@@ -4231,7 +4229,7 @@ ovl_link (fuse_req_t req, fuse_ino_t ino, fuse_ino_t newparent, const char *newn
}
destnode = do_lookup_file (lo, newparent, newname);
- if (destnode && !destnode->whiteout)
+ if (destnode && ! destnode->whiteout)
{
fuse_reply_err (req, EEXIST);
return;
@@ -4272,7 +4270,7 @@ ovl_link (fuse_req_t req, fuse_ino_t ino, fuse_ino_t newparent, const char *newn
fuse_reply_err (req, ENOMEM);
return;
}
- if (destnode && !destnode->whiteout)
+ if (destnode && ! destnode->whiteout)
node->last_layer = get_upper_layer (lo);
node = insert_node (newparentnode, node, true);
@@ -4369,7 +4367,7 @@ ovl_symlink (fuse_req_t req, const char *link, fuse_ino_t parent, const char *na
}
node = do_lookup_file (lo, parent, name);
- if (node != NULL && !node->whiteout)
+ if (node != NULL && ! node->whiteout)
{
fuse_reply_err (req, EEXIST);
return;
@@ -4507,7 +4505,6 @@ ovl_rename_exchange (fuse_req_t req, fuse_ino_t parent, const char *name,
if (destnode == NULL)
goto error;
-
ret = direct_renameat2 (srcfd, name, destfd, newname, flags);
if (ret < 0)
goto error;
@@ -4546,10 +4543,10 @@ ovl_rename_exchange (fuse_req_t req, fuse_ino_t parent, const char *name,
ret = 0;
goto cleanup;
- error:
+error:
ret = -1;
- cleanup:
+cleanup:
fuse_reply_err (req, ret == 0 ? 0 : errno);
}
@@ -4626,7 +4623,7 @@ ovl_rename_direct (fuse_req_t req, fuse_ino_t parent, const char *name,
/* If NOREPLACE flag is given, check if we should throw an error now.
If not, just remove the flag as it might cause problems with replacing whiteouts later. */
- if (flags & RENAME_NOREPLACE && destnode && !destnode->whiteout)
+ if (flags & RENAME_NOREPLACE && destnode && ! destnode->whiteout)
{
errno = EEXIST;
goto error;
@@ -4639,12 +4636,12 @@ ovl_rename_direct (fuse_req_t req, fuse_ino_t parent, const char *name,
size_t destnode_whiteouts = 0;
errno = EINVAL;
- if (!destnode->whiteout && destnode->tmp_ino == node->tmp_ino && destnode->tmp_dev == node->tmp_dev)
+ if (! destnode->whiteout && destnode->tmp_ino == node->tmp_ino && destnode->tmp_dev == node->tmp_dev)
goto error;
destnode_is_whiteout = destnode->whiteout;
- if (!destnode->whiteout && node_dirp (destnode))
+ if (! destnode->whiteout && node_dirp (destnode))
{
destnode = reload_dir (lo, destnode);
if (destnode == NULL)
@@ -4670,7 +4667,7 @@ ovl_rename_direct (fuse_req_t req, fuse_ino_t parent, const char *name,
destnode = NULL;
}
- if (destnode && !destnode_is_whiteout)
+ if (destnode && ! destnode_is_whiteout)
{
/* If the node is still accessible then be sure we
can write to it. Fix it to be done when a write is
@@ -4706,7 +4703,7 @@ ovl_rename_direct (fuse_req_t req, fuse_ino_t parent, const char *name,
If destination is a whiteout, we can EXCHANGE source and destination and reuse the old whiteout.
If not, we can try to atomically create one with the WHITEOUT flag. */
if (destnode_is_whiteout)
- ret = direct_renameat2 (srcfd, name, destfd, newname, flags|RENAME_EXCHANGE);
+ ret = direct_renameat2 (srcfd, name, destfd, newname, flags | RENAME_EXCHANGE);
else
{
if (! can_mknod)
@@ -4715,7 +4712,7 @@ ovl_rename_direct (fuse_req_t req, fuse_ino_t parent, const char *name,
errno = EPERM;
}
else
- ret = direct_renameat2 (srcfd, name, destfd, newname, flags|RENAME_WHITEOUT);
+ ret = direct_renameat2 (srcfd, name, destfd, newname, flags | RENAME_WHITEOUT);
}
/* If atomic whiteout creation failed, fall back to separate rename and whiteout creation. */
@@ -4762,15 +4759,15 @@ ovl_rename_direct (fuse_req_t req, fuse_ino_t parent, const char *name,
fuse_reply_err (req, 0);
return;
- error:
+error:
ret = -1;
fuse_reply_err (req, errno);
}
static void
ovl_rename (fuse_req_t req, fuse_ino_t parent, const char *name,
- fuse_ino_t newparent, const char *newname,
- unsigned int flags)
+ fuse_ino_t newparent, const char *newname,
+ unsigned int flags)
{
struct ovl_node *p;
cleanup_lock int l = enter_big_lock ();
@@ -4898,7 +4895,7 @@ hide_all (struct ovl_data *lo, struct ovl_node *node)
if (ret < 0)
{
- free(nodes);
+ free (nodes);
return ret;
}
}
@@ -4922,7 +4919,7 @@ ovl_mknod (fuse_req_t req, fuse_ino_t parent, const char *name, mode_t mode, dev
if (UNLIKELY (ovl_debug (req)))
fprintf (stderr, "ovl_mknod(ino=%" PRIu64 ", name=%s, mode=%d, rdev=%lu)\n",
- parent, name, mode, rdev);
+ parent, name, mode, rdev);
if (strlen (name) > get_fs_namemax (lo))
{
@@ -4936,7 +4933,7 @@ ovl_mknod (fuse_req_t req, fuse_ino_t parent, const char *name, mode_t mode, dev
mode |= 0755;
node = do_lookup_file (lo, parent, name);
- if (node != NULL && !node->whiteout)
+ if (node != NULL && ! node->whiteout)
{
fuse_reply_err (req, EEXIST);
return;
@@ -5053,7 +5050,7 @@ ovl_mkdir (fuse_req_t req, fuse_ino_t parent, const char *name, mode_t mode)
if (UNLIKELY (ovl_debug (req)))
fprintf (stderr, "ovl_mkdir(ino=%" PRIu64 ", name=%s, mode=%d)\n",
- parent, name, mode);
+ parent, name, mode);
if (strlen (name) > get_fs_namemax (lo))
{
@@ -5064,7 +5061,7 @@ ovl_mkdir (fuse_req_t req, fuse_ino_t parent, const char *name, mode_t mode)
mode |= 0755;
node = do_lookup_file (lo, parent, name);
- if (node != NULL && !node->whiteout)
+ if (node != NULL && ! node->whiteout)
{
fuse_reply_err (req, EEXIST);
return;
@@ -5172,9 +5169,9 @@ direct_fsync (struct ovl_layer *l, int fd, const char *path, int datasync)
if (fd < 0)
{
- cfd = safe_openat (l->fd, path, O_NOFOLLOW|O_DIRECTORY, 0);
+ cfd = safe_openat (l->fd, path, O_NOFOLLOW | O_DIRECTORY, 0);
if (cfd < 0)
- return cfd;
+ return cfd;
fd = cfd;
}
@@ -5190,7 +5187,7 @@ do_fsync (fuse_req_t req, fuse_ino_t ino, int datasync, int fd)
struct ovl_data *lo = ovl_data (req);
cleanup_lock int l = 0;
- if (!lo->fsync)
+ if (! lo->fsync)
{
fuse_reply_err (req, ENOSYS);
return;
@@ -5292,17 +5289,17 @@ ovl_ioctl (fuse_req_t req, fuse_ino_t ino, int cmd, void *arg,
return;
}
if (in_bufsz >= sizeof (r))
- r = *(unsigned long *) in_buf;
+ r = *(unsigned long *) in_buf;
break;
default:
- fuse_reply_err (req, ENOSYS);
- return;
+ fuse_reply_err (req, ENOSYS);
+ return;
}
if (fd < 0)
{
- fd = cleaned_fd = node->layer->ds->openat (node->layer, node->path, O_RDONLY|O_NONBLOCK, 0755);
+ fd = cleaned_fd = node->layer->ds->openat (node->layer, node->path, O_RDONLY | O_NONBLOCK, 0755);
if (fd < 0)
{
fuse_reply_err (req, errno);
@@ -5353,7 +5350,7 @@ ovl_fallocate (fuse_req_t req, fuse_ino_t ino, int mode, off_t offset, off_t len
}
dirfd = node_dirfd (node);
- fd = safe_openat (dirfd, node->path, O_NONBLOCK|O_NOFOLLOW|O_WRONLY, 0);
+ fd = safe_openat (dirfd, node->path, O_NONBLOCK | O_NOFOLLOW | O_WRONLY, 0);
if (fd < 0)
{
fuse_reply_err (req, errno);
@@ -5412,16 +5409,16 @@ ovl_copy_file_range (fuse_req_t req, fuse_ino_t ino_in, off_t off_in, struct fus
}
if (node->hidden)
- fd = openat (node->hidden_dirfd, node->path, O_NONBLOCK|O_NOFOLLOW|O_RDONLY, 0755);
+ fd = openat (node->hidden_dirfd, node->path, O_NONBLOCK | O_NOFOLLOW | O_RDONLY, 0755);
else
- fd = node->layer->ds->openat (node->layer, node->path, O_NONBLOCK|O_NOFOLLOW|O_RDONLY, 0755);
+ fd = node->layer->ds->openat (node->layer, node->path, O_NONBLOCK | O_NOFOLLOW | O_RDONLY, 0755);
if (fd < 0)
{
fuse_reply_err (req, errno);
return;
}
- fd_dest = TEMP_FAILURE_RETRY (safe_openat (node_dirfd (dnode), dnode->path, O_NONBLOCK|O_NOFOLLOW|O_WRONLY, 0));
+ fd_dest = TEMP_FAILURE_RETRY (safe_openat (node_dirfd (dnode), dnode->path, O_NONBLOCK | O_NOFOLLOW | O_WRONLY, 0));
if (fd_dest < 0)
{
fuse_reply_err (req, errno);
@@ -5438,45 +5435,44 @@ ovl_copy_file_range (fuse_req_t req, fuse_ino_t ino_in, off_t off_in, struct fus
}
#endif
-static struct fuse_lowlevel_ops ovl_oper =
- {
- .statfs = ovl_statfs,
- .access = ovl_access,
- .getxattr = ovl_getxattr,
- .removexattr = ovl_removexattr,
- .setxattr = ovl_setxattr,
- .listxattr = ovl_listxattr,
- .init = ovl_init,
- .lookup = ovl_lookup,
- .forget = ovl_forget,
- .forget_multi = ovl_forget_multi,
- .getattr = ovl_getattr,
- .readlink = ovl_readlink,
- .opendir = ovl_opendir,
- .readdir = ovl_readdir,
- .readdirplus = ovl_readdirplus,
- .releasedir = ovl_releasedir,
- .create = ovl_create,
- .open = ovl_open,
- .release = ovl_release,
- .read = ovl_read,
- .write_buf = ovl_write_buf,
- .unlink = ovl_unlink,
- .rmdir = ovl_rmdir,
- .setattr = ovl_setattr,
- .symlink = ovl_symlink,
- .rename = ovl_rename,
- .mkdir = ovl_mkdir,
- .mknod = ovl_mknod,
- .link = ovl_link,
- .fsync = ovl_fsync,
- .fsyncdir = ovl_fsyncdir,
- .ioctl = ovl_ioctl,
- .fallocate = ovl_fallocate,
+static struct fuse_lowlevel_ops ovl_oper = {
+ .statfs = ovl_statfs,
+ .access = ovl_access,
+ .getxattr = ovl_getxattr,
+ .removexattr = ovl_removexattr,
+ .setxattr = ovl_setxattr,
+ .listxattr = ovl_listxattr,
+ .init = ovl_init,
+ .lookup = ovl_lookup,
+ .forget = ovl_forget,
+ .forget_multi = ovl_forget_multi,
+ .getattr = ovl_getattr,
+ .readlink = ovl_readlink,
+ .opendir = ovl_opendir,
+ .readdir = ovl_readdir,
+ .readdirplus = ovl_readdirplus,
+ .releasedir = ovl_releasedir,
+ .create = ovl_create,
+ .open = ovl_open,
+ .release = ovl_release,
+ .read = ovl_read,
+ .write_buf = ovl_write_buf,
+ .unlink = ovl_unlink,
+ .rmdir = ovl_rmdir,
+ .setattr = ovl_setattr,
+ .symlink = ovl_symlink,
+ .rename = ovl_rename,
+ .mkdir = ovl_mkdir,
+ .mknod = ovl_mknod,
+ .link = ovl_link,
+ .fsync = ovl_fsync,
+ .fsyncdir = ovl_fsyncdir,
+ .ioctl = ovl_ioctl,
+ .fallocate = ovl_fallocate,
#if HAVE_COPY_FILE_RANGE && HAVE_FUSE_COPY_FILE_RANGE
- .copy_file_range = ovl_copy_file_range,
+ .copy_file_range = ovl_copy_file_range,
#endif
- };
+};
static int
fuse_opt_proc (void *data, const char *arg, int key, struct fuse_args *outargs)
@@ -5493,8 +5489,7 @@ fuse_opt_proc (void *data, const char *arg, int key, struct fuse_args *outargs)
return 1;
if (strcmp (arg, "-V") == 0)
return 1;
- if ((strcmp (arg, "--debug") == 0) || (strcmp (arg, "-d") == 0) ||
- (strcmp (arg, "debug") == 0))
+ if ((strcmp (arg, "--debug") == 0) || (strcmp (arg, "-d") == 0) || (strcmp (arg, "debug") == 0))
{
ovl_data->debug = 1;
return 1;
@@ -5568,7 +5563,7 @@ get_new_args (int *argc, char **argv)
error (EXIT_FAILURE, 0, "error allocating memory");
newargv[0] = argv[0];
- if (geteuid() == 0)
+ if (geteuid () == 0)
newargv[1] = "-odefault_permissions,allow_other,suid,noatime,lazytime";
else
newargv[1] = "-odefault_permissions,noatime";
@@ -5634,30 +5629,31 @@ main (int argc, char *argv[])
struct fuse_session *se;
struct fuse_cmdline_opts opts;
char **newargv = get_new_args (&argc, argv);
- struct ovl_data lo = {.debug = 0,
- .uid_mappings = NULL,
- .gid_mappings = NULL,
- .uid_str = NULL,
- .gid_str = NULL,
- .root = NULL,
- .lowerdir = NULL,
- .redirect_dir = NULL,
- .mountpoint = NULL,
- .fsync = 1,
- .noacl = 0,
- .squash_to_uid = -1,
- .squash_to_gid = -1,
- .static_nlink = 0,
- .xattr_permissions = 0,
- .euid = geteuid (),
- .timeout = 1000000000.0,
- .timeout_str = NULL,
- .writeback = 1,
- .volatile_mode = 0,
+ struct ovl_data lo = {
+ .debug = 0,
+ .uid_mappings = NULL,
+ .gid_mappings = NULL,
+ .uid_str = NULL,
+ .gid_str = NULL,
+ .root = NULL,
+ .lowerdir = NULL,
+ .redirect_dir = NULL,
+ .mountpoint = NULL,
+ .fsync = 1,
+ .noacl = 0,
+ .squash_to_uid = -1,
+ .squash_to_gid = -1,
+ .static_nlink = 0,
+ .xattr_permissions = 0,
+ .euid = geteuid (),
+ .timeout = 1000000000.0,
+ .timeout_str = NULL,
+ .writeback = 1,
+ .volatile_mode = 0,
};
struct fuse_loop_config fuse_conf = {
- .clone_fd = 1,
- .max_idle_threads = 10,
+ .clone_fd = 1,
+ .max_idle_threads = 10,
};
int ret = -1;
cleanup_layer struct ovl_layer *layers = NULL;
@@ -5723,8 +5719,8 @@ main (int argc, char *argv[])
if (lo.debug)
{
- fprintf (stderr, "uid=%s\n", lo.uid_str ? : "unchanged");
- fprintf (stderr, "gid=%s\n", lo.gid_str ? : "unchanged");
+ fprintf (stderr, "uid=%s\n", lo.uid_str ?: "unchanged");
+ fprintf (stderr, "gid=%s\n", lo.gid_str ?: "unchanged");
fprintf (stderr, "upperdir=%s\n", lo.upperdir ? lo.upperdir : "NOT USED");
fprintf (stderr, "workdir=%s\n", lo.workdir ? lo.workdir : "NOT USED");
fprintf (stderr, "lowerdir=%s\n", lo.lowerdir);
@@ -5765,10 +5761,10 @@ main (int argc, char *argv[])
lo.layers = layers;
- for (tmp_layer = layers; !lo.noacl && tmp_layer; tmp_layer = tmp_layer->next)
+ for (tmp_layer = layers; ! lo.noacl && tmp_layer; tmp_layer = tmp_layer->next)
{
if (! tmp_layer->ds->support_acls (tmp_layer))
- lo.noacl = 1;
+ lo.noacl = 1;
}
if (lo.upperdir)
@@ -5832,8 +5828,8 @@ main (int argc, char *argv[])
if (path == NULL)
goto err_out1;
mkdir (path, 0700);
- path = realloc(path, strlen(path)+strlen("/work")+1);
- if (!path)
+ path = realloc (path, strlen (path) + strlen ("/work") + 1);
+ if (! path)
error (EXIT_FAILURE, errno, "allocating workdir path");
strcat (path, "/work");
mkdir (path, 0700);
@@ -5853,7 +5849,7 @@ main (int argc, char *argv[])
}
umask (0);
- disable_locking = !lo.threaded;
+ disable_locking = ! lo.threaded;
se = fuse_session_new (&args, &ovl_oper, sizeof (ovl_oper), &lo);
lo.se = se;
diff --git a/plugin-manager.c b/plugin-manager.c
index 449976a..4832136 100644
--- a/plugin-manager.c
+++ b/plugin-manager.c
@@ -52,9 +52,9 @@ plugin_load_one (struct ovl_plugin_context *context, const char *path)
plugin_name name;
struct ovl_plugin *p;
plugin_version version;
- void *handle = dlopen (path, RTLD_NOW|RTLD_LOCAL);
+ void *handle = dlopen (path, RTLD_NOW | RTLD_LOCAL);
if (! handle)
- error (EXIT_FAILURE, 0, "cannot load plugin %s: %s", path, dlerror());
+ error (EXIT_FAILURE, 0, "cannot load plugin %s: %s", path, dlerror ());
p = calloc (1, sizeof (*p));
if (p == NULL)
diff --git a/plugin-manager.h b/plugin-manager.h
index ff6a365..81d6a05 100644
--- a/plugin-manager.h
+++ b/plugin-manager.h
@@ -17,10 +17,10 @@
*/
#ifndef PLUGIN_MANAGER_H
-# define PLUGIN_MANAGER_H
-# include
+#define PLUGIN_MANAGER_H
+#include
-# include
+#include
struct ovl_plugin_context
{
@@ -37,8 +37,7 @@ struct ovl_plugin_context *load_plugins (const char *plugins);
/* taken from glibc unistd.h and fixes musl */
#ifndef TEMP_FAILURE_RETRY
#define TEMP_FAILURE_RETRY(expression) \
- (__extension__ \
- ({ long int __result; \
+ (__extension__ ({ long int __result; \
do __result = (long int) (expression); \
while (__result == -1L && errno == EINTR); \
__result; }))
diff --git a/plugin.h b/plugin.h
index 32bca7c..c63f2de 100644
--- a/plugin.h
+++ b/plugin.h
@@ -17,16 +17,16 @@
*/
#ifndef PLUGIN_H
-# define PLUGIN_H
-# include
+#define PLUGIN_H
+#include
-# include
-# include
+#include
+#include
-typedef struct data_source *(*plugin_load_data_source)(const char *opaque, const char *path);
-typedef int (*plugin_release)();
-typedef const char *(*plugin_name)();
-typedef int (*plugin_version)();
+typedef struct data_source *(*plugin_load_data_source) (const char *opaque, const char *path);
+typedef int (*plugin_release) ();
+typedef const char *(*plugin_name) ();
+typedef int (*plugin_version) ();
struct ovl_plugin
{
diff --git a/tests/suid-test.c b/tests/suid-test.c
index 8ecd0de..b6b8fff 100644
--- a/tests/suid-test.c
+++ b/tests/suid-test.c
@@ -14,13 +14,13 @@ main ()
unlink ("suid");
unlink ("nosuid");
- fd = open ("suid", O_WRONLY|O_CREAT|O_EXCL);
+ fd = open ("suid", O_WRONLY | O_CREAT | O_EXCL);
write (fd, "1", 1);
fchown (fd, 0, 0);
fchmod (fd, S_ISUID | 0755);
close (fd);
- fd = open ("nosuid", O_WRONLY|O_CREAT|O_EXCL);
+ fd = open ("nosuid", O_WRONLY | O_CREAT | O_EXCL);
write (fd, "1", 1);
fchown (fd, 0, 0);
fchmod (fd, S_ISUID | 0755);
diff --git a/utils.c b/utils.c
index 8c0749a..2e014ac 100644
--- a/utils.c
+++ b/utils.c
@@ -32,48 +32,42 @@
#include
#ifndef TEMP_FAILURE_RETRY
-#define TEMP_FAILURE_RETRY(expression) \
- (__extension__ \
- ({ long int __result; \
+# define TEMP_FAILURE_RETRY(expression) \
+ (__extension__ ({ long int __result; \
do __result = (long int) (expression); \
while (__result == -1L && errno == EINTR); \
__result; }))
#endif
#ifndef RESOLVE_IN_ROOT
-# define RESOLVE_IN_ROOT 0x10
+# define RESOLVE_IN_ROOT 0x10
#endif
#ifndef __NR_openat2
-# define __NR_openat2 437
+# define __NR_openat2 437
#endif
/* uClibc and uClibc-ng don't provide O_TMPFILE */
#ifndef O_TMPFILE
-# define O_TMPFILE (020000000 | O_DIRECTORY)
+# define O_TMPFILE (020000000 | O_DIRECTORY)
#endif
/* List of all valid flags for the open/openat flags argument: */
#define VALID_OPEN_FLAGS \
- (O_RDONLY | O_WRONLY | O_RDWR | O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC | \
- O_APPEND | O_NDELAY | O_NONBLOCK | O_NDELAY | O_SYNC | O_DSYNC | \
- FASYNC | O_DIRECT | O_LARGEFILE | O_DIRECTORY | O_NOFOLLOW | \
- O_NOATIME | O_CLOEXEC | O_PATH | O_TMPFILE)
+ (O_RDONLY | O_WRONLY | O_RDWR | O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC | O_APPEND | O_NDELAY | O_NONBLOCK | O_NDELAY | O_SYNC | O_DSYNC | FASYNC | O_DIRECT | O_LARGEFILE | O_DIRECTORY | O_NOFOLLOW | O_NOATIME | O_CLOEXEC | O_PATH | O_TMPFILE)
static int
syscall_openat2 (int dirfd, const char *path, uint64_t flags, uint64_t mode, uint64_t resolve)
{
struct openat2_open_how
- {
- uint64_t flags;
- uint64_t mode;
- uint64_t resolve;
- }
- how =
- {
- .flags = flags & VALID_OPEN_FLAGS,
- .mode = (flags & O_CREAT) ? (mode & 07777) : 0,
- .resolve = resolve,
- };
+ {
+ uint64_t flags;
+ uint64_t mode;
+ uint64_t resolve;
+ } how = {
+ .flags = flags & VALID_OPEN_FLAGS,
+ .mode = (flags & O_CREAT) ? (mode & 07777) : 0,
+ .resolve = resolve,
+ };
return (int) syscall (__NR_openat2, dirfd, path, &how, sizeof (how), 0);
}
@@ -97,18 +91,19 @@ safe_openat (int dirfd, const char *pathname, int flags, mode_t mode)
}
return ret;
}
- fallback:
+fallback:
return openat (dirfd, pathname, flags, mode);
}
int
file_exists_at (int dirfd, const char *pathname)
{
- int ret = faccessat (dirfd, pathname, F_OK, AT_SYMLINK_NOFOLLOW|AT_EACCESS);
- if (ret < 0 && errno == EINVAL) {
- struct stat buf;
- return fstatat (dirfd, pathname, &buf, AT_SYMLINK_NOFOLLOW);
- }
+ int ret = faccessat (dirfd, pathname, F_OK, AT_SYMLINK_NOFOLLOW | AT_EACCESS);
+ if (ret < 0 && errno == EINVAL)
+ {
+ struct stat buf;
+ return fstatat (dirfd, pathname, &buf, AT_SYMLINK_NOFOLLOW);
+ }
return ret;
}
@@ -219,7 +214,7 @@ open_fd_or_get_path (struct ovl_layer *l, const char *path, char *out, int *fd,
{
out[0] = '\0';
- *fd = l->ds->openat (l, path, O_NONBLOCK|O_NOFOLLOW|flags, 0);
+ *fd = l->ds->openat (l, path, O_NONBLOCK | O_NOFOLLOW | flags, 0);
if (*fd < 0 && (errno == ELOOP || errno == EISDIR || errno == ENXIO))
{
strconcat3 (out, PATH_MAX, l->path, "/", path);
diff --git a/utils.h b/utils.h
index dbbd059..a9176f9 100644
--- a/utils.h
+++ b/utils.h
@@ -16,25 +16,25 @@
along with this program. If not, see .
*/
#ifndef UTILS_H
-# define UTILS_H
+#define UTILS_H
#ifndef _GNU_SOURCE
-# define _GNU_SOURCE
+# define _GNU_SOURCE
#endif
-# include
-# include
-# include
-# include
-# include
-# include
-# include
-# include
-# include "fuse-overlayfs.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "fuse-overlayfs.h"
-# define XATTR_OVERRIDE_STAT "user.fuseoverlayfs.override_stat"
-# define XATTR_PRIVILEGED_OVERRIDE_STAT "security.fuseoverlayfs.override_stat"
-# define XATTR_OVERRIDE_CONTAINERS_STAT "user.containers.override_stat"
+#define XATTR_OVERRIDE_STAT "user.fuseoverlayfs.override_stat"
+#define XATTR_PRIVILEGED_OVERRIDE_STAT "security.fuseoverlayfs.override_stat"
+#define XATTR_OVERRIDE_CONTAINERS_STAT "user.containers.override_stat"
void cleanup_freep (void *p);
void cleanup_filep (FILE **f);
@@ -46,17 +46,17 @@ int file_exists_at (int dirfd, const char *pathname);
int strconcat3 (char *dest, size_t size, const char *s1, const char *s2, const char *s3);
int open_fd_or_get_path (struct ovl_layer *l, const char *path, char *out, int *fd, int flags);
-# define cleanup_file __attribute__((cleanup (cleanup_filep)))
-# define cleanup_free __attribute__((cleanup (cleanup_freep)))
-# define cleanup_close __attribute__((cleanup (cleanup_closep)))
-# define cleanup_dir __attribute__((cleanup (cleanup_dirp)))
+#define cleanup_file __attribute__ ((cleanup (cleanup_filep)))
+#define cleanup_free __attribute__ ((cleanup (cleanup_freep)))
+#define cleanup_close __attribute__ ((cleanup (cleanup_closep)))
+#define cleanup_dir __attribute__ ((cleanup (cleanup_dirp)))
-# define LIKELY(x) __builtin_expect((x),1)
-# define UNLIKELY(x) __builtin_expect((x),0)
+#define LIKELY(x) __builtin_expect ((x), 1)
+#define UNLIKELY(x) __builtin_expect ((x), 0)
-# ifdef HAVE_STATX
+#ifdef HAVE_STATX
void statx_to_stat (struct statx *stx, struct stat *st);
-# endif
+#endif
int safe_openat (int dirfd, const char *pathname, int flags, mode_t mode);