[3/2] statvfs: f_type: NEWS & test
Commit Message
Also fix tst-statvfs so that it actually fails;
as it stood, all it did was return 0 always.
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
NEWS | 5 +++++
io/tst-statvfs.c | 19 +++++++++++--------
2 files changed, 16 insertions(+), 8 deletions(-)
Comments
* наб:
> /* This test cannot detect many errors. But it will fail if the
> @@ -11,17 +13,18 @@ do_test (int argc, char *argv[])
> for (int i = 1; i < argc; ++i)
> {
> struct statvfs st;
> - if (statvfs (argv[i], &st) != 0)
> - printf ("%s: failed (%m)\n", argv[i]);
> - else
> - printf ("%s: free: %llu, mandatory: %s\n", argv[i],
> - (unsigned long long int) st.f_bfree,
> + struct statfs stf;
> + TEST_VERIFY (statvfs (argv[i], &st) == 0);
> + TEST_VERIFY (statfs (argv[i], &stf) == 0);
> + TEST_VERIFY (st.f_type == stf.f_type);
These TEST_VERIFYs could use TEST_COMPARE for better diagnostics on
failure.
Thanks,
Florian
@@ -48,6 +48,11 @@ Major new features:
* The strlcpy and strlcat functions have been added. They are derived
from OpenBSD, and are expected to be added to a future POSIX version.
+* struct statvfs now has an f_type member, equal to the f_type statfs member;
+ on the Hurd this was always available under a reserved name,
+ and under Linux a spare has been allocated: it was always zero
+ in previous versions of glibc, and zero is not a valid result.
+
Deprecated and removed features, and other changes affecting compatibility:
* In the Linux kernel for the hppa/parisc architecture some of the
@@ -1,5 +1,7 @@
#include <stdio.h>
+#include <sys/statfs.h>
#include <sys/statvfs.h>
+#include <support/check.h>
/* This test cannot detect many errors. But it will fail if the
@@ -11,17 +13,18 @@ do_test (int argc, char *argv[])
for (int i = 1; i < argc; ++i)
{
struct statvfs st;
- if (statvfs (argv[i], &st) != 0)
- printf ("%s: failed (%m)\n", argv[i]);
- else
- printf ("%s: free: %llu, mandatory: %s\n", argv[i],
- (unsigned long long int) st.f_bfree,
+ struct statfs stf;
+ TEST_VERIFY (statvfs (argv[i], &st) == 0);
+ TEST_VERIFY (statfs (argv[i], &stf) == 0);
+ TEST_VERIFY (st.f_type == stf.f_type);
+ printf ("%s: free: %llu, mandatory: %s\n", argv[i],
+ (unsigned long long int) st.f_bfree,
#ifdef ST_MANDLOCK
- (st.f_flag & ST_MANDLOCK) ? "yes" : "no"
+ (st.f_flag & ST_MANDLOCK) ? "yes" : "no"
#else
- "no"
+ "no"
#endif
- );
+ );
}
return 0;
}