1
/* $Id: readdir.c 264 2006-12-04 06:43:42Z steve-beattie $ */
4
* Copyright (C) 2002-2006 Novell/SUSE
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License as
8
* published by the Free Software Foundation, version 2 of the
16
#include <linux/types.h>
17
#include <linux/dirent.h>
18
#include <linux/unistd.h>
20
#include <sys/syscall.h>
22
int main(int argc, char *argv[])
28
fprintf(stderr, "usage: %s dir\n",
33
fd = open(argv[1], O_RDONLY, 0);
35
printf("FAIL - open %s\n", strerror(errno));
40
if (fchdir(fd) == -1){
41
printf("FAIL - fchdir %s\n", strerror(errno));
46
/* getdents isn't exported by glibc, so must use syscall() */
47
if (syscall(SYS_getdents, fd, &dir, sizeof(struct dirent)) == -1){
48
printf("FAIL - getdents %s\n", strerror(errno));