2 * Tests for various stat functions
4 * stat - tests fstatat with 1st arg AT_FDCWD
22 if (-1 == stat("stat.c", &sb
))
24 perror("stat failed:");
27 assert(sb
.st_size
== 1161);
29 int fd
= openat(AT_FDCWD
, "stat.c", O_RDONLY
);
32 perror("openat failed:");
35 if (-1 == fstat(fd
, &sb
))
37 perror("fstat failed:");
40 DIR* cwd
= opendir(".");
43 int cwdfd
= dirfd(cwd
);
44 fstatat(cwdfd
, "stat.c", &sb
, 0);
49 char *badfilename
= strdup("stat.c");
52 stat(badfilename
, &sb
);
54 struct stat
* badpsb
= malloc(sizeof(struct stat
));
57 stat("stat.c", badpsb
);
59 badpsb
= malloc(sizeof(struct stat
));
66 fstatat(badfd
, "stat.c", &sb
, 0);
67 fstatat(fd
, "stat.c", &sb
, badfd
);