The cirros image was rebuilt against the 3.13.0-83 kernel, drivers e1000e, igbvf...
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / uclibc / 0.9.33.2 / 0034-statfs-support-f_frsize.patch
1 From 479f8407c4822d2b872afb8bb14e5ab596714744 Mon Sep 17 00:00:00 2001
2 From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
3 Date: Thu, 17 Jan 2013 22:44:00 +0100
4 Subject: [PATCH] statfs: support f_frsize
5
6 closes bugzilla #5834
7
8 Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
9 ---
10  libc/misc/statfs/fstatfs64.c        |    3 +++
11  libc/misc/statfs/internal_statvfs.c |    8 ++++++--
12  libc/misc/statfs/statfs64.c         |    3 +++
13  test/.gitignore                     |    3 +++
14  test/misc/Makefile.in               |    6 ++++++
15  test/misc/tst-statfs.c              |   33 +++++++++++++++++++++++++++++++++
16  test/misc/tst-statvfs.c             |   28 ++++++++++++++++++++++++++++
17  7 files changed, 82 insertions(+), 2 deletions(-)
18  create mode 100644 test/misc/tst-statfs.c
19  create mode 100644 test/misc/tst-statvfs.c
20
21 diff --git a/libc/misc/statfs/fstatfs64.c b/libc/misc/statfs/fstatfs64.c
22 index 27bb8d6..42df1ae 100644
23 --- a/libc/misc/statfs/fstatfs64.c
24 +++ b/libc/misc/statfs/fstatfs64.c
25 @@ -43,6 +43,9 @@ int fstatfs64 (int fd, struct statfs64 *buf)
26      buf->f_files = buf32.f_files;
27      buf->f_ffree = buf32.f_ffree;
28      buf->f_fsid = buf32.f_fsid;
29 +#ifdef _STATFS_F_FRSIZE
30 +    buf->f_frsize = buf32.f_frsize;
31 +#endif
32      buf->f_namelen = buf32.f_namelen;
33      memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
34  
35 diff --git a/libc/misc/statfs/internal_statvfs.c b/libc/misc/statfs/internal_statvfs.c
36 index 6075e9c..c1862b5 100644
37 --- a/libc/misc/statfs/internal_statvfs.c
38 +++ b/libc/misc/statfs/internal_statvfs.c
39 @@ -19,8 +19,12 @@
40  
41    /* Now fill in the fields we have information for.  */
42    buf->f_bsize = fsbuf.f_bsize;
43 -  /* Linux does not support f_frsize, so set it to the full block size.  */
44 +#ifdef _STATFS_F_FRSIZE
45 +  buf->f_frsize = fsbuf.f_frsize;
46 +#else
47 +  /* No support for f_frsize so set it to the full block size.  */
48    buf->f_frsize = fsbuf.f_bsize;
49 +#endif
50    buf->f_blocks = fsbuf.f_blocks;
51    buf->f_bfree = fsbuf.f_bfree;
52    buf->f_bavail = fsbuf.f_bavail;
53 @@ -39,7 +43,7 @@
54    buf->__f_unused = 0;
55  #endif
56    buf->f_namemax = fsbuf.f_namelen;
57 -  memset (buf->__f_spare, '\0', 6 * sizeof (int));
58 +  memset (buf->__f_spare, '\0', sizeof(buf->__f_spare));
59  
60    /* What remains to do is to fill the fields f_favail and f_flag.  */
61  
62 diff --git a/libc/misc/statfs/statfs64.c b/libc/misc/statfs/statfs64.c
63 index 0cc8595..35329bd 100644
64 --- a/libc/misc/statfs/statfs64.c
65 +++ b/libc/misc/statfs/statfs64.c
66 @@ -42,6 +42,9 @@ int statfs64 (const char *file, struct statfs64 *buf)
67      buf->f_ffree = buf32.f_ffree;
68      buf->f_fsid = buf32.f_fsid;
69      buf->f_namelen = buf32.f_namelen;
70 +#ifdef _STATFS_F_FRSIZE
71 +    buf->f_frsize = buf32.f_frsize;
72 +#endif
73      memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
74  
75      return 0;
76 diff --git a/test/.gitignore b/test/.gitignore
77 index c892816..7234c48 100644
78 --- a/test/.gitignore
79 +++ b/test/.gitignore
80 @@ -148,6 +148,8 @@ misc/sem
81  misc/stdarg
82  misc/tst-scandir
83  misc/tst-seekdir
84 +misc/tst-statfs
85 +misc/tst-statvfs
86  misc/tst-utmp
87  mmap/mmap
88  mmap/mmap2
89 @@ -254,6 +256,7 @@ stdio/64bit
90  stdio/fclose-loop
91  stdlib/ptytest
92  stdlib/qsort
93 +stdlib/testarc4random
94  stdlib/testatexit
95  stdlib/test-canon
96  stdlib/test-canon2
97 diff --git a/test/misc/Makefile.in b/test/misc/Makefile.in
98 index 2263211..9b74d22 100644
99 --- a/test/misc/Makefile.in
100 +++ b/test/misc/Makefile.in
101 @@ -9,6 +9,12 @@ CFLAGS_dirent64 := -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS
102  
103  DODIFF_dirent    := 1
104  DODIFF_dirent64  := 1
105 +DODIFF_tst-statfs := 1
106 +DODIFF_tst-statvfs := 1
107  
108  OPTS_bug-glob1   := $(PWD)
109  OPTS_tst-fnmatch := < tst-fnmatch.input
110 +
111 +MNTENTS = $(shell mount | while read dev on mp rest; do echo $$mp; done)
112 +OPTS_tst-statfs := $(MNTENTS)
113 +OPTS_tst-statvfs := $(MNTENTS)
114 diff --git a/test/misc/tst-statfs.c b/test/misc/tst-statfs.c
115 new file mode 100644
116 index 0000000..44ab3aa
117 --- /dev/null
118 +++ b/test/misc/tst-statfs.c
119 @@ -0,0 +1,33 @@
120 +#define _FILE_OFFSET_BITS 64
121 +
122 +#include <sys/vfs.h>
123 +#include <errno.h>
124 +#include <stdio.h>
125 +#include <stdlib.h>
126 +#include <string.h>
127 +
128 +int
129 +main(int argc, char* argv[])
130 +{
131 +       struct statfs s;
132 +       int ret = 0, i;
133 +
134 +       for (i = 1; i < argc; i++) {
135 +               if (statfs(argv[i], &s) != 0) {
136 +                       fprintf(stderr, "%s: %s: statfs failed. %s\n",
137 +                               *argv, argv[i], strerror(errno));
138 +                       exit(EXIT_FAILURE);
139 +               }
140 +               ++ret;
141 +               printf("statfs %s:\n\tblocks=%lld\n\tblkfree=%lld\n\tbsize=%d\n",
142 +                       argv[i], s.f_blocks, s.f_bfree, s.f_bsize);
143 +#ifdef _STATFS_F_FRSIZE
144 +               printf("\tfrsize=%lld\n", s.f_frsize);
145 +#elif defined __mips__
146 +               printf("\tfrsize=mips, unsupported?\n");
147 +#else
148 +# error no _STATFS_F_FRSIZE
149 +#endif
150 +       }
151 +       exit(ret ? EXIT_SUCCESS : EXIT_FAILURE);
152 +}
153 diff --git a/test/misc/tst-statvfs.c b/test/misc/tst-statvfs.c
154 new file mode 100644
155 index 0000000..c1e8fde
156 --- /dev/null
157 +++ b/test/misc/tst-statvfs.c
158 @@ -0,0 +1,28 @@
159 +#define _FILE_OFFSET_BITS 64
160 +
161 +#include <sys/statvfs.h>
162 +#include <errno.h>
163 +#include <stdio.h>
164 +#include <stdlib.h>
165 +#include <string.h>
166 +
167 +int
168 +main(int argc, char* argv[])
169 +{
170 +       struct statvfs s;
171 +       int i;
172 +
173 +       for (i = 1; i < argc; i++) {
174 +               if (statvfs(argv[i], &s) != 0) {
175 +                       fprintf(stderr, "%s: %s: statvfs failed. %s\n",
176 +                               *argv, argv[i], strerror(errno));
177 +                       exit(EXIT_FAILURE);
178 +               }
179 +               printf("statvfs %s:\n\tblocks=%lld\n\tblkfree=%lld\n\tbsize=%d\n",
180 +                       argv[i], s.f_blocks, s.f_bfree, s.f_bsize);
181 +#if 1 // def _STATFS_F_FRSIZE
182 +               printf("\tfrsize=%lld\n", s.f_frsize);
183 +#endif
184 +       }
185 +       exit(EXIT_SUCCESS);
186 +}
187 -- 
188 1.7.10.4
189