summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/uclibc/uclibc-0.9.33/posix_fallocate.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/uclibc/uclibc-0.9.33/posix_fallocate.patch')
-rw-r--r--meta/recipes-core/uclibc/uclibc-0.9.33/posix_fallocate.patch407
1 files changed, 0 insertions, 407 deletions
diff --git a/meta/recipes-core/uclibc/uclibc-0.9.33/posix_fallocate.patch b/meta/recipes-core/uclibc/uclibc-0.9.33/posix_fallocate.patch
deleted file mode 100644
index b55fbbd6e0..0000000000
--- a/meta/recipes-core/uclibc/uclibc-0.9.33/posix_fallocate.patch
+++ /dev/null
@@ -1,407 +0,0 @@
1Delivered-To: raj.khem@gmail.com
2Received: by 10.152.129.134 with SMTP id nw6csp47712lab;
3 Tue, 17 Apr 2012 00:30:48 -0700 (PDT)
4Received: by 10.68.216.167 with SMTP id or7mr34112133pbc.140.1334647840512;
5 Tue, 17 Apr 2012 00:30:40 -0700 (PDT)
6Return-Path: <uclibc-bounces@uclibc.org>
7Received: from hemlock.osuosl.org (hemlock.osuosl.org. [140.211.166.133])
8 by mx.google.com with ESMTP id gr10si13305623pbc.339.2012.04.17.00.30.39;
9 Tue, 17 Apr 2012 00:30:40 -0700 (PDT)
10Received-SPF: neutral (google.com: 140.211.166.133 is neither permitted nor denied by best guess record for domain of uclibc-bounces@uclibc.org) client-ip=140.211.166.133;
11Authentication-Results: mx.google.com; spf=neutral (google.com: 140.211.166.133 is neither permitted nor denied by best guess record for domain of uclibc-bounces@uclibc.org) smtp.mail=uclibc-bounces@uclibc.org; dkim=neutral (body hash did not verify) header.i=@gmail.com
12Received: from localhost (localhost [127.0.0.1])
13 by hemlock.osuosl.org (Postfix) with ESMTP id 7C494A0277;
14 Tue, 17 Apr 2012 07:30:39 +0000 (UTC)
15X-Virus-Scanned: amavisd-new at osuosl.org
16Received: from hemlock.osuosl.org ([127.0.0.1])
17 by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)
18 with ESMTP id ZsSp5xE48GwC; Tue, 17 Apr 2012 07:30:34 +0000 (UTC)
19Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34])
20 by hemlock.osuosl.org (Postfix) with ESMTP id 1C4F5A0274;
21 Tue, 17 Apr 2012 07:30:33 +0000 (UTC)
22X-Original-To: uclibc@lists.busybox.net
23Delivered-To: uclibc@osuosl.org
24Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137])
25 by ash.osuosl.org (Postfix) with ESMTP id 17FDE8F75B
26 for <uclibc@lists.busybox.net>; Tue, 17 Apr 2012 07:30:32 +0000 (UTC)
27Received: from localhost (localhost [127.0.0.1])
28 by fraxinus.osuosl.org (Postfix) with ESMTP id 07B491016A1
29 for <uclibc@lists.busybox.net>; Tue, 17 Apr 2012 07:30:32 +0000 (UTC)
30X-Virus-Scanned: amavisd-new at osuosl.org
31Received: from fraxinus.osuosl.org ([127.0.0.1])
32 by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)
33 with ESMTP id XKP7jhcUijp4 for <uclibc@lists.busybox.net>;
34 Tue, 17 Apr 2012 07:30:27 +0000 (UTC)
35X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6
36Received: from mail-we0-f174.google.com (mail-we0-f174.google.com
37 [74.125.82.174])
38 by fraxinus.osuosl.org (Postfix) with ESMTPS id 2CC0B100190
39 for <uclibc@uclibc.org>; Tue, 17 Apr 2012 07:30:26 +0000 (UTC)
40Received: by wejx9 with SMTP id x9so5218587wej.33
41 for <uclibc@uclibc.org>; Tue, 17 Apr 2012 00:30:25 -0700 (PDT)
42DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
43 h=from:to:cc:subject:date:message-id:x-mailer;
44 bh=vadTQ1GL81XLDadHLtwCrcdL0YvVNNbIuISfTaQphgg=;
45 b=KkyW95PC1TUTmwGt+iBJ8p0FfGtTPAsTlXmul/1iH2p21itEpWkU+WcVd2jBH+jc6L
46 gzf4d6K1pmmfscdbPY3OkpFfvO/v/E4KYN7JmeI+fX1NY+gLBSHhExAVhM1Opue9z09V
47 54MrEMtlIA9Wo/5QPd1+W7o9gXHYEnMkoqYYZLmfPlG3+pCXZ6RP36fOZnSV44BQgOFz
48 KBqn7XLo6nxgP5X/+JuEe4stvCrI9/66nX30u/Sh77a9poj5pp8hQZmtIpbbm3xRKGnM
49 Fi72jNCq/0nHh3M7eMqn+rvwi1JQjk/90zWNv8v5ShAKqSJVrfqLVN72KjTJtXfLOqbL
50 e2qA==
51Received: by 10.216.133.72 with SMTP id p50mr8903959wei.78.1334647825412;
52 Tue, 17 Apr 2012 00:30:25 -0700 (PDT)
53Received: from s42.loc (85-127-86-115.dynamic.xdsl-line.inode.at.
54 [85.127.86.115])
55 by mx.google.com with ESMTPS id n20sm40466274wiw.5.2012.04.17.00.30.23
56 (version=TLSv1/SSLv3 cipher=OTHER);
57 Tue, 17 Apr 2012 00:30:24 -0700 (PDT)
58Received: from cow by s42.loc with local (Exim 4.77)
59 (envelope-from <rep.dot.nop@gmail.com>)
60 id 1SK2rm-0008Pl-V3; Tue, 17 Apr 2012 09:30:23 +0200
61From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
62To: uclibc@uclibc.org
63Subject: [PATCH,CFT] libc: add posix_fallocate()
64Date: Tue, 17 Apr 2012 09:30:15 +0200
65Message-Id: <1334647815-32315-1-git-send-email-rep.dot.nop@gmail.com>
66X-Mailer: git-send-email 1.7.9.1
67X-BeenThere: uclibc@uclibc.org
68X-Mailman-Version: 2.1.14
69Precedence: list
70List-Id: "Discussion and development of uClibc \(the embedded C library\)"
71 <uclibc.uclibc.org>
72List-Unsubscribe: <http://lists.busybox.net/mailman/options/uclibc>,
73 <mailto:uclibc-request@uclibc.org?subject=unsubscribe>
74List-Archive: <http://lists.busybox.net/pipermail/uclibc>
75List-Post: <mailto:uclibc@uclibc.org>
76List-Help: <mailto:uclibc-request@uclibc.org?subject=help>
77List-Subscribe: <http://lists.busybox.net/mailman/listinfo/uclibc>,
78 <mailto:uclibc-request@uclibc.org?subject=subscribe>
79MIME-Version: 1.0
80Content-Type: text/plain; charset="us-ascii"
81Content-Transfer-Encoding: 7bit
82Errors-To: uclibc-bounces@uclibc.org
83Sender: uclibc-bounces@uclibc.org
84
85Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
86Upstream-Status: Pending
87---
88 include/fcntl.h | 4 +-
89 libc/sysdeps/linux/common/Makefile.in | 3 +-
90 libc/sysdeps/linux/common/bits/kernel-features.h | 8 ++
91 libc/sysdeps/linux/common/posix_fallocate.c | 43 ++++++++
92 libc/sysdeps/linux/common/posix_fallocate64.c | 39 +++++++
93 libc/sysdeps/linux/common/stubs.c | 4 +
94 test/.gitignore | 1 +
95 test/unistd/Makefile.in | 3 +
96 test/unistd/tst-posix_fallocate.c | 121 ++++++++++++++++++++++
97 9 files changed, 222 insertions(+), 4 deletions(-)
98 create mode 100644 libc/sysdeps/linux/common/posix_fallocate.c
99 create mode 100644 libc/sysdeps/linux/common/posix_fallocate64.c
100 create mode 100644 test/unistd/tst-posix_fallocate.c
101
102Index: git/include/fcntl.h
103===================================================================
104--- git.orig/include/fcntl.h 2012-09-02 17:00:26.000000000 -0700
105+++ git/include/fcntl.h 2012-09-02 17:01:51.567076705 -0700
106@@ -210,9 +210,7 @@
107
108 #endif
109
110-#if 0 /* && defined __UCLIBC_HAS_ADVANCED_REALTIME__ */
111-
112-/* FIXME -- uClibc should probably implement these... */
113+#if defined __UCLIBC_HAS_ADVANCED_REALTIME__
114
115 /* Reserve storage for the data of the file associated with FD.
116
117Index: git/libc/sysdeps/linux/common/Makefile.in
118===================================================================
119--- git.orig/libc/sysdeps/linux/common/Makefile.in 2012-09-02 17:00:26.000000000 -0700
120+++ git/libc/sysdeps/linux/common/Makefile.in 2012-09-02 17:03:02.739079369 -0700
121@@ -81,7 +81,7 @@
122 sched_get_priority_max.c sched_get_priority_min.c sched_getscheduler.c \
123 sched_rr_get_interval.c sched_setparam.c sched_setscheduler.c sigqueue.c
124 # clock_getcpuclockid|clock_nanosleep|mq_timedreceive|mq_timedsend|posix_fadvise|posix_fallocate|posix_madvise|posix_memalign|posix_mem_offset|posix_spawnattr_destroy|posix_spawnattr_init|posix_spawnattr_getflags|posix_spawnattr_setflags|posix_spawnattr_getpgroup|posix_spawnattr_setpgroup|posix_spawnattr_getschedparam|posix_spawnattr_setschedparam|posix_spawnattr_getschedpolicy|posix_spawnattr_setschedpolicy|posix_spawnattr_getsigdefault|posix_spawnattr_setsigdefault|posix_spawnattr_getsigmask|posix_spawnattr_setsigmask|posix_spawnattr_init|posix_spawnattr_setflags|posix_spawnattr_setpgroup|posix_spawnattr_setschedparam|posix_spawnattr_setschedpolicy|posix_spawnattr_setsigdefault|posix_spawnattr_setsigmask|posix_spawn_file_actions_addclose|posix_spawn_file_actions_addopen|posix_spawn_file_actions_adddup2|posix_spawn_file_actions_addopen|posix_spawn_file_actions_destroy|posix_spawn_file_actions_init|posix_spawn_file_actions_init|posix_spawn|posix_spawnp|posix_spawnp|posix_typed_mem_get_info|pthread_mutex_timedlock|sem_timedwait
125-CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c posix_madvise.c
126+CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c posix_madvise.c posix_fallocate.c posix_fallocate64.c
127 CSRC-$(UCLIBC_SUSV4_LEGACY) += utime.c
128 CSRC-$(UCLIBC_HAS_EPOLL) += epoll.c
129 CSRC-$(UCLIBC_HAS_XATTR) += xattr.c
130Index: git/libc/sysdeps/linux/common/bits/kernel-features.h
131===================================================================
132--- git.orig/libc/sysdeps/linux/common/bits/kernel-features.h 2012-09-02 17:00:26.000000000 -0700
133+++ git/libc/sysdeps/linux/common/bits/kernel-features.h 2012-09-02 17:01:51.567076705 -0700
134@@ -494,6 +494,14 @@
135 # define __ASSUME_PRIVATE_FUTEX 1
136 #endif
137
138+/* Support for fallocate was added in 2.6.23,
139+ on s390 only after 2.6.23-rc1, on alpha only after 2.6.33-rc1. */
140+#if __LINUX_KERNEL_VERSION >= 0x020617 \
141+ && (!defined __s390__ || __LINUX_KERNEL_VERSION >= 0x020618) \
142+ && (!defined __alpha__ || __LINUX_KERNEL_VERSION >= 0x020621)
143+# define __ASSUME_FALLOCATE 1
144+#endif
145+
146 /* getcpu is a syscall for x86-64 since 3.1. */
147 #if defined __x86_64__ && __LINUX_KERNEL_VERSION >= 0x030100
148 # define __ASSUME_GETCPU_SYSCALL 1
149Index: git/libc/sysdeps/linux/common/posix_fallocate.c
150===================================================================
151--- /dev/null 1970-01-01 00:00:00.000000000 +0000
152+++ git/libc/sysdeps/linux/common/posix_fallocate.c 2012-09-02 17:01:51.579076667 -0700
153@@ -0,0 +1,43 @@
154+/* vi: set sw=4 ts=4: */
155+/*
156+ * posix_fallocate() for uClibc
157+ * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
158+ *
159+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
160+ *
161+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
162+ */
163+
164+#include <sys/syscall.h>
165+#include <fcntl.h>
166+#include <bits/kernel-features.h>
167+#include <stdint.h>
168+
169+#if defined __NR_fallocate
170+int posix_fallocate(int fd, __off_t offset, __off_t len)
171+{
172+ int ret;
173+
174+# if __WORDSIZE == 32
175+ uint32_t off_low = offset;
176+ uint32_t len_low = len;
177+ /* may assert that these >>31 are 0 */
178+ uint32_t zero = 0;
179+ INTERNAL_SYSCALL_DECL(err);
180+ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, 0,
181+ __LONG_LONG_PAIR (zero, off_low),
182+ __LONG_LONG_PAIR (zero, len_low)));
183+# elif __WORDSIZE == 64
184+ INTERNAL_SYSCALL_DECL(err);
185+ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 4, fd, 0, offset, len));
186+# else
187+# error your machine is neither 32 bit or 64 bit ... it must be magical
188+#endif
189+ if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err)))
190+ return INTERNAL_SYSCALL_ERRNO (ret, err);
191+ return 0;
192+}
193+# if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
194+strong_alias(posix_fallocate,posix_fallocate64)
195+# endif
196+#endif
197Index: git/libc/sysdeps/linux/common/posix_fallocate64.c
198===================================================================
199--- /dev/null 1970-01-01 00:00:00.000000000 +0000
200+++ git/libc/sysdeps/linux/common/posix_fallocate64.c 2012-09-02 17:01:51.579076667 -0700
201@@ -0,0 +1,39 @@
202+/* vi: set sw=4 ts=4: */
203+/*
204+ * posix_fallocate() for uClibc
205+ * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
206+ *
207+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
208+ *
209+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
210+ */
211+
212+#include <sys/syscall.h>
213+#include <fcntl.h>
214+#include <bits/kernel-features.h>
215+#include <stdint.h>
216+
217+#if defined __NR_fallocate
218+
219+# if __WORDSIZE == 64
220+/* Can use normal posix_fallocate() */
221+# elif __WORDSIZE == 32
222+int posix_fallocate64(int fd, __off64_t offset, __off64_t len)
223+{
224+ int ret;
225+ uint32_t off_low = offset & 0xffffffff;
226+ uint32_t off_high = offset >> 32;
227+ uint32_t len_low = len & 0xffffffff;
228+ uint32_t len_high = len >> 32;
229+ INTERNAL_SYSCALL_DECL(err);
230+ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, 0,
231+ __LONG_LONG_PAIR (off_high, off_low),
232+ __LONG_LONG_PAIR (len_high, len_low)));
233+ if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err)))
234+ return INTERNAL_SYSCALL_ERRNO (ret, err);
235+ return 0;
236+}
237+# else
238+# error your machine is neither 32 bit or 64 bit ... it must be magical
239+# endif
240+#endif
241Index: git/libc/sysdeps/linux/common/stubs.c
242===================================================================
243--- git.orig/libc/sysdeps/linux/common/stubs.c 2012-09-02 17:00:26.000000000 -0700
244+++ git/libc/sysdeps/linux/common/stubs.c 2012-09-02 17:01:51.579076667 -0700
245@@ -209,6 +209,10 @@
246 make_stub(madvise)
247 #endif
248
249+#if !defined __NR_fallocate && defined __UCLIBC_HAS_ADVANCED_REALTIME__
250+make_ret_stub(posix_fallocate)
251+#endif
252+
253 #if !defined __NR_modify_ldt && defined __UCLIBC_LINUX_SPECIFIC__
254 make_stub(modify_ldt)
255 #endif
256Index: git/test/.gitignore
257===================================================================
258--- git.orig/test/.gitignore 2012-09-02 17:00:26.000000000 -0700
259+++ git/test/.gitignore 2012-09-02 17:01:51.579076667 -0700
260@@ -302,6 +302,7 @@
261 unistd/getopt
262 unistd/getopt_long
263 unistd/tstgetopt
264+unistd/tst-posix_fallocate
265 unistd/tst-preadwrite
266 unistd/tst-preadwrite64
267 unistd/vfork
268Index: git/test/unistd/Makefile.in
269===================================================================
270--- git.orig/test/unistd/Makefile.in 2012-09-02 17:00:26.000000000 -0700
271+++ git/test/unistd/Makefile.in 2012-09-02 17:01:51.579076667 -0700
272@@ -4,6 +4,9 @@
273 ifeq ($(UCLIBC_HAS_LFS),)
274 TESTS_DISABLED := tst-preadwrite64
275 endif
276+ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),)
277+TESTS_DISABLED := tst-posix_fallocate
278+endif
279 OPTS_getopt := -abcXXX -9
280 OPTS_getopt_long := --add XXX --delete YYY --verbose
281 ifeq ($(UCLIBC_HAS_GNU_GETOPT),y)
282Index: git/test/unistd/tst-posix_fallocate.c
283===================================================================
284--- /dev/null 1970-01-01 00:00:00.000000000 +0000
285+++ git/test/unistd/tst-posix_fallocate.c 2012-09-02 17:01:51.579076667 -0700
286@@ -0,0 +1,121 @@
287+#include <fcntl.h>
288+#include <sys/stat.h>
289+
290+static void do_prepare (void);
291+#define PREPARE(argc, argv) do_prepare ()
292+static int do_test (void);
293+#define TEST_FUNCTION do_test ()
294+#include <test-skeleton.c>
295+
296+static int fd;
297+#ifndef O_LARGEFILE
298+# error no O_LARGEFILE
299+#endif
300+static void
301+do_prepare (void)
302+{
303+ fd = create_temp_file ("tst-posix_fallocate.", NULL);
304+ if (fd == -1)
305+ {
306+ printf ("cannot create temporary file: %m\n");
307+ exit (1);
308+ }
309+}
310+
311+
312+static int
313+do_test (void)
314+{
315+ struct stat64 st;
316+
317+ if (fstat64 (fd, &st) != 0)
318+ {
319+ puts ("1st fstat failed");
320+ return 1;
321+ }
322+
323+ if (st.st_size != 0)
324+ {
325+ puts ("file not created with size 0");
326+ return 1;
327+ }
328+
329+ if (posix_fallocate (fd, 512, 768) != 0)
330+ {
331+ puts ("1st posix_fallocate call failed");
332+ return 1;
333+ }
334+
335+ if (fstat64 (fd, &st) != 0)
336+ {
337+ puts ("2nd fstat failed");
338+ return 1;
339+ }
340+
341+ if (st.st_size != 512 + 768)
342+ {
343+ printf ("file size after 1st posix_fallocate call is %llu, expected %u\n",
344+ (unsigned long long int) st.st_size, 512u + 768u);
345+ return 1;
346+ }
347+
348+ if (posix_fallocate (fd, 0, 1024) != 0)
349+ {
350+ puts ("2nd posix_fallocate call failed");
351+ return 1;
352+ }
353+
354+ if (fstat64 (fd, &st) != 0)
355+ {
356+ puts ("3rd fstat failed");
357+ return 1;
358+ }
359+
360+ if (st.st_size != 512 + 768)
361+ {
362+ puts ("file size changed in 2nd posix_fallocate");
363+ return 1;
364+ }
365+
366+ if (posix_fallocate (fd, 2048, 64) != 0)
367+ {
368+ puts ("3rd posix_fallocate call failed");
369+ return 1;
370+ }
371+
372+ if (fstat64 (fd, &st) != 0)
373+ {
374+ puts ("4th fstat failed");
375+ return 1;
376+ }
377+
378+ if (st.st_size != 2048 + 64)
379+ {
380+ printf ("file size after 3rd posix_fallocate call is %llu, expected %u\n",
381+ (unsigned long long int) st.st_size, 2048u + 64u);
382+ return 1;
383+ }
384+
385+ if (posix_fallocate64 (fd, 4097ULL, 4294967295ULL + 2ULL) != 0)
386+ {
387+ puts ("4th posix_fallocate call failed");
388+ return 1;
389+ }
390+
391+ if (fstat64 (fd, &st) != 0)
392+ {
393+ puts ("5th fstat failed");
394+ return 1;
395+ }
396+
397+ if (st.st_size != 4097ULL + 4294967295ULL + 2ULL)
398+ {
399+ printf ("file size after 4th posix_fallocate call is %llu, expected %u\n",
400+ (unsigned long long int) st.st_size, 4097ULL + 4294967295ULL + 2ULL);
401+ return 1;
402+ }
403+
404+ close (fd);
405+
406+ return 0;
407+}