stat-util: unify code that checks whether something is a regular file
Let's add a common implementation for regular file checks, that are careful to return the right error code (EISDIR/EISLNK/EBADFD) when we are encountering a wrong file node.
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include "import-common.h"
|
||||
#include "missing.h"
|
||||
#include "ratelimit.h"
|
||||
#include "stat-util.h"
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -319,8 +320,9 @@ int raw_export_start(RawExport *e, const char *path, int fd, ImportCompressType
|
||||
|
||||
if (fstat(sfd, &e->st) < 0)
|
||||
return -errno;
|
||||
if (!S_ISREG(e->st.st_mode))
|
||||
return -ENOTTY;
|
||||
r = stat_verify_regular(&e->st);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* Try to take a reflink snapshot of the file, if we can t make the export atomic */
|
||||
tfd = reflink_snapshot(sfd, path);
|
||||
|
||||
Reference in New Issue
Block a user