summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch
diff options
context:
space:
mode:
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.patch82
1 files changed, 82 insertions, 0 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
new file mode 100644
index 0000000000..089ba64690
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch
@@ -0,0 +1,82 @@
1Index: git/src/journal/journal-file.c
2===================================================================
3--- git.orig/src/journal/journal-file.c 2012-09-02 09:49:15.126089594 -0700
4+++ git/src/journal/journal-file.c 2012-09-02 09:49:17.118089670 -0700
5@@ -34,6 +34,8 @@
6 #include "compress.h"
7 #include "fsprg.h"
8
9+#include "config.h"
10+
11 #define DEFAULT_DATA_HASH_TABLE_SIZE (2047ULL*sizeof(HashItem))
12 #define DEFAULT_FIELD_HASH_TABLE_SIZE (333ULL*sizeof(HashItem))
13
14@@ -262,7 +264,7 @@
15
16 static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) {
17 uint64_t old_size, new_size;
18- int r;
19+ int r = 0;
20
21 assert(f);
22
23@@ -307,10 +309,25 @@
24 /* Note that the glibc fallocate() fallback is very
25 inefficient, hence we try to minimize the allocation area
26 as we can. */
27+#ifdef HAVE_POSIX_ALLOCATE
28 r = posix_fallocate(f->fd, old_size, new_size - old_size);
29 if (r != 0)
30 return -r;
31
32+#else
33+ /* Use good old method to write zeros into the journal file
34+ perhaps very inefficient yet working. */
35+ if(new_size > old_size) {
36+ char *buf = alloca(new_size - old_size);
37+ off_t oldpos = lseek(f->fd, 0, SEEK_CUR);
38+ bzero(buf, new_size - old_size);
39+ lseek(f->fd, old_size, SEEK_SET);
40+ r = write(f->fd, buf, new_size - old_size);
41+ lseek(f->fd, oldpos, SEEK_SET);
42+ }
43+ if (r < 0)
44+ return -errno;
45+#endif /* HAVE_POSIX_FALLOCATE */
46 if (fstat(f->fd, &f->last_stat) < 0)
47 return -errno;
48
49Index: git/src/journal/journald-kmsg.c
50===================================================================
51--- git.orig/src/journal/journald-kmsg.c 2012-09-02 09:49:15.130089595 -0700
52+++ git/src/journal/journald-kmsg.c 2012-09-02 12:26:17.326447895 -0700
53@@ -404,6 +404,7 @@
54
55 int server_open_kernel_seqnum(Server *s) {
56 int fd;
57+ int r = 0;
58 uint64_t *p;
59
60 assert(s);
61@@ -417,8 +418,19 @@
62 log_error("Failed to open /run/systemd/journal/kernel-seqnum, ignoring: %m");
63 return 0;
64 }
65-
66- if (posix_fallocate(fd, 0, sizeof(uint64_t)) < 0) {
67+#ifdef HAVE_POSIX_ALLOCATE
68+ r = posix_fallocate(fd, 0, sizeof(uint64_t));
69+#else
70+ /* Use good old method to write zeros into the journal file
71+ perhaps very inefficient yet working. */
72+ char *buf = alloca(sizeof(uint64_t));
73+ off_t oldpos = lseek(fd, 0, SEEK_CUR);
74+ bzero(buf, sizeof(uint64_t));
75+ lseek(fd, 0, SEEK_SET);
76+ r = write(fd, buf, sizeof(uint64_t));
77+ lseek(fd, oldpos, SEEK_SET);
78+#endif /* HAVE_POSIX_FALLOCATE */
79+ if (r < 0) {
80 log_error("Failed to allocate sequential number file, ignoring: %m");
81 close_nointr_nofail(fd);
82 return 0;