Skip to content

Instantly share code, notes, and snippets.

@kostikbel
Created July 23, 2017 09:43
Show Gist options
  • Save kostikbel/0db335a4b30cd519632d0c847c24ce18 to your computer and use it in GitHub Desktop.
Save kostikbel/0db335a4b30cd519632d0c847c24ce18 to your computer and use it in GitHub Desktop.
nfs_halfpage
/* $Id: nfs_halfpage.c,v 1.2 2017/07/23 09:36:23 kostik Exp kostik $ */
#include <sys/fcntl.h>
#include <sys/mman.h>
#include <err.h>
#include <unistd.h>
int
main(int argc __unused, char *argv[])
{
char *m;
int error, fd, pgsz, sz;
pgsz = getpagesize();
fd = open(argv[1], O_RDWR | O_CREAT | O_TRUNC, 0666);
if (fd == -1)
err(1, "open %s", argv[1]);
sz = pgsz / 4;
error = lseek(fd, sz, SEEK_SET);
if (error == -1)
err(1, "lseek");
error = write(fd, "a", 1);
if (error == -1)
err(1, "write");
else if (error != 1)
errx(1, "short write");
m = mmap(NULL, sz + 1, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (m == MAP_FAILED)
err(1, "mmap");
m[0] = 'x';
}
@kostikbel
Copy link
Author

Run this program with the argument a filename to be created on an nfs mount, then reboot the machine. It should loop syncing vnodes and buffers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment