summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.syscall/dir.c
blob: 3eda817509d15acdb8be9f7df0630b030b914114 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* COVERAGE: mkdir chdir open fchdir close rmdir mkdirat */
#define _GNU_SOURCE
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/syscall.h>

int main()
{
  int fd;

  mkdir("foobar", 0765);
  //staptest// mkdir ("foobar", 0765) =

  chdir("foobar");
  //staptest// chdir ("foobar") = 0

  chdir("..");
  //staptest// chdir ("..") = 0

  fd = open("foobar", O_RDONLY);
  //staptest// open ("foobar", O_RDONLY) = NNNN

  fchdir(fd);
  //staptest// fchdir (NNNN) = 0

  chdir("..");
  //staptest// chdir ("..") = 0

  close(fd);
  //staptest// close (NNNN) = 0

  rmdir("foobar");
  //staptest// rmdir ("foobar") = 0

  fd = open(".", O_RDONLY);
  //staptest// open (".", O_RDONLY) = NNNN

#ifdef SYS_mkdirat
  mkdirat(fd, "xyzzy", 0765);
  //staptest// mkdirat (NNNN, "xyzzy", 0765) = 0

#endif

  close(fd);
  //staptest// close (NNNN) = 0

  rmdir("xyzzy");
  //staptest// rmdir ("xyzzy") =

  return 0;
}