mirror of
https://github.com/containers/fuse-overlayfs.git
synced 2025-09-09 23:34:57 -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
|
||||||
|
14
direct.c
14
direct.c
@ -76,7 +76,7 @@ direct_fstat (struct ovl_layer *l, int fd, const char *path, unsigned int mask,
|
|||||||
#ifdef HAVE_STATX
|
#ifdef HAVE_STATX
|
||||||
struct statx stx;
|
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))
|
if (ret < 0 && (errno == ENOSYS || errno == EINVAL))
|
||||||
goto fallback;
|
goto fallback;
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
@ -88,7 +88,7 @@ direct_fstat (struct ovl_layer *l, int fd, const char *path, unsigned int mask,
|
|||||||
return ret;
|
return ret;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fallback:
|
fallback:
|
||||||
ret = fstat (fd, st);
|
ret = fstat (fd, st);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
@ -103,7 +103,7 @@ direct_statat (struct ovl_layer *l, const char *path, struct stat *st, int flags
|
|||||||
#ifdef HAVE_STATX
|
#ifdef HAVE_STATX
|
||||||
struct statx stx;
|
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))
|
if (ret < 0 && (errno == ENOSYS || errno == EINVAL))
|
||||||
goto fallback;
|
goto fallback;
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
@ -114,7 +114,7 @@ direct_statat (struct ovl_layer *l, const char *path, struct stat *st, int flags
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
#endif
|
#endif
|
||||||
fallback:
|
fallback:
|
||||||
ret = fstatat (l->fd, path, st, flags);
|
ret = fstatat (l->fd, path, st, flags);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
@ -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,
|
||||||
@ -232,4 +230,4 @@ struct data_source direct_access_ds =
|
|||||||
.listxattr = direct_listxattr,
|
.listxattr = direct_listxattr,
|
||||||
.readlinkat = direct_readlinkat,
|
.readlinkat = direct_readlinkat,
|
||||||
.support_acls = direct_support_acls,
|
.support_acls = direct_support_acls,
|
||||||
};
|
};
|
||||||
|
@ -16,15 +16,15 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef FUSE_OVERLAYFS_H
|
#ifndef FUSE_OVERLAYFS_H
|
||||||
# define FUSE_OVERLAYFS_H
|
#define FUSE_OVERLAYFS_H
|
||||||
# define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
# include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
# include <plugin-manager.h>
|
#include <plugin-manager.h>
|
||||||
# include <stdbool.h>
|
#include <stdbool.h>
|
||||||
# include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
# define ACL_XATTR "system.posix_acl_default"
|
#define ACL_XATTR "system.posix_acl_default"
|
||||||
|
|
||||||
typedef struct hash_table Hash_table;
|
typedef struct hash_table Hash_table;
|
||||||
|
|
||||||
@ -143,25 +143,25 @@ struct ovl_layer
|
|||||||
struct data_source
|
struct data_source
|
||||||
{
|
{
|
||||||
int (*num_of_layers) (const char *opaque, const char *path);
|
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 (*load_data_source) (struct ovl_layer *l, const char *opaque, const char *path, int n_layer);
|
||||||
int (*cleanup)(struct ovl_layer *l);
|
int (*cleanup) (struct ovl_layer *l);
|
||||||
int (*file_exists)(struct ovl_layer *l, const char *pathname);
|
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 (*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);
|
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);
|
void *(*opendir) (struct ovl_layer *l, const char *path);
|
||||||
struct dirent *(*readdir)(void *dirp);
|
struct dirent *(*readdir) (void *dirp);
|
||||||
int (*closedir)(void *dirp);
|
int (*closedir) (void *dirp);
|
||||||
int (*openat)(struct ovl_layer *l, const char *path, int flags, mode_t mode);
|
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 (*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);
|
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);
|
ssize_t (*readlinkat) (struct ovl_layer *l, const char *path, char *buf, size_t bufsiz);
|
||||||
bool (*support_acls)(struct ovl_layer *l);
|
bool (*support_acls) (struct ovl_layer *l);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* passthrough to the file system. */
|
/* passthrough to the file system. */
|
||||||
extern struct data_source direct_access_ds;
|
extern struct data_source direct_access_ds;
|
||||||
|
|
||||||
# ifndef HAVE_STATX
|
#ifndef HAVE_STATX
|
||||||
# define STATX_TYPE 0x00000001U /* Want/got stx_mode & S_IFMT */
|
# define STATX_TYPE 0x00000001U /* Want/got stx_mode & S_IFMT */
|
||||||
# define STATX_MODE 0x00000002U /* 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_NLINK 0x00000004U /* Want/got stx_nlink */
|
||||||
@ -176,6 +176,6 @@ extern struct data_source direct_access_ds;
|
|||||||
# define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */
|
# define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */
|
||||||
# define STATX_BTIME 0x00000800U /* Want/got stx_btime */
|
# define STATX_BTIME 0x00000800U /* Want/got stx_btime */
|
||||||
# define STATX_ALL 0x00000fffU /* All currently supported flags */
|
# define STATX_ALL 0x00000fffU /* All currently supported flags */
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,14 +17,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FUSE_OVERLAYFS_ERROR_H
|
#ifndef FUSE_OVERLAYFS_ERROR_H
|
||||||
# define FUSE_OVERLAYFS_ERROR_H
|
#define FUSE_OVERLAYFS_ERROR_H
|
||||||
|
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
# 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 \
|
||||||
@ -34,7 +36,7 @@
|
|||||||
} \
|
} \
|
||||||
if (status) \
|
if (status) \
|
||||||
exit (status); \
|
exit (status); \
|
||||||
} while(0)
|
} while (0)
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
280
main.c
280
main.c
@ -67,9 +67,8 @@
|
|||||||
#include <plugin.h>
|
#include <plugin.h>
|
||||||
|
|
||||||
#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; }))
|
||||||
@ -108,7 +107,7 @@ cleanup_lockp (int *l)
|
|||||||
*l = 0;
|
*l = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define cleanup_lock __attribute__((cleanup (cleanup_lockp)))
|
#define cleanup_lock __attribute__ ((cleanup (cleanup_lockp)))
|
||||||
|
|
||||||
#ifndef HAVE_OPEN_BY_HANDLE_AT
|
#ifndef HAVE_OPEN_BY_HANDLE_AT
|
||||||
struct file_handle
|
struct file_handle
|
||||||
@ -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_OPAQUE_XATTR "trusted.overlay.opaque"
|
||||||
#define PRIVILEGED_ORIGIN_XATTR "trusted.overlay.origin"
|
#define PRIVILEGED_ORIGIN_XATTR "trusted.overlay.origin"
|
||||||
#define OPAQUE_WHITEOUT ".wh..wh..opq"
|
#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__
|
#if ! defined FICLONE && defined __linux__
|
||||||
# define FICLONE _IOW (0x94, 9, int)
|
# define FICLONE _IOW (0x94, 9, int)
|
||||||
#endif
|
#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),
|
_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
|
#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
|
||||||
|
|
||||||
@ -194,48 +192,48 @@ get_timeout (struct ovl_data *lo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const struct fuse_opt ovl_opts[] = {
|
static const struct fuse_opt ovl_opts[] = {
|
||||||
{"redirect_dir=%s",
|
{ "redirect_dir=%s",
|
||||||
offsetof (struct ovl_data, redirect_dir), 0},
|
offsetof (struct ovl_data, redirect_dir), 0 },
|
||||||
{"context=%s",
|
{ "context=%s",
|
||||||
offsetof (struct ovl_data, context), 0},
|
offsetof (struct ovl_data, context), 0 },
|
||||||
{"lowerdir=%s",
|
{ "lowerdir=%s",
|
||||||
offsetof (struct ovl_data, lowerdir), 0},
|
offsetof (struct ovl_data, lowerdir), 0 },
|
||||||
{"upperdir=%s",
|
{ "upperdir=%s",
|
||||||
offsetof (struct ovl_data, upperdir), 0},
|
offsetof (struct ovl_data, upperdir), 0 },
|
||||||
{"workdir=%s",
|
{ "workdir=%s",
|
||||||
offsetof (struct ovl_data, workdir), 0},
|
offsetof (struct ovl_data, workdir), 0 },
|
||||||
{"uidmapping=%s",
|
{ "uidmapping=%s",
|
||||||
offsetof (struct ovl_data, uid_str), 0},
|
offsetof (struct ovl_data, uid_str), 0 },
|
||||||
{"gidmapping=%s",
|
{ "gidmapping=%s",
|
||||||
offsetof (struct ovl_data, gid_str), 0},
|
offsetof (struct ovl_data, gid_str), 0 },
|
||||||
{"timeout=%s",
|
{ "timeout=%s",
|
||||||
offsetof (struct ovl_data, timeout_str), 0},
|
offsetof (struct ovl_data, timeout_str), 0 },
|
||||||
{"threaded=%d",
|
{ "threaded=%d",
|
||||||
offsetof (struct ovl_data, threaded), 0},
|
offsetof (struct ovl_data, threaded), 0 },
|
||||||
{"fsync=%d",
|
{ "fsync=%d",
|
||||||
offsetof (struct ovl_data, fsync), 1},
|
offsetof (struct ovl_data, fsync), 1 },
|
||||||
{"fast_ino=%d",
|
{ "fast_ino=%d",
|
||||||
offsetof (struct ovl_data, fast_ino_check), 0},
|
offsetof (struct ovl_data, fast_ino_check), 0 },
|
||||||
{"writeback=%d",
|
{ "writeback=%d",
|
||||||
offsetof (struct ovl_data, writeback), 1},
|
offsetof (struct ovl_data, writeback), 1 },
|
||||||
{"noxattrs=%d",
|
{ "noxattrs=%d",
|
||||||
offsetof (struct ovl_data, disable_xattrs), 1},
|
offsetof (struct ovl_data, disable_xattrs), 1 },
|
||||||
{"plugins=%s",
|
{ "plugins=%s",
|
||||||
offsetof (struct ovl_data, plugins), 0},
|
offsetof (struct ovl_data, plugins), 0 },
|
||||||
{"xattr_permissions=%d",
|
{ "xattr_permissions=%d",
|
||||||
offsetof (struct ovl_data, xattr_permissions), 0},
|
offsetof (struct ovl_data, xattr_permissions), 0 },
|
||||||
{"squash_to_root",
|
{ "squash_to_root",
|
||||||
offsetof (struct ovl_data, squash_to_root), 1},
|
offsetof (struct ovl_data, squash_to_root), 1 },
|
||||||
{"squash_to_uid=%d",
|
{ "squash_to_uid=%d",
|
||||||
offsetof (struct ovl_data, squash_to_uid), 1},
|
offsetof (struct ovl_data, squash_to_uid), 1 },
|
||||||
{"squash_to_gid=%d",
|
{ "squash_to_gid=%d",
|
||||||
offsetof (struct ovl_data, squash_to_gid), 1},
|
offsetof (struct ovl_data, squash_to_gid), 1 },
|
||||||
{"static_nlink",
|
{ "static_nlink",
|
||||||
offsetof (struct ovl_data, static_nlink), 1},
|
offsetof (struct ovl_data, static_nlink), 1 },
|
||||||
{"volatile", /* native overlay supports "volatile" to mean fsync=0. */
|
{ "volatile", /* native overlay supports "volatile" to mean fsync=0. */
|
||||||
offsetof (struct ovl_data, volatile_mode), 1},
|
offsetof (struct ovl_data, volatile_mode), 1 },
|
||||||
{"noacl",
|
{ "noacl",
|
||||||
offsetof (struct ovl_data, noacl), 1},
|
offsetof (struct ovl_data, noacl), 1 },
|
||||||
FUSE_OPT_END
|
FUSE_OPT_END
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -333,7 +331,7 @@ check_can_mknod (struct ovl_data *lo)
|
|||||||
|
|
||||||
sprintf (path, "%lu", get_next_wd_counter ());
|
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)
|
if (ret == 0)
|
||||||
unlinkat (lo->workdir_fd, path, 0);
|
unlinkat (lo->workdir_fd, path, 0);
|
||||||
if (ret < 0 && errno == EPERM)
|
if (ret < 0 && errno == EPERM)
|
||||||
@ -528,9 +526,9 @@ has_prefix (const char *str, const char *pref)
|
|||||||
static bool
|
static bool
|
||||||
can_access_xattr (const char *name)
|
can_access_xattr (const char *name)
|
||||||
{
|
{
|
||||||
return !has_prefix (name, XATTR_PREFIX)
|
return ! has_prefix (name, XATTR_PREFIX)
|
||||||
&& !has_prefix (name, PRIVILEGED_XATTR_PREFIX)
|
&& ! has_prefix (name, PRIVILEGED_XATTR_PREFIX)
|
||||||
&& !has_prefix (name, UNPRIVILEGED_XATTR_PREFIX);
|
&& ! has_prefix (name, UNPRIVILEGED_XATTR_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
@ -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)
|
if (lo->xattr_permissions)
|
||||||
{
|
{
|
||||||
char proc_path[32];
|
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)
|
if (fd < 0)
|
||||||
return fd;
|
return fd;
|
||||||
|
|
||||||
@ -705,8 +703,8 @@ set_fd_opaque (int fd)
|
|||||||
if (errno != EPERM || (fsetxattr (fd, OPAQUE_XATTR, "y", 1, 0) < 0 && errno != ENOTSUP))
|
if (errno != EPERM || (fsetxattr (fd, OPAQUE_XATTR, "y", 1, 0) < 0 && errno != ENOTSUP))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
create_opq_whiteout:
|
create_opq_whiteout:
|
||||||
opq_whiteout_fd = TEMP_FAILURE_RETRY (safe_openat (fd, OPAQUE_WHITEOUT, O_CREAT|O_WRONLY|O_NONBLOCK, 0700));
|
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;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
/* Not present in the lower layers, do not do anything. */
|
/* Not present in the lower layers, do not do anything. */
|
||||||
if (!found)
|
if (! found)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skip_mknod && can_mknod)
|
if (! skip_mknod && can_mknod)
|
||||||
{
|
{
|
||||||
char whiteout_path[PATH_MAX];
|
char whiteout_path[PATH_MAX];
|
||||||
|
|
||||||
strconcat3 (whiteout_path, PATH_MAX, parent->path, "/", name);
|
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)
|
if (ret == 0)
|
||||||
return 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);
|
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)
|
if (fd < 0 && errno != EEXIST)
|
||||||
return -1;
|
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);
|
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
|
&& (st.st_mode & S_IFMT) == S_IFCHR
|
||||||
&& major (st.st_rdev) == 0
|
&& major (st.st_rdev) == 0
|
||||||
&& minor (st.st_rdev) == 0)
|
&& minor (st.st_rdev) == 0)
|
||||||
@ -879,7 +877,7 @@ find_mapping (unsigned int id, const struct ovl_data *data,
|
|||||||
|
|
||||||
if (direct && uid && data->squash_to_uid != -1)
|
if (direct && uid && data->squash_to_uid != -1)
|
||||||
return data->squash_to_uid;
|
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;
|
return data->squash_to_gid;
|
||||||
if (direct && data->squash_to_root)
|
if (direct && data->squash_to_root)
|
||||||
return 0;
|
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);
|
struct ovl_data *data = ovl_data (req);
|
||||||
|
|
||||||
if (st_in)
|
if (st_in)
|
||||||
memcpy (st, st_in, sizeof (* st));
|
memcpy (st, st_in, sizeof (*st));
|
||||||
else if (fd >= 0)
|
else if (fd >= 0)
|
||||||
ret = l->ds->fstat (l, fd, path, STATX_BASIC_STATS, st);
|
ret = l->ds->fstat (l, fd, path, STATX_BASIC_STATS, st);
|
||||||
else if (path != NULL)
|
else if (path != NULL)
|
||||||
@ -1110,7 +1108,7 @@ hide_node (struct ovl_data *lo, struct ovl_node *node, bool unlink_src)
|
|||||||
bool needs_whiteout;
|
bool needs_whiteout;
|
||||||
|
|
||||||
needs_whiteout = (node->last_layer != get_upper_layer (lo)) && (node->parent && node->parent->last_layer != get_upper_layer (lo));
|
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);
|
ret = is_directory_opaque (get_upper_layer (lo), node->path);
|
||||||
if (ret < 0)
|
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 the parent directory is opaque, there's no need to put a whiteout in it.
|
||||||
if (node->parent != NULL)
|
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)
|
if (needs_whiteout)
|
||||||
{
|
{
|
||||||
@ -1132,7 +1130,7 @@ hide_node (struct ovl_data *lo, struct ovl_node *node, bool unlink_src)
|
|||||||
moved = true;
|
moved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!whiteout_created)
|
if (! whiteout_created)
|
||||||
{
|
{
|
||||||
if (node->parent)
|
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)
|
if (renameat (node_dirfd (node), node->path, lo->workdir_fd, newpath) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1371,7 +1369,7 @@ cleanup_node_initp (struct ovl_node **p)
|
|||||||
free (n);
|
free (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define cleanup_node_init __attribute__((cleanup (cleanup_node_initp)))
|
#define cleanup_node_init __attribute__ ((cleanup (cleanup_node_initp)))
|
||||||
|
|
||||||
static void
|
static void
|
||||||
node_set_name (struct ovl_node *node, char *name)
|
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)
|
if (ret->path == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!dir_p)
|
if (! dir_p)
|
||||||
ret->children = NULL;
|
ret->children = NULL;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1540,11 +1538,11 @@ make_ovl_node (struct ovl_data *lo, const char *path, struct ovl_layer *layer, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! fast_ino_check)
|
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 (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)
|
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. */
|
/* 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)
|
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);
|
size_t s = ofh->len - sizeof (*ofh);
|
||||||
struct file_handle *fh = (struct file_handle *) buf;
|
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;
|
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);
|
originfd = open_by_handle_at (AT_FDCWD, fh, O_RDONLY);
|
||||||
if (originfd >= 0)
|
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_ino = st.st_ino;
|
||||||
ret->tmp_dev = st.st_dev;
|
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;
|
origin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
no_fd:
|
no_fd:
|
||||||
if (parent && parent->last_layer == it)
|
if (parent && parent->last_layer == it)
|
||||||
break;
|
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);
|
struct ovl_layer *it, *upper_layer = get_upper_layer (lo);
|
||||||
char parent_whiteout_path[PATH_MAX];
|
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);
|
n = make_ovl_node (lo, path, layer, name, 0, 0, true, NULL, lo->fast_ino_check);
|
||||||
if (n == NULL)
|
if (n == NULL)
|
||||||
@ -1704,7 +1702,7 @@ load_dir (struct ovl_data *lo, struct ovl_node *n, struct ovl_layer *layer, char
|
|||||||
else
|
else
|
||||||
strconcat3 (parent_whiteout_path, PATH_MAX, ".wh.", name, NULL);
|
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;
|
struct stat st;
|
||||||
DIR *dp = NULL;
|
DIR *dp = NULL;
|
||||||
@ -1764,7 +1762,7 @@ load_dir (struct ovl_data *lo, struct ovl_node *n, struct ovl_layer *layer, char
|
|||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
child->last_layer = it;
|
child->last_layer = it;
|
||||||
if (!child->whiteout || it != upper_layer)
|
if (! child->whiteout || it != upper_layer)
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1903,7 +1901,7 @@ cleanup_layerp (struct ovl_layer **p)
|
|||||||
free_layers (l);
|
free_layers (l);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define cleanup_layer __attribute__((cleanup (cleanup_layerp)))
|
#define cleanup_layer __attribute__ ((cleanup (cleanup_layerp)))
|
||||||
|
|
||||||
static struct ovl_layer *
|
static struct ovl_layer *
|
||||||
read_dirs (struct ovl_data *lo, char *path, bool low, struct ovl_layer *layers)
|
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_set_name (&key, (char *) name);
|
||||||
node = hash_lookup (pnode->children, &key);
|
node = hash_lookup (pnode->children, &key);
|
||||||
if (node == NULL && !pnode->loaded)
|
if (node == NULL && ! pnode->loaded)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct ovl_layer *it;
|
struct ovl_layer *it;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
bool stop_lookup = false;
|
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 path[PATH_MAX];
|
||||||
char whpath[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);
|
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)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
int saved_errno = errno;
|
int saved_errno = errno;
|
||||||
@ -2156,7 +2154,7 @@ do_lookup_file (struct ovl_data *lo, fuse_ino_t parent, const char *name)
|
|||||||
stop_lookup = true;
|
stop_lookup = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
insert_node:
|
insert_node:
|
||||||
if (insert_node (pnode, node, false) == NULL)
|
if (insert_node (pnode, node, false) == NULL)
|
||||||
{
|
{
|
||||||
node_free (node);
|
node_free (node);
|
||||||
@ -2194,7 +2192,7 @@ ovl_lookup (fuse_req_t req, fuse_ino_t parent, const char *name)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lo->static_nlink && node_dirp (node))
|
if (! lo->static_nlink && node_dirp (node))
|
||||||
{
|
{
|
||||||
node = reload_dir (lo, node);
|
node = reload_dir (lo, node);
|
||||||
if (node == NULL)
|
if (node == NULL)
|
||||||
@ -2453,7 +2451,7 @@ ovl_do_readdir (fuse_req_t req, fuse_ino_t ino, size_t size,
|
|||||||
name = node->name;
|
name = node->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plus)
|
if (! plus)
|
||||||
{
|
{
|
||||||
/* From the 'stbuf' argument the st_ino field and bits 12-15 of the
|
/* 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_mode field are used. The other fields are ignored.
|
||||||
@ -2466,7 +2464,7 @@ ovl_do_readdir (fuse_req_t req, fuse_ino_t ino, size_t size,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!lo->static_nlink && node_dirp (node))
|
if (! lo->static_nlink && node_dirp (node))
|
||||||
{
|
{
|
||||||
node = reload_dir (lo, node);
|
node = reload_dir (lo, node);
|
||||||
if (node == NULL)
|
if (node == NULL)
|
||||||
@ -2871,7 +2869,7 @@ create_directory (struct ovl_data *lo, int dirfd, const char *name, const struct
|
|||||||
mode |= 0755;
|
mode |= 0755;
|
||||||
|
|
||||||
need_rename = set_opaque || times || xattr_sfd >= 0 || uid != lo->uid || gid != lo->gid;
|
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. */
|
/* mkdir can be used directly without a temporary directory in the working directory. */
|
||||||
ret = mkdirat (dirfd, name, mode);
|
ret = mkdirat (dirfd, name, mode);
|
||||||
@ -3002,7 +3000,7 @@ create_node_directory (struct ovl_data *lo, struct ovl_node *src)
|
|||||||
if (src->layer == get_upper_layer (lo))
|
if (src->layer == get_upper_layer (lo))
|
||||||
return 0;
|
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)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
@ -3127,11 +3124,11 @@ copyup (struct ovl_data *lo, struct ovl_node *node)
|
|||||||
goto success;
|
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)
|
if (sfd < 0)
|
||||||
goto exit;
|
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)
|
if (dfd < 0)
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
@ -3216,12 +3213,12 @@ copyup (struct ovl_data *lo, struct ovl_node *node)
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
success:
|
success:
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
node->layer = get_upper_layer (lo);
|
node->layer = get_upper_layer (lo);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
unlinkat (lo->workdir_fd, wd_tmp_file_name, 0);
|
unlinkat (lo->workdir_fd, wd_tmp_file_name, 0);
|
||||||
@ -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."))
|
if (name && has_prefix (name, ".wh."))
|
||||||
{
|
{
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return - 1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = do_lookup_file (lo, parent, name);
|
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);
|
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;
|
errno = EEXIST;
|
||||||
return -1;
|
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;
|
is_whiteout = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!n)
|
if (! n)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct ovl_node *p;
|
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)
|
if (p == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (p->loaded && !is_whiteout)
|
if (p->loaded && ! is_whiteout)
|
||||||
need_delete_whiteout = false;
|
need_delete_whiteout = false;
|
||||||
|
|
||||||
sprintf (wd_tmp_file_name, "%lu", get_next_wd_counter ());
|
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;
|
errno = ENOMEM;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!is_whiteout)
|
if (! is_whiteout)
|
||||||
n->last_layer = get_upper_layer (lo);
|
n->last_layer = get_upper_layer (lo);
|
||||||
|
|
||||||
n = insert_node (p, n, true);
|
n = insert_node (p, n, true);
|
||||||
@ -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;
|
||||||
@ -3820,7 +3818,7 @@ ovl_write_buf (fuse_req_t req, fuse_ino_t ino,
|
|||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
|
|
||||||
/* if it is a writepage request, make sure to restore the setuid bit. */
|
/* 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)
|
if (do_fchmod (lo, fi->fh, inode->mode) < 0)
|
||||||
{
|
{
|
||||||
@ -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)
|
switch (mode & S_IFMT)
|
||||||
{
|
{
|
||||||
case S_IFREG:
|
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)
|
if (fd < 0)
|
||||||
strconcat3 (path, PATH_MAX, get_upper_layer (lo)->path, "/", node->path);
|
strconcat3 (path, PATH_MAX, get_upper_layer (lo)->path, "/", node->path);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_IFDIR:
|
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 (fd < 0)
|
||||||
{
|
{
|
||||||
if (errno != ELOOP)
|
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;
|
break;
|
||||||
|
|
||||||
case S_IFLNK:
|
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)
|
if (cleaned_up_fd < 0)
|
||||||
{
|
{
|
||||||
fuse_reply_err (req, errno);
|
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);
|
destnode = do_lookup_file (lo, newparent, newname);
|
||||||
if (destnode && !destnode->whiteout)
|
if (destnode && ! destnode->whiteout)
|
||||||
{
|
{
|
||||||
fuse_reply_err (req, EEXIST);
|
fuse_reply_err (req, EEXIST);
|
||||||
return;
|
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);
|
fuse_reply_err (req, ENOMEM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (destnode && !destnode->whiteout)
|
if (destnode && ! destnode->whiteout)
|
||||||
node->last_layer = get_upper_layer (lo);
|
node->last_layer = get_upper_layer (lo);
|
||||||
|
|
||||||
node = insert_node (newparentnode, node, true);
|
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);
|
node = do_lookup_file (lo, parent, name);
|
||||||
if (node != NULL && !node->whiteout)
|
if (node != NULL && ! node->whiteout)
|
||||||
{
|
{
|
||||||
fuse_reply_err (req, EEXIST);
|
fuse_reply_err (req, EEXIST);
|
||||||
return;
|
return;
|
||||||
@ -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;
|
||||||
@ -4546,10 +4543,10 @@ ovl_rename_exchange (fuse_req_t req, fuse_ino_t parent, const char *name,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
fuse_reply_err (req, ret == 0 ? 0 : errno);
|
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 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 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;
|
errno = EEXIST;
|
||||||
goto error;
|
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;
|
size_t destnode_whiteouts = 0;
|
||||||
|
|
||||||
errno = EINVAL;
|
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;
|
goto error;
|
||||||
|
|
||||||
destnode_is_whiteout = destnode->whiteout;
|
destnode_is_whiteout = destnode->whiteout;
|
||||||
|
|
||||||
if (!destnode->whiteout && node_dirp (destnode))
|
if (! destnode->whiteout && node_dirp (destnode))
|
||||||
{
|
{
|
||||||
destnode = reload_dir (lo, destnode);
|
destnode = reload_dir (lo, destnode);
|
||||||
if (destnode == NULL)
|
if (destnode == NULL)
|
||||||
@ -4670,7 +4667,7 @@ ovl_rename_direct (fuse_req_t req, fuse_ino_t parent, const char *name,
|
|||||||
destnode = NULL;
|
destnode = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destnode && !destnode_is_whiteout)
|
if (destnode && ! destnode_is_whiteout)
|
||||||
{
|
{
|
||||||
/* If the node is still accessible then be sure we
|
/* If the node is still accessible then be sure we
|
||||||
can write to it. Fix it to be done when a write is
|
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 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 not, we can try to atomically create one with the WHITEOUT flag. */
|
||||||
if (destnode_is_whiteout)
|
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
|
else
|
||||||
{
|
{
|
||||||
if (! can_mknod)
|
if (! can_mknod)
|
||||||
@ -4715,7 +4712,7 @@ ovl_rename_direct (fuse_req_t req, fuse_ino_t parent, const char *name,
|
|||||||
errno = EPERM;
|
errno = EPERM;
|
||||||
}
|
}
|
||||||
else
|
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. */
|
/* If atomic whiteout creation failed, fall back to separate rename and whiteout creation. */
|
||||||
@ -4762,7 +4759,7 @@ ovl_rename_direct (fuse_req_t req, fuse_ino_t parent, const char *name,
|
|||||||
fuse_reply_err (req, 0);
|
fuse_reply_err (req, 0);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
ret = -1;
|
ret = -1;
|
||||||
fuse_reply_err (req, errno);
|
fuse_reply_err (req, errno);
|
||||||
}
|
}
|
||||||
@ -4898,7 +4895,7 @@ hide_all (struct ovl_data *lo, struct ovl_node *node)
|
|||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
free(nodes);
|
free (nodes);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4936,7 +4933,7 @@ ovl_mknod (fuse_req_t req, fuse_ino_t parent, const char *name, mode_t mode, dev
|
|||||||
mode |= 0755;
|
mode |= 0755;
|
||||||
|
|
||||||
node = do_lookup_file (lo, parent, name);
|
node = do_lookup_file (lo, parent, name);
|
||||||
if (node != NULL && !node->whiteout)
|
if (node != NULL && ! node->whiteout)
|
||||||
{
|
{
|
||||||
fuse_reply_err (req, EEXIST);
|
fuse_reply_err (req, EEXIST);
|
||||||
return;
|
return;
|
||||||
@ -5064,7 +5061,7 @@ ovl_mkdir (fuse_req_t req, fuse_ino_t parent, const char *name, mode_t mode)
|
|||||||
mode |= 0755;
|
mode |= 0755;
|
||||||
|
|
||||||
node = do_lookup_file (lo, parent, name);
|
node = do_lookup_file (lo, parent, name);
|
||||||
if (node != NULL && !node->whiteout)
|
if (node != NULL && ! node->whiteout)
|
||||||
{
|
{
|
||||||
fuse_reply_err (req, EEXIST);
|
fuse_reply_err (req, EEXIST);
|
||||||
return;
|
return;
|
||||||
@ -5172,7 +5169,7 @@ direct_fsync (struct ovl_layer *l, int fd, const char *path, int datasync)
|
|||||||
|
|
||||||
if (fd < 0)
|
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)
|
if (cfd < 0)
|
||||||
return cfd;
|
return cfd;
|
||||||
fd = 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);
|
struct ovl_data *lo = ovl_data (req);
|
||||||
cleanup_lock int l = 0;
|
cleanup_lock int l = 0;
|
||||||
|
|
||||||
if (!lo->fsync)
|
if (! lo->fsync)
|
||||||
{
|
{
|
||||||
fuse_reply_err (req, ENOSYS);
|
fuse_reply_err (req, ENOSYS);
|
||||||
return;
|
return;
|
||||||
@ -5302,7 +5299,7 @@ ovl_ioctl (fuse_req_t req, fuse_ino_t ino, int cmd, void *arg,
|
|||||||
|
|
||||||
if (fd < 0)
|
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)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
fuse_reply_err (req, errno);
|
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);
|
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)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
fuse_reply_err (req, errno);
|
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)
|
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
|
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)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
fuse_reply_err (req, errno);
|
fuse_reply_err (req, errno);
|
||||||
return;
|
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)
|
if (fd_dest < 0)
|
||||||
{
|
{
|
||||||
fuse_reply_err (req, errno);
|
fuse_reply_err (req, errno);
|
||||||
@ -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,
|
||||||
@ -5476,7 +5472,7 @@ static struct fuse_lowlevel_ops ovl_oper =
|
|||||||
#if HAVE_COPY_FILE_RANGE && HAVE_FUSE_COPY_FILE_RANGE
|
#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
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
fuse_opt_proc (void *data, const char *arg, int key, struct fuse_args *outargs)
|
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;
|
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;
|
||||||
@ -5568,7 +5563,7 @@ get_new_args (int *argc, char **argv)
|
|||||||
error (EXIT_FAILURE, 0, "error allocating memory");
|
error (EXIT_FAILURE, 0, "error allocating memory");
|
||||||
|
|
||||||
newargv[0] = argv[0];
|
newargv[0] = argv[0];
|
||||||
if (geteuid() == 0)
|
if (geteuid () == 0)
|
||||||
newargv[1] = "-odefault_permissions,allow_other,suid,noatime,lazytime";
|
newargv[1] = "-odefault_permissions,allow_other,suid,noatime,lazytime";
|
||||||
else
|
else
|
||||||
newargv[1] = "-odefault_permissions,noatime";
|
newargv[1] = "-odefault_permissions,noatime";
|
||||||
@ -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,
|
||||||
@ -5723,8 +5719,8 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
if (lo.debug)
|
if (lo.debug)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "uid=%s\n", lo.uid_str ? : "unchanged");
|
fprintf (stderr, "uid=%s\n", lo.uid_str ?: "unchanged");
|
||||||
fprintf (stderr, "gid=%s\n", lo.gid_str ? : "unchanged");
|
fprintf (stderr, "gid=%s\n", lo.gid_str ?: "unchanged");
|
||||||
fprintf (stderr, "upperdir=%s\n", lo.upperdir ? lo.upperdir : "NOT USED");
|
fprintf (stderr, "upperdir=%s\n", lo.upperdir ? lo.upperdir : "NOT USED");
|
||||||
fprintf (stderr, "workdir=%s\n", lo.workdir ? lo.workdir : "NOT USED");
|
fprintf (stderr, "workdir=%s\n", lo.workdir ? lo.workdir : "NOT USED");
|
||||||
fprintf (stderr, "lowerdir=%s\n", lo.lowerdir);
|
fprintf (stderr, "lowerdir=%s\n", lo.lowerdir);
|
||||||
@ -5765,7 +5761,7 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
lo.layers = layers;
|
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))
|
if (! tmp_layer->ds->support_acls (tmp_layer))
|
||||||
lo.noacl = 1;
|
lo.noacl = 1;
|
||||||
@ -5832,8 +5828,8 @@ main (int argc, char *argv[])
|
|||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
goto err_out1;
|
goto err_out1;
|
||||||
mkdir (path, 0700);
|
mkdir (path, 0700);
|
||||||
path = realloc(path, strlen(path)+strlen("/work")+1);
|
path = realloc (path, strlen (path) + strlen ("/work") + 1);
|
||||||
if (!path)
|
if (! path)
|
||||||
error (EXIT_FAILURE, errno, "allocating workdir path");
|
error (EXIT_FAILURE, errno, "allocating workdir path");
|
||||||
strcat (path, "/work");
|
strcat (path, "/work");
|
||||||
mkdir (path, 0700);
|
mkdir (path, 0700);
|
||||||
@ -5853,7 +5849,7 @@ main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
umask (0);
|
umask (0);
|
||||||
disable_locking = !lo.threaded;
|
disable_locking = ! lo.threaded;
|
||||||
|
|
||||||
se = fuse_session_new (&args, &ovl_oper, sizeof (ovl_oper), &lo);
|
se = fuse_session_new (&args, &ovl_oper, sizeof (ovl_oper), &lo);
|
||||||
lo.se = se;
|
lo.se = se;
|
||||||
|
@ -52,9 +52,9 @@ plugin_load_one (struct ovl_plugin_context *context, const char *path)
|
|||||||
plugin_name name;
|
plugin_name name;
|
||||||
struct ovl_plugin *p;
|
struct ovl_plugin *p;
|
||||||
plugin_version version;
|
plugin_version version;
|
||||||
void *handle = dlopen (path, RTLD_NOW|RTLD_LOCAL);
|
void *handle = dlopen (path, RTLD_NOW | RTLD_LOCAL);
|
||||||
if (! handle)
|
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));
|
p = calloc (1, sizeof (*p));
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PLUGIN_MANAGER_H
|
#ifndef PLUGIN_MANAGER_H
|
||||||
# define PLUGIN_MANAGER_H
|
#define PLUGIN_MANAGER_H
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
# include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
struct ovl_plugin_context
|
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 */
|
/* 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; }))
|
||||||
|
16
plugin.h
16
plugin.h
@ -17,16 +17,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PLUGIN_H
|
#ifndef PLUGIN_H
|
||||||
# define PLUGIN_H
|
#define PLUGIN_H
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
# include <utils.h>
|
#include <utils.h>
|
||||||
# include <fuse-overlayfs.h>
|
#include <fuse-overlayfs.h>
|
||||||
|
|
||||||
typedef struct data_source *(*plugin_load_data_source)(const char *opaque, const char *path);
|
typedef struct data_source *(*plugin_load_data_source) (const char *opaque, const char *path);
|
||||||
typedef int (*plugin_release)();
|
typedef int (*plugin_release) ();
|
||||||
typedef const char *(*plugin_name)();
|
typedef const char *(*plugin_name) ();
|
||||||
typedef int (*plugin_version)();
|
typedef int (*plugin_version) ();
|
||||||
|
|
||||||
struct ovl_plugin
|
struct ovl_plugin
|
||||||
{
|
{
|
||||||
|
@ -14,13 +14,13 @@ main ()
|
|||||||
unlink ("suid");
|
unlink ("suid");
|
||||||
unlink ("nosuid");
|
unlink ("nosuid");
|
||||||
|
|
||||||
fd = open ("suid", O_WRONLY|O_CREAT|O_EXCL);
|
fd = open ("suid", O_WRONLY | O_CREAT | O_EXCL);
|
||||||
write (fd, "1", 1);
|
write (fd, "1", 1);
|
||||||
fchown (fd, 0, 0);
|
fchown (fd, 0, 0);
|
||||||
fchmod (fd, S_ISUID | 0755);
|
fchmod (fd, S_ISUID | 0755);
|
||||||
close (fd);
|
close (fd);
|
||||||
|
|
||||||
fd = open ("nosuid", O_WRONLY|O_CREAT|O_EXCL);
|
fd = open ("nosuid", O_WRONLY | O_CREAT | O_EXCL);
|
||||||
write (fd, "1", 1);
|
write (fd, "1", 1);
|
||||||
fchown (fd, 0, 0);
|
fchown (fd, 0, 0);
|
||||||
fchmod (fd, S_ISUID | 0755);
|
fchmod (fd, S_ISUID | 0755);
|
||||||
|
23
utils.c
23
utils.c
@ -32,9 +32,8 @@
|
|||||||
#include <sys/xattr.h>
|
#include <sys/xattr.h>
|
||||||
|
|
||||||
#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,
|
||||||
@ -97,15 +91,16 @@ safe_openat (int dirfd, const char *pathname, int flags, mode_t mode)
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
fallback:
|
fallback:
|
||||||
return openat (dirfd, pathname, flags, mode);
|
return openat (dirfd, pathname, flags, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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);
|
||||||
}
|
}
|
||||||
@ -219,7 +214,7 @@ open_fd_or_get_path (struct ovl_layer *l, const char *path, char *out, int *fd,
|
|||||||
{
|
{
|
||||||
out[0] = '\0';
|
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))
|
if (*fd < 0 && (errno == ELOOP || errno == EISDIR || errno == ENXIO))
|
||||||
{
|
{
|
||||||
strconcat3 (out, PATH_MAX, l->path, "/", path);
|
strconcat3 (out, PATH_MAX, l->path, "/", path);
|
||||||
|
42
utils.h
42
utils.h
@ -16,25 +16,25 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef UTILS_H
|
#ifndef UTILS_H
|
||||||
# define UTILS_H
|
#define UTILS_H
|
||||||
|
|
||||||
#ifndef _GNU_SOURCE
|
#ifndef _GNU_SOURCE
|
||||||
# define _GNU_SOURCE
|
# define _GNU_SOURCE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
# include <dirent.h>
|
#include <dirent.h>
|
||||||
# include <fcntl.h>
|
#include <fcntl.h>
|
||||||
# include <limits.h>
|
#include <limits.h>
|
||||||
# include <stdio.h>
|
#include <stdio.h>
|
||||||
# include <stdlib.h>
|
#include <stdlib.h>
|
||||||
# include <sys/types.h>
|
#include <sys/types.h>
|
||||||
# include <unistd.h>
|
#include <unistd.h>
|
||||||
# include "fuse-overlayfs.h"
|
#include "fuse-overlayfs.h"
|
||||||
|
|
||||||
# define XATTR_OVERRIDE_STAT "user.fuseoverlayfs.override_stat"
|
#define XATTR_OVERRIDE_STAT "user.fuseoverlayfs.override_stat"
|
||||||
# define XATTR_PRIVILEGED_OVERRIDE_STAT "security.fuseoverlayfs.override_stat"
|
#define XATTR_PRIVILEGED_OVERRIDE_STAT "security.fuseoverlayfs.override_stat"
|
||||||
# define XATTR_OVERRIDE_CONTAINERS_STAT "user.containers.override_stat"
|
#define XATTR_OVERRIDE_CONTAINERS_STAT "user.containers.override_stat"
|
||||||
|
|
||||||
void cleanup_freep (void *p);
|
void cleanup_freep (void *p);
|
||||||
void cleanup_filep (FILE **f);
|
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 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);
|
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_file __attribute__ ((cleanup (cleanup_filep)))
|
||||||
# define cleanup_free __attribute__((cleanup (cleanup_freep)))
|
#define cleanup_free __attribute__ ((cleanup (cleanup_freep)))
|
||||||
# define cleanup_close __attribute__((cleanup (cleanup_closep)))
|
#define cleanup_close __attribute__ ((cleanup (cleanup_closep)))
|
||||||
# define cleanup_dir __attribute__((cleanup (cleanup_dirp)))
|
#define cleanup_dir __attribute__ ((cleanup (cleanup_dirp)))
|
||||||
|
|
||||||
# define LIKELY(x) __builtin_expect((x),1)
|
#define LIKELY(x) __builtin_expect ((x), 1)
|
||||||
# define UNLIKELY(x) __builtin_expect((x),0)
|
#define UNLIKELY(x) __builtin_expect ((x), 0)
|
||||||
|
|
||||||
# ifdef HAVE_STATX
|
#ifdef HAVE_STATX
|
||||||
void statx_to_stat (struct statx *stx, struct stat *st);
|
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);
|
int safe_openat (int dirfd, const char *pathname, int flags, mode_t mode);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user