dirconc

dirconc - /* * Concurrent directory operations test. * *...

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

View Full Document Right Arrow Icon
/* * Concurrent directory operations test. * * Your system should survive this (without leaving a corrupted file * system behind) once the file system assignment is complete. */ #include <sys/types.h> #include <sys/wait.h> #include <sys/stat.h> #include <errno.h> #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <stdarg.h> #include <string.h> #define NTRIES 100 /* loop count */ #define NPROCS 5 /* actually totals 4x this +1 processes */ #define TESTDIR "dirconc" #define NNAMES 4 #define NAMESIZE 32 #ifndef HOST /* OS/161 doesn't support the Unix exit status macros */ #define WIFSIGNALED(status) ((void)(status), 0) #define WTERMSIG(status) ((void)(status), 0) #define WIFEXITED(status) ((void)(status), 1) #define WEXITSTATUS(status) (status) #endif //////////////////////////////////////////////////////////// static const char *const names[NNAMES] = { "aaaa", "bbbb", "cccc", "dddd", }; static void choose_name(char *buf, size_t len) { const char *a, *b, *c; a = names[random()%NNAMES]; if (random()%2==0) { snprintf(buf, len, "%s", a); return; } b = names[random()%NNAMES]; if (random()%2==0) { snprintf(buf, len, "%s/%s", a, b); return; } c = names[random()%NNAMES]; snprintf(buf, len, "%s/%s/%s", a, b, c);
Background image of page 1

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

View Full DocumentRight Arrow Icon
} //////////////////////////////////////////////////////////// /* * The purpose of this is to be atomic. In our world, straight
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

dirconc - /* * Concurrent directory operations test. * *...

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

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