diff options
Diffstat (limited to 'meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch')
-rw-r--r-- | meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch b/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch index f8e19ce172..28a9a3491f 100644 --- a/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch +++ b/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch @@ -9,11 +9,11 @@ Signed-off-by: Chen Qi <Qi.Chen@windriver.com> src/journal/journald-kmsg.c | 16 ++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) -diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c -index f2f1f35..092f87b 100644 ---- a/src/journal/journal-file.c -+++ b/src/journal/journal-file.c -@@ -38,6 +38,8 @@ +Index: git/src/journal/journal-file.c +=================================================================== +--- git.orig/src/journal/journal-file.c ++++ git/src/journal/journal-file.c +@@ -35,6 +35,8 @@ #include "compress.h" #include "fsprg.h" @@ -22,7 +22,7 @@ index f2f1f35..092f87b 100644 #define DEFAULT_DATA_HASH_TABLE_SIZE (2047ULL*sizeof(HashItem)) #define DEFAULT_FIELD_HASH_TABLE_SIZE (333ULL*sizeof(HashItem)) -@@ -314,7 +316,7 @@ static int journal_file_verify_header(JournalFile *f) { +@@ -314,7 +316,7 @@ static int journal_file_verify_header(Jo static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) { uint64_t old_size, new_size; @@ -31,7 +31,7 @@ index f2f1f35..092f87b 100644 assert(f); -@@ -362,9 +364,21 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) +@@ -362,9 +364,21 @@ static int journal_file_allocate(Journal /* Note that the glibc fallocate() fallback is very inefficient, hence we try to minimize the allocation area as we can. */ @@ -53,10 +53,10 @@ index f2f1f35..092f87b 100644 if (fstat(f->fd, &f->last_stat) < 0) return -errno; -diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c -index 12992e7..dc4fa93 100644 ---- a/src/journal/journald-kmsg.c -+++ b/src/journal/journald-kmsg.c +Index: git/src/journal/journald-kmsg.c +=================================================================== +--- git.orig/src/journal/journald-kmsg.c ++++ git/src/journal/journald-kmsg.c @@ -437,6 +437,7 @@ fail: int server_open_kernel_seqnum(Server *s) { _cleanup_close_ int fd; @@ -65,28 +65,24 @@ index 12992e7..dc4fa93 100644 assert(s); -@@ -449,8 +450,19 @@ int server_open_kernel_seqnum(Server *s) { - log_error("Failed to open /run/systemd/journal/kernel-seqnum, ignoring: %m"); +@@ -450,7 +451,19 @@ int server_open_kernel_seqnum(Server *s) return 0; } -- + - if (posix_fallocate(fd, 0, sizeof(uint64_t)) < 0) { +#ifdef HAVE_POSIX_FALLOCATE + r = posix_fallocate(fd, 0, sizeof(uint64_t)); +#else -+ /* Use good old method to write zeros into the journal file -+ perhaps very inefficient yet working. */ -+ char *buf = alloca(sizeof(uint64_t)); -+ off_t oldpos = lseek(fd, 0, SEEK_CUR); -+ bzero(buf, sizeof(uint64_t)); -+ lseek(fd, 0, SEEK_SET); -+ r = write(fd, buf, sizeof(uint64_t)); -+ lseek(fd, oldpos, SEEK_SET); ++ /* Use good old method to write zeros into the journal file ++ perhaps very inefficient yet working. */ ++ char *buf = alloca(sizeof(uint64_t)); ++ off_t oldpos = lseek(fd, 0, SEEK_CUR); ++ bzero(buf, sizeof(uint64_t)); ++ lseek(fd, 0, SEEK_SET); ++ r = write(fd, buf, sizeof(uint64_t)); ++ lseek(fd, oldpos, SEEK_SET); +#endif /* HAVE_POSIX_FALLOCATE */ -+ if (r < 0) { - log_error("Failed to allocate sequential number file, ignoring: %m"); ++ if (r < 0) { + log_error_errno(errno, "Failed to allocate sequential number file, ignoring: %m"); return 0; } --- -1.7.9.5 - |