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