diff options
author | Khem Raj <raj.khem@gmail.com> | 2012-02-03 20:06:55 -0800 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2012-02-05 12:11:26 -0800 |
commit | ae0e6225db6dacb4d4de81245fba8671526dfe90 (patch) | |
tree | 335d1f4ba329d7de195a3f87daa8e71e9d3a3e84 /test/stat | |
parent | 812ae602fe96bb40d1743d410eb1eadb6aa722f5 (diff) |
lstat/stat/fstat: Use 64bit version of syscall if available
This is needed for stat'ing loop devices > 255
since otherwise kernel returns EOVERFLOW becasue
it needs st_rdev/st_dev to be larger than 16bits but
in kernel it uses __old_kernel_stat for stat
syscall which has st_rdev/st_dev as unsigned short
Add a testcase
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'test/stat')
-rw-r--r-- | test/stat/stat-loop256.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/stat/stat-loop256.c b/test/stat/stat-loop256.c new file mode 100644 index 000000000..14284c184 --- /dev/null +++ b/test/stat/stat-loop256.c @@ -0,0 +1,32 @@ +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <sys/stat.h> +int main() +{ + struct stat statbuf; + int ret = 0; + char* loop255 = "/dev/loop255"; + char* loop256 = "/dev/loop256"; + mode_t mode = 0660; + mknod(loop255, mode, 0x7ff); + mknod(loop256, mode, 0x100700); + ret = stat(loop255, &statbuf); + if(ret < 0) { + printf("stat: Cant stat %s\n",loop255); + unlink(loop255); + exit(1); + } + ret = stat(loop256, &statbuf); + if(ret < 0) { + printf("stat: Cant stat %s\n",loop256); + unlink(loop255); + unlink(loop256); + exit(1); + } + + unlink(loop255); + unlink(loop256); + exit(0); +} + |