--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/mman.h>
+
+// not correctly in the headers yet!!
+#define O_DIRECT 040000 /* direct disk access hint */
+
+int main(int argc, char **argv)
+{
+ int fd;
+ char *buf;
+ int pages;
+ int rc;
+
+ if (argc != 3) {
+ printf("Usage: %s file nr_pages\n", argv[0]);
+ return 1;
+ }
+
+ pages = strtoul(argv[2], 0, 0);
+ printf("directio on %s for %d pages \n", argv[1], pages);
+
+ buf = mmap(0, pages * 4096, PROT_READ|PROT_WRITE,
+ MAP_PRIVATE|MAP_ANON, 0, 0);
+ if (!buf) {
+ printf("No memory %s\n", strerror(errno));
+ return 1;
+ }
+
+ fd = open(argv[1], O_DIRECT | O_RDWR | O_CREAT);
+ if (fd == -1) {
+ printf("Cannot open %s: %s\n", argv[1], strerror(errno));
+ return 1;
+ }
+
+ rc = read(fd, buf, pages * 4096);
+ if (rc != pages * 4096) {
+ printf("Read error: %s, rc %d\n", strerror(errno), rc);
+ return 1;
+ }
+
+ if ( lseek(fd, 0, SEEK_SET) != 0 ) {
+ printf("Cannot seek %s\n", strerror(errno));
+ return 1;
+ }
+
+ rc = write(fd, buf, pages * 4096);
+ if (rc != pages * 4096) {
+ printf("Write error %s\n", strerror(errno));
+ return 1;
+ }
+
+ return 0;
+}
--- /dev/null
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+ int fd;
+
+ if (argc != 2) {
+ printf("Usage openme <filename>\n");
+ exit(1);
+ }
+
+ fd = open(argv[1], O_RDONLY | O_CREAT, 0600);
+ if (fd == -1) {
+ printf("Error opening %s\n", argv[1]);
+ exit(1);
+ }
+
+ sleep(10000000);
+ return 0;
+}
--- /dev/null
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+int main(int argc, char **argv)
+{
+ int fd, rc;
+ int i = 0;
+ char buf[4096];
+
+ memset(buf, 0, 4096);
+
+ if (argc != 2) {
+ printf("Usage openme <filename>\n");
+ exit(1);
+ }
+
+ fd = open(argv[1], O_RDWR | O_CREAT, 0600);
+ if (fd == -1) {
+ printf("Error opening %s\n", argv[1]);
+ exit(1);
+ }
+
+ while (1) {
+ sprintf(buf, "write %d\n", i);
+ rc = write(fd, buf, sizeof(buf));
+ sleep(1);
+ }
+ return 0;
+}
--- /dev/null
+#!/bin/bash
+set -vx
+date
+echo "ha assist checking for problems"
+sleep 3
+if [ ! -e /tmp/halog ]; then
+ echo "no problems, exiting"
+ exit
+fi
+
+echo "removing /tmp/halog"
+rm /tmp/halog
+
+echo secondary start `date`
+echo "- please supply a new mds"
+
+
+/usr/src/portals/linux/utils/ptlctl <<EOF3
+setup tcp
+close_uuid mds
+del_uuid mds
+connect localhost 1234
+add_uuid mds
+quit
+EOF3
+
+echo "connected to new MDS!"
+
+/usr/src/obd/utils/obdctl <<EOF2
+name2dev RPCDEV
+newconn
+quit
+EOF2