| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#define _GNU_SOURCE |
| 21 |
|
| 22 |
#include <stdio.h> |
| 23 |
#include <stdlib.h> |
| 24 |
#include <string.h> |
| 25 |
#include <unistd.h> |
| 26 |
#include <fcntl.h> |
| 27 |
#include <dlfcn.h> |
| 28 |
#include <stdarg.h> |
| 29 |
|
| 30 |
#include <hugetlbfs.h> |
| 31 |
|
| 32 |
#include "hugetests.h" |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
int open(const char *path, int flags, ...) |
| 37 |
{ |
| 38 |
int (*old_open)(const char *, int, ...); |
| 39 |
int fd; |
| 40 |
|
| 41 |
if ((strcmp(path, "/proc/mounts") == 0) |
| 42 |
|| (strcmp(path, "/etc/mtab") == 0)) |
| 43 |
path = "/dev/null"; |
| 44 |
|
| 45 |
old_open = dlsym(RTLD_NEXT, "open"); |
| 46 |
if (flags & O_CREAT) { |
| 47 |
va_list ap; |
| 48 |
|
| 49 |
va_start(ap, flags); |
| 50 |
fd = (*old_open)(path, flags, va_arg(ap, mode_t)); |
| 51 |
va_end(ap); |
| 52 |
return fd; |
| 53 |
} else { |
| 54 |
return (*old_open)(path, flags); |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
int main(int argc, char *argv[]) |
| 59 |
{ |
| 60 |
int fd; |
| 61 |
|
| 62 |
test_init(argc, argv); |
| 63 |
|
| 64 |
fd = hugetlbfs_unlinked_fd(); |
| 65 |
if (fd < 0) |
| 66 |
PASS(); |
| 67 |
|
| 68 |
FAIL("Mysteriously found a mount"); |
| 69 |
} |