diff options
author | Tudor Florea <tudor.florea@enea.com> | 2015-10-09 22:59:03 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2015-10-09 22:59:03 +0200 |
commit | 972dcfcdbfe75dcfeb777150c136576cf1a71e99 (patch) | |
tree | 97a61cd7e293d7ae9d56ef7ed0f81253365bb026 /meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch | |
download | poky-972dcfcdbfe75dcfeb777150c136576cf1a71e99.tar.gz |
initial commit for Enea Linux 5.0 arm
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
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 | 92 |
1 files changed, 92 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..f8e19ce172 --- /dev/null +++ b/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch | |||
@@ -0,0 +1,92 @@ | |||
1 | Upstream-Status: Denied [no desire for uclibc support] | ||
2 | |||
3 | This patch is uclibc specific, thus not suitable for upstream. | ||
4 | |||
5 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
6 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> | ||
7 | --- | ||
8 | src/journal/journal-file.c | 16 +++++++++++++++- | ||
9 | src/journal/journald-kmsg.c | 16 ++++++++++++++-- | ||
10 | 2 files changed, 29 insertions(+), 3 deletions(-) | ||
11 | |||
12 | diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c | ||
13 | index f2f1f35..092f87b 100644 | ||
14 | --- a/src/journal/journal-file.c | ||
15 | +++ b/src/journal/journal-file.c | ||
16 | @@ -38,6 +38,8 @@ | ||
17 | #include "compress.h" | ||
18 | #include "fsprg.h" | ||
19 | |||
20 | +#include "config.h" | ||
21 | + | ||
22 | #define DEFAULT_DATA_HASH_TABLE_SIZE (2047ULL*sizeof(HashItem)) | ||
23 | #define DEFAULT_FIELD_HASH_TABLE_SIZE (333ULL*sizeof(HashItem)) | ||
24 | |||
25 | @@ -314,7 +316,7 @@ static int journal_file_verify_header(JournalFile *f) { | ||
26 | |||
27 | static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) { | ||
28 | uint64_t old_size, new_size; | ||
29 | - int r; | ||
30 | + int r = 0; | ||
31 | |||
32 | assert(f); | ||
33 | |||
34 | @@ -362,9 +364,21 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) | ||
35 | /* Note that the glibc fallocate() fallback is very | ||
36 | inefficient, hence we try to minimize the allocation area | ||
37 | as we can. */ | ||
38 | +#ifdef HAVE_POSIX_FALLOCATE | ||
39 | r = posix_fallocate(f->fd, old_size, new_size - old_size); | ||
40 | if (r != 0) | ||
41 | return -r; | ||
42 | +#else | ||
43 | + /* Write something every 512 bytes to make sure the block is allocated */ | ||
44 | + uint64_t len = new_size - old_size; | ||
45 | + uint64_t offset = old_size; | ||
46 | + for (offset += (len-1) % 512; len > 0; offset += 512) { | ||
47 | + len -= 512; | ||
48 | + if (pwrite(f->fd, "", 1, offset) != 1) | ||
49 | + return -errno; | ||
50 | + } | ||
51 | + | ||
52 | +#endif /* HAVE_POSIX_FALLOCATE */ | ||
53 | |||
54 | if (fstat(f->fd, &f->last_stat) < 0) | ||
55 | return -errno; | ||
56 | diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c | ||
57 | index 12992e7..dc4fa93 100644 | ||
58 | --- a/src/journal/journald-kmsg.c | ||
59 | +++ b/src/journal/journald-kmsg.c | ||
60 | @@ -437,6 +437,7 @@ fail: | ||
61 | int server_open_kernel_seqnum(Server *s) { | ||
62 | _cleanup_close_ int fd; | ||
63 | uint64_t *p; | ||
64 | + int r = 0; | ||
65 | |||
66 | assert(s); | ||
67 | |||
68 | @@ -449,8 +450,19 @@ int server_open_kernel_seqnum(Server *s) { | ||
69 | log_error("Failed to open /run/systemd/journal/kernel-seqnum, ignoring: %m"); | ||
70 | return 0; | ||
71 | } | ||
72 | - | ||
73 | - if (posix_fallocate(fd, 0, sizeof(uint64_t)) < 0) { | ||
74 | +#ifdef HAVE_POSIX_FALLOCATE | ||
75 | + r = posix_fallocate(fd, 0, sizeof(uint64_t)); | ||
76 | +#else | ||
77 | + /* Use good old method to write zeros into the journal file | ||
78 | + perhaps very inefficient yet working. */ | ||
79 | + char *buf = alloca(sizeof(uint64_t)); | ||
80 | + off_t oldpos = lseek(fd, 0, SEEK_CUR); | ||
81 | + bzero(buf, sizeof(uint64_t)); | ||
82 | + lseek(fd, 0, SEEK_SET); | ||
83 | + r = write(fd, buf, sizeof(uint64_t)); | ||
84 | + lseek(fd, oldpos, SEEK_SET); | ||
85 | +#endif /* HAVE_POSIX_FALLOCATE */ | ||
86 | + if (r < 0) { | ||
87 | log_error("Failed to allocate sequential number file, ignoring: %m"); | ||
88 | return 0; | ||
89 | } | ||
90 | -- | ||
91 | 1.7.9.5 | ||
92 | |||