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.patch84
1 files changed, 84 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 0000000..de73be9
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch
@@ -0,0 +1,84 @@
1Upstream-Status: Denied [no desire for uclibc support]
2Signed-off-by: Khem Raj <raj.khem@gmail.com>
3
4Index: systemd-209/src/journal/journal-file.c
5===================================================================
6--- systemd-209.orig/src/journal/journal-file.c 2014-02-12 18:42:33.000000000 -0800
7+++ systemd-209/src/journal/journal-file.c 2014-02-19 23:23:19.464631643 -0800
8@@ -38,6 +38,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@@ -316,7 +318,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@@ -364,9 +366,24 @@
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+#else
35+ /* Use good old method to write zeros into the journal file
36+ perhaps very inefficient yet working. */
37+ if(new_size > old_size) {
38+ char *buf = alloca(new_size - old_size);
39+ off_t oldpos = lseek(f->fd, 0, SEEK_CUR);
40+ bzero(buf, new_size - old_size);
41+ lseek(f->fd, old_size, SEEK_SET);
42+ r = write(f->fd, buf, new_size - old_size);
43+ lseek(f->fd, oldpos, SEEK_SET);
44+ }
45+ if (r < 0)
46+ return -errno;
47+#endif /* HAVE_POSIX_FALLOCATE */
48
49 if (fstat(f->fd, &f->last_stat) < 0)
50 return -errno;
51Index: systemd-209/src/journal/journald-kmsg.c
52===================================================================
53--- systemd-209.orig/src/journal/journald-kmsg.c 2014-02-19 15:03:09.000000000 -0800
54+++ systemd-209/src/journal/journald-kmsg.c 2014-02-19 23:22:14.396630422 -0800
55@@ -441,6 +441,7 @@
56
57 int server_open_kernel_seqnum(Server *s) {
58 int fd;
59+ int r = 0;
60 uint64_t *p;
61
62 assert(s);
63@@ -454,8 +455,19 @@
64 log_error("Failed to open /run/systemd/journal/kernel-seqnum, ignoring: %m");
65 return 0;
66 }
67-
68- if (posix_fallocate(fd, 0, sizeof(uint64_t)) < 0) {
69+#ifdef HAVE_POSIX_ALLOCATE
70+ r = posix_fallocate(fd, 0, sizeof(uint64_t));
71+#else
72+ /* Use good old method to write zeros into the journal file
73+ perhaps very inefficient yet working. */
74+ char *buf = alloca(sizeof(uint64_t));
75+ off_t oldpos = lseek(fd, 0, SEEK_CUR);
76+ bzero(buf, sizeof(uint64_t));
77+ lseek(fd, 0, SEEK_SET);
78+ r = write(fd, buf, sizeof(uint64_t));
79+ lseek(fd, oldpos, SEEK_SET);
80+#endif /* HAVE_POSIX_FALLOCATE */
81+ if (r < 0) {
82 log_error("Failed to allocate sequential number file, ignoring: %m");
83 close_nointr_nofail(fd);
84 return 0;