[SOLVED] CS /* Maps a file into memory and runs child-inherit to verify that

$25

File Name: CS_/*_Maps_a_file_into_memory_and_runs_child-inherit_to_verify_that.zip
File Size: 631.14 KB

5/5 - (1 vote)

/* Maps a file into memory and runs child-inherit to verify that
mappings are not inherited. */

#include
#include
#include tests/vm/sample.inc
#include tests/lib.h
#include tests/main.h

void
test_main (void)
{
char *actual = (char *) 0x54321000;
int handle;
pid_t child;

/* Open file, map, verify data. */
CHECK ((handle = open (sample.txt)) > 1, open sample.txt);
CHECK (mmap (handle, actual) != MAP_FAILED, mmap sample.txt);
if (memcmp (actual, sample, strlen (sample)))
fail (read of mmapd file reported bad data);

/* Spawn child and wait. */
CHECK ((child = exec (child-inherit)) != -1, exec child-inherit);
quiet = true;
CHECK (wait (child) == -1, wait for child (should return -1));
quiet = false;

/* Verify data again. */
CHECK (!memcmp (actual, sample, strlen (sample)),
checking that mmapd file still has same data);
}

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS /* Maps a file into memory and runs child-inherit to verify that
$25