b7ead76cffcf29a9fd09961b5f9804a60b0910be
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / f2fs-tools / 0001-configure-add-check-for-fallocate.patch
1 From 265d97d02e8ef373653c76a339869985eb3ba27a Mon Sep 17 00:00:00 2001
2 From: Gustavo Zacarias <gustavo@zacarias.com.ar>
3 Date: Tue, 10 Mar 2015 15:10:35 -0300
4 Subject: [PATCH] configure: add check for fallocate
5
6 We need to check for fallocate() rather than just linux/falloc.h +
7 FALLOC_FL_PUNCH_HOLE since in uClibc we've got both but still not
8 fallocate() itself since it's only implemented in newer unreleased
9 versions.
10
11 Status: sent upstream.
12
13 Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
14 ---
15  configure.ac             | 1 +
16  mkfs/f2fs_format_utils.c | 2 +-
17  2 files changed, 2 insertions(+), 1 deletion(-)
18
19 diff --git a/configure.ac b/configure.ac
20 index ae451b8..900b84a 100644
21 --- a/configure.ac
22 +++ b/configure.ac
23 @@ -68,6 +68,7 @@ AC_TYPE_SIZE_T
24  # Checks for library functions.
25  AC_FUNC_GETMNTENT
26  AC_CHECK_FUNCS_ONCE([
27 +       fallocate
28         getmntent
29         memset
30  ])
31 diff --git a/mkfs/f2fs_format_utils.c b/mkfs/f2fs_format_utils.c
32 index a0f85f5..ddeafeb 100644
33 --- a/mkfs/f2fs_format_utils.c
34 +++ b/mkfs/f2fs_format_utils.c
35 @@ -46,7 +46,7 @@ int f2fs_trim_device()
36  #if defined(WITH_BLKDISCARD) && defined(BLKDISCARD)
37         MSG(0, "Info: Discarding device\n");
38         if (S_ISREG(stat_buf.st_mode)) {
39 -#ifdef FALLOC_FL_PUNCH_HOLE
40 +#if defined(HAVE_FALLOCATE) && defined(FALLOC_FL_PUNCH_HOLE)
41                 if (fallocate(config.fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
42                                 range[0], range[1]) < 0) {
43                         MSG(0, "Info: fallocate(PUNCH_HOLE|KEEP_SIZE) is failed\n");
44 -- 
45 2.0.5
46