Merge pull request #31311 from yuwata/journal-user-corruption
journal: fix user journal corruption on rotation
This commit is contained in:
+22
-2
@@ -260,11 +260,31 @@ int path_is_network_fs(const char *path) {
|
||||
return is_network_fs(&s);
|
||||
}
|
||||
|
||||
int stat_verify_linked(const struct stat *st) {
|
||||
assert(st);
|
||||
|
||||
if (st->st_nlink <= 0)
|
||||
return -EIDRM; /* recognizable error. */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fd_verify_linked(int fd) {
|
||||
struct stat st;
|
||||
|
||||
assert(fd >= 0);
|
||||
|
||||
if (fstat(fd, &st) < 0)
|
||||
return -errno;
|
||||
|
||||
return stat_verify_linked(&st);
|
||||
}
|
||||
|
||||
int stat_verify_regular(const struct stat *st) {
|
||||
assert(st);
|
||||
|
||||
/* Checks whether the specified stat() structure refers to a regular file. If not returns an appropriate error
|
||||
* code. */
|
||||
/* Checks whether the specified stat() structure refers to a regular file. If not returns an
|
||||
* appropriate error code. */
|
||||
|
||||
if (S_ISDIR(st->st_mode))
|
||||
return -EISDIR;
|
||||
|
||||
@@ -72,6 +72,9 @@ int path_is_network_fs(const char *path);
|
||||
*/
|
||||
#define F_TYPE_EQUAL(a, b) (a == (typeof(a)) b)
|
||||
|
||||
int stat_verify_linked(const struct stat *st);
|
||||
int fd_verify_linked(int fd);
|
||||
|
||||
int stat_verify_regular(const struct stat *st);
|
||||
int fd_verify_regular(int fd);
|
||||
int verify_regular_at(int dir_fd, const char *path, bool follow);
|
||||
|
||||
Reference in New Issue
Block a user