mirror of
https://github.com/containers/fuse-overlayfs.git
synced 2025-09-10 07:44:54 -04:00
code: add clang-format
add a clang-format definition file and apply it to the code. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
ff6b14d0a8
commit
ba472b58bc
117
.clang-format
Normal file
117
.clang-format
Normal file
@ -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
|
||||||
|
...
|
@ -36,3 +36,6 @@ srpm: dist-gzip fuse-overlayfs.spec
|
|||||||
echo $(VERSION)
|
echo $(VERSION)
|
||||||
$(MAKE) -C $(WD) dist-xz
|
$(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
|
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
|
||||||
|
4
direct.c
4
direct.c
@ -215,9 +215,7 @@ direct_support_acls (struct ovl_layer *l)
|
|||||||
|| errno != ENOTSUP;
|
|| errno != ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct data_source direct_access_ds = {
|
||||||
struct data_source direct_access_ds =
|
|
||||||
{
|
|
||||||
.num_of_layers = direct_num_of_layers,
|
.num_of_layers = direct_num_of_layers,
|
||||||
.load_data_source = direct_load_data_source,
|
.load_data_source = direct_load_data_source,
|
||||||
.cleanup = direct_cleanup,
|
.cleanup = direct_cleanup,
|
||||||
|
@ -24,7 +24,9 @@
|
|||||||
#ifdef HAVE_ERROR_H
|
#ifdef HAVE_ERROR_H
|
||||||
# include <error.h>
|
# include <error.h>
|
||||||
#else
|
#else
|
||||||
# define error(status, errno, fmt, ...) do { \
|
# define error(status, errno, fmt, ...) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
if (errno == 0) \
|
if (errno == 0) \
|
||||||
fprintf (stderr, "fuse-overlayfs: " fmt "\n", ##__VA_ARGS__); \
|
fprintf (stderr, "fuse-overlayfs: " fmt "\n", ##__VA_ARGS__); \
|
||||||
else \
|
else \
|
||||||
|
22
main.c
22
main.c
@ -68,8 +68,7 @@
|
|||||||
|
|
||||||
#ifndef TEMP_FAILURE_RETRY
|
#ifndef TEMP_FAILURE_RETRY
|
||||||
# define TEMP_FAILURE_RETRY(expression) \
|
# define TEMP_FAILURE_RETRY(expression) \
|
||||||
(__extension__ \
|
(__extension__ ({ long int __result; \
|
||||||
({ long int __result; \
|
|
||||||
do __result = (long int) (expression); \
|
do __result = (long int) (expression); \
|
||||||
while (__result == -1L && errno == EINTR); \
|
while (__result == -1L && errno == EINTR); \
|
||||||
__result; }))
|
__result; }))
|
||||||
@ -160,8 +159,7 @@ _Static_assert (sizeof (fuse_ino_t) >= sizeof (uintptr_t),
|
|||||||
#else
|
#else
|
||||||
struct _uintptr_to_must_hold_fuse_ino_t_dummy_struct
|
struct _uintptr_to_must_hold_fuse_ino_t_dummy_struct
|
||||||
{
|
{
|
||||||
unsigned _uintptr_to_must_hold_fuse_ino_t:
|
unsigned _uintptr_to_must_hold_fuse_ino_t : ((sizeof (fuse_ino_t) >= sizeof (uintptr_t)) ? 1 : -1);
|
||||||
((sizeof (fuse_ino_t) >= sizeof (uintptr_t)) ? 1 : -1);
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -3050,8 +3048,7 @@ copy_fd_to_fd (int sfd, int dfd, char *buf, size_t buf_size)
|
|||||||
return ret;
|
return ret;
|
||||||
nread -= ret;
|
nread -= ret;
|
||||||
written += ret;
|
written += ret;
|
||||||
}
|
} while (nread);
|
||||||
while (nread);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -3787,7 +3784,8 @@ ovl_read (fuse_req_t req, fuse_ino_t ino, size_t size,
|
|||||||
struct fuse_bufvec buf = FUSE_BUFVEC_INIT (size);
|
struct fuse_bufvec buf = FUSE_BUFVEC_INIT (size);
|
||||||
if (UNLIKELY (ovl_debug (req)))
|
if (UNLIKELY (ovl_debug (req)))
|
||||||
fprintf (stderr, "ovl_read(ino=%" PRIu64 ", size=%zd, "
|
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].flags = FUSE_BUF_IS_FD | FUSE_BUF_FD_SEEK | FUSE_BUF_FD_RETRY;
|
||||||
buf.buf[0].fd = fi->fh;
|
buf.buf[0].fd = fi->fh;
|
||||||
buf.buf[0].pos = offset;
|
buf.buf[0].pos = offset;
|
||||||
@ -4507,7 +4505,6 @@ ovl_rename_exchange (fuse_req_t req, fuse_ino_t parent, const char *name,
|
|||||||
if (destnode == NULL)
|
if (destnode == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
|
||||||
ret = direct_renameat2 (srcfd, name, destfd, newname, flags);
|
ret = direct_renameat2 (srcfd, name, destfd, newname, flags);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error;
|
goto error;
|
||||||
@ -5438,8 +5435,7 @@ ovl_copy_file_range (fuse_req_t req, fuse_ino_t ino_in, off_t off_in, struct fus
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct fuse_lowlevel_ops ovl_oper =
|
static struct fuse_lowlevel_ops ovl_oper = {
|
||||||
{
|
|
||||||
.statfs = ovl_statfs,
|
.statfs = ovl_statfs,
|
||||||
.access = ovl_access,
|
.access = ovl_access,
|
||||||
.getxattr = ovl_getxattr,
|
.getxattr = ovl_getxattr,
|
||||||
@ -5493,8 +5489,7 @@ fuse_opt_proc (void *data, const char *arg, int key, struct fuse_args *outargs)
|
|||||||
return 1;
|
return 1;
|
||||||
if (strcmp (arg, "-V") == 0)
|
if (strcmp (arg, "-V") == 0)
|
||||||
return 1;
|
return 1;
|
||||||
if ((strcmp (arg, "--debug") == 0) || (strcmp (arg, "-d") == 0) ||
|
if ((strcmp (arg, "--debug") == 0) || (strcmp (arg, "-d") == 0) || (strcmp (arg, "debug") == 0))
|
||||||
(strcmp (arg, "debug") == 0))
|
|
||||||
{
|
{
|
||||||
ovl_data->debug = 1;
|
ovl_data->debug = 1;
|
||||||
return 1;
|
return 1;
|
||||||
@ -5634,7 +5629,8 @@ main (int argc, char *argv[])
|
|||||||
struct fuse_session *se;
|
struct fuse_session *se;
|
||||||
struct fuse_cmdline_opts opts;
|
struct fuse_cmdline_opts opts;
|
||||||
char **newargv = get_new_args (&argc, argv);
|
char **newargv = get_new_args (&argc, argv);
|
||||||
struct ovl_data lo = {.debug = 0,
|
struct ovl_data lo = {
|
||||||
|
.debug = 0,
|
||||||
.uid_mappings = NULL,
|
.uid_mappings = NULL,
|
||||||
.gid_mappings = NULL,
|
.gid_mappings = NULL,
|
||||||
.uid_str = NULL,
|
.uid_str = NULL,
|
||||||
|
@ -37,8 +37,7 @@ struct ovl_plugin_context *load_plugins (const char *plugins);
|
|||||||
/* taken from glibc unistd.h and fixes musl */
|
/* taken from glibc unistd.h and fixes musl */
|
||||||
#ifndef TEMP_FAILURE_RETRY
|
#ifndef TEMP_FAILURE_RETRY
|
||||||
#define TEMP_FAILURE_RETRY(expression) \
|
#define TEMP_FAILURE_RETRY(expression) \
|
||||||
(__extension__ \
|
(__extension__ ({ long int __result; \
|
||||||
({ long int __result; \
|
|
||||||
do __result = (long int) (expression); \
|
do __result = (long int) (expression); \
|
||||||
while (__result == -1L && errno == EINTR); \
|
while (__result == -1L && errno == EINTR); \
|
||||||
__result; }))
|
__result; }))
|
||||||
|
15
utils.c
15
utils.c
@ -33,8 +33,7 @@
|
|||||||
|
|
||||||
#ifndef TEMP_FAILURE_RETRY
|
#ifndef TEMP_FAILURE_RETRY
|
||||||
# define TEMP_FAILURE_RETRY(expression) \
|
# define TEMP_FAILURE_RETRY(expression) \
|
||||||
(__extension__ \
|
(__extension__ ({ long int __result; \
|
||||||
({ long int __result; \
|
|
||||||
do __result = (long int) (expression); \
|
do __result = (long int) (expression); \
|
||||||
while (__result == -1L && errno == EINTR); \
|
while (__result == -1L && errno == EINTR); \
|
||||||
__result; }))
|
__result; }))
|
||||||
@ -54,10 +53,7 @@
|
|||||||
|
|
||||||
/* List of all valid flags for the open/openat flags argument: */
|
/* List of all valid flags for the open/openat flags argument: */
|
||||||
#define VALID_OPEN_FLAGS \
|
#define VALID_OPEN_FLAGS \
|
||||||
(O_RDONLY | O_WRONLY | O_RDWR | O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC | \
|
(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_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
|
static int
|
||||||
syscall_openat2 (int dirfd, const char *path, uint64_t flags, uint64_t mode, uint64_t resolve)
|
syscall_openat2 (int dirfd, const char *path, uint64_t flags, uint64_t mode, uint64_t resolve)
|
||||||
@ -67,9 +63,7 @@ syscall_openat2 (int dirfd, const char *path, uint64_t flags, uint64_t mode, uin
|
|||||||
uint64_t flags;
|
uint64_t flags;
|
||||||
uint64_t mode;
|
uint64_t mode;
|
||||||
uint64_t resolve;
|
uint64_t resolve;
|
||||||
}
|
} how = {
|
||||||
how =
|
|
||||||
{
|
|
||||||
.flags = flags & VALID_OPEN_FLAGS,
|
.flags = flags & VALID_OPEN_FLAGS,
|
||||||
.mode = (flags & O_CREAT) ? (mode & 07777) : 0,
|
.mode = (flags & O_CREAT) ? (mode & 07777) : 0,
|
||||||
.resolve = resolve,
|
.resolve = resolve,
|
||||||
@ -105,7 +99,8 @@ int
|
|||||||
file_exists_at (int dirfd, const char *pathname)
|
file_exists_at (int dirfd, const char *pathname)
|
||||||
{
|
{
|
||||||
int ret = faccessat (dirfd, pathname, F_OK, AT_SYMLINK_NOFOLLOW | AT_EACCESS);
|
int ret = faccessat (dirfd, pathname, F_OK, AT_SYMLINK_NOFOLLOW | AT_EACCESS);
|
||||||
if (ret < 0 && errno == EINVAL) {
|
if (ret < 0 && errno == EINVAL)
|
||||||
|
{
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
return fstatat (dirfd, pathname, &buf, AT_SYMLINK_NOFOLLOW);
|
return fstatat (dirfd, pathname, &buf, AT_SYMLINK_NOFOLLOW);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user