| 1 |
/* COVERAGE: ioctl */ |
| 2 |
|
| 3 |
#include <unistd.h> |
| 4 |
#include <fcntl.h> |
| 5 |
#include <sys/ioctl.h> |
| 6 |
#include <stdio.h> |
| 7 |
#include <linux/if_tun.h> |
| 8 |
#include <linux/fs.h> |
| 9 |
|
| 10 |
unsigned int fd, val; |
| 11 |
char fname[] = "/dev/net/tun"; |
| 12 |
|
| 13 |
int main() { |
| 14 |
fd = open(fname, O_RDWR); |
| 15 |
if (fd < 0) { |
| 16 |
printf("ERROR (open %s)\n", fname); |
| 17 |
} |
| 18 |
|
| 19 |
// ----- try successful call ----- |
| 20 |
|
| 21 |
ioctl(fd, TUNGETFEATURES, &val); |
| 22 |
//staptest/ ioctl (NNNN, NNNN, XXXX) = NNNN |
| 23 |
|
| 24 |
|
| 25 |
// ----- try ugly things ----- |
| 26 |
|
| 27 |
ioctl(-1, TUNGETFEATURES, &val); |
| 28 |
//staptest// ioctl (-1, NNNN, XXXX) = NNNN |
| 29 |
|
| 30 |
ioctl(fd, -1, &val); |
| 31 |
//staptest// ioctl (NNNN, -1, XXXX) = NNNN |
| 32 |
|
| 33 |
ioctl(fd, TUNGETFEATURES, -1); |
| 34 |
#ifdef __s390__ |
| 35 |
//staptest// ioctl (NNNN, NNNN, 0x[7]?[f]+) = NNNN |
| 36 |
#else |
| 37 |
//staptest// ioctl (NNNN, NNNN, 0x[f]+) = NNNN |
| 38 |
#endif |
| 39 |
|
| 40 |
close(fd); |
| 41 |
|
| 42 |
return 0; |
| 43 |
} |