Add /none/tests/use_after_close to .gitignore
[valgrind.git] / memcheck / tests / freebsd / getfh.c
blobc72318f10e91743b4376c6fe382db761458953de
1 #include <sys/param.h>
2 #include <sys/mount.h>
3 #include <fcntl.h>
4 #include <stdlib.h>
5 #include <string.h>
6 #include <assert.h>
7 #include <err.h>
8 #include <unistd.h>
9 #include "../../../config.h"
11 int main()
13 char path[PATH_MAX];
14 fhandle_t fh1;
15 fhandle_t fh2;
16 #if (__FreeBSD_version >= 1200031)
17 fhandle_t fh3;
18 #endif
20 int fd;
22 strcpy(path, "/tmp/getfh.XXXXXXXXXXX");
23 fd = mkstemp(path);
24 if (fd < 0)
25 err(-1, "mkstemp(%s)", path);
27 getfh(path, &fh1);
28 lgetfh(path, &fh2);
29 #if (__FreeBSD_version >= 1200031)
30 getfhat(fd, path, &fh3, AT_SYMLINK_NOFOLLOW);
31 #endif
33 // error section
34 char* fn = strdup(path);
35 fhandle_t* pfh1 = malloc(sizeof(fhandle_t));
36 int* pi = malloc(sizeof(int));
37 free(fn);
38 free(pfh1);
40 getfh(fn, pfh1);
41 lgetfh(fn, pfh1);
42 #if (__FreeBSD_version >= 1200031)
43 getfhat(*pi+AT_FDCWD, fn, pfh1, *pi+AT_SYMLINK_NOFOLLOW);
44 #endif
46 free(pi);
47 close(fd);
48 unlink(path);