summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e5cabca)
raw | patch | inline | side by side (parent: e5cabca)
author | Yabin Cui <yabinc@google.com> | |
Sat, 8 Nov 2014 22:58:12 +0000 (14:58 -0800) | ||
committer | Yabin Cui <yabinc@google.com> | |
Fri, 14 Nov 2014 23:45:24 +0000 (23:45 +0000) |
libc/bionic/pathconf.cpp | patch | blob | history | |
tests/unistd_test.cpp | patch | blob | history |
index de9e022e2996aa9325f8f47ded27b8c28c492be1..e6f57421458f18ef59e93cf4fdd858b31066247f 100644 (file)
--- a/libc/bionic/pathconf.cpp
+++ b/libc/bionic/pathconf.cpp
case _PC_2_SYMLINKS:
return __2_symlinks(s);
+ case _PC_ALLOC_SIZE_MIN: /* fall through */
+ case _PC_REC_XFER_ALIGN:
+ return s.f_frsize;
+
+ case _PC_REC_MIN_XFER_SIZE:
+ return s.f_bsize;
+
#if 0
- case _PC_ALLOC_SIZE_MIN:
case _PC_REC_INCR_XFER_SIZE:
case _PC_REC_MAX_XFER_SIZE:
- case _PC_REC_MIN_XFER_SIZE:
- case _PC_REC_XFER_ALIGN:
#endif
case _PC_SYMLINK_MAX:
diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp
index 19d4017733bf8a1fdf8d7bb2532ea5841cc98805..4ead05779723b7f1e603934cc6645f4e7de43840 100644 (file)
--- a/tests/unistd_test.cpp
+++ b/tests/unistd_test.cpp
#include <fcntl.h>
#include <limits.h>
#include <stdint.h>
+#include <sys/param.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/utsname.h>
ASSERT_EQ(-1, gethostname(hostname, strlen(hostname)));
ASSERT_EQ(ENAMETOOLONG, errno);
}
+
+TEST(unistd, pathconf_fpathconf) {
+ TemporaryFile tf;
+ long rc = 0L;
+ // As a file system's block size is always power of 2, the configure values
+ // for ALLOC and XFER should be power of 2 as well.
+ rc = pathconf(tf.filename, _PC_ALLOC_SIZE_MIN);
+ ASSERT_TRUE(rc > 0 && powerof2(rc));
+ rc = pathconf(tf.filename, _PC_REC_MIN_XFER_SIZE);
+ ASSERT_TRUE(rc > 0 && powerof2(rc));
+ rc = pathconf(tf.filename, _PC_REC_XFER_ALIGN);
+ ASSERT_TRUE(rc > 0 && powerof2(rc));
+
+ rc = fpathconf(tf.fd, _PC_ALLOC_SIZE_MIN);
+ ASSERT_TRUE(rc > 0 && powerof2(rc));
+ rc = fpathconf(tf.fd, _PC_REC_MIN_XFER_SIZE);
+ ASSERT_TRUE(rc > 0 && powerof2(rc));
+ rc = fpathconf(tf.fd, _PC_REC_XFER_ALIGN);
+ ASSERT_TRUE(rc > 0 && powerof2(rc));
+}