calls - /* Automatically generated file; do not edit */...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
/* Automatically generated file; do not edit */ #include <sys/types.h> #include <sys/stat.h> #include <assert.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <err.h> #include "extern.h" typedef void (*tryfunc)(int dofork); static void try_execv(int dofork) { void * a0 = randptr(); void * a1 = randptr(); int result, pid, status; char buf[128]; snprintf(buf, sizeof(buf), "execv(%p, %p)", (a0), (a1)); printf("%-47s", buf); pid = dofork ? fork() : 0; if (pid<0) { err(1, "fork"); } if (pid>0) { waitpid(pid, &status, 0); return; } result = execv(a0, a1); printf(" result %d, errno %d\n", result, errno); if (dofork) { exit(0); } } static void try_waitpid(int dofork) { int a0 = randint(); void * a1 = randptr(); int a2 = randint(); int result, pid, status; char buf[128]; snprintf(buf, sizeof(buf), "waitpid(%d, %p, %d)", (a0), (a1), (a2)); printf("%-47s", buf); pid = dofork ? fork() : 0; if (pid<0) {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
err(1, "fork"); } if (pid>0) { waitpid(pid, &status, 0); return; } result = waitpid(a0, a1, a2); printf(" result %d, errno %d\n", result, errno); if (dofork) { exit(0); } } static void try_open(int dofork) { void * a0 = randptr(); int a1 = randint(); int a2 = randint(); int result, pid, status; char buf[128]; snprintf(buf, sizeof(buf), "open(%p, %d, %d)", (a0), (a1), (a2)); printf("%-47s", buf); pid = dofork ? fork() : 0; if (pid<0) { err(1, "fork"); } if (pid>0) { waitpid(pid, &status, 0); return; } result = open(a0, a1, a2); printf(" result %d, errno %d\n", result, errno); if (dofork) { exit(0); } } static void try_read(int dofork) { int a0 = randint(); void * a1 = randptr(); size_t a2 = randsize(); int result, pid, status; char buf[128]; snprintf(buf, sizeof(buf), "read(%d, %p, %lu)", (a0), (a1), (unsigned long)(a2)); printf("%-47s", buf); pid = dofork ? fork() : 0;
Background image of page 2
if (pid<0) { err(1, "fork"); } if (pid>0) { waitpid(pid, &status, 0); return; } result = read(a0, a1, a2); printf(" result %d, errno %d\n", result, errno); if (dofork) { exit(0); } } static void try_write(int dofork) { int a0 = randint(); void * a1 = randptr(); size_t a2 = randsize(); int result, pid, status; char buf[128]; snprintf(buf, sizeof(buf), "write(%d, %p, %lu)", (a0), (a1), (unsigned long)(a2)); printf("%-47s", buf); pid = dofork ? fork() : 0; if (pid<0) { err(1, "fork"); } if (pid>0) { waitpid(pid, &status, 0); return; } result = write(a0, a1, a2); printf(" result %d, errno %d\n", result, errno); if (dofork) { exit(0); } } static void try_close(int dofork) { int a0 = randint(); int result, pid, status; char buf[128]; snprintf(buf, sizeof(buf), "close(%d)", (a0)); printf("%-47s", buf); pid = dofork ? fork() : 0; if (pid<0) {
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
err(1, "fork"); } if (pid>0) { waitpid(pid, &status, 0); return; } result = close(a0); printf(" result %d, errno %d\n", result, errno); if (dofork) { exit(0); } } static void try_ioctl(int dofork) { int a0 = randint(); int a1 = randint(); void * a2 = randptr(); int result, pid, status;
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 15

calls - /* Automatically generated file; do not edit */...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online