/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
*/
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ */
+
#ifndef _GNU_SOURCE
#define _GNU_SOURCE /* pull in O_DIRECTORY in bits/fcntl.h */
#endif
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
+#include <libcfs/libcfs.h>
+#include <lustre/liblustreapi.h>
#define T1 "write data before unlink\n"
#define T2 "write data after unlink\n"
int bufsize = 0;
#define ALIGN 65535
-char usage[] =
+char usage[] =
"Usage: %s filename command-sequence\n"
" command-sequence items:\n"
" c close\n"
+" C[num] create with optional stripes\n"
" d mkdir\n"
" D open(O_DIRECTORY)\n"
" L link\n"
" T[num] ftruncate [optional position, default 0]\n"
" u unlink\n"
" U munmap\n"
+" v verbose\n"
" w[num] write optional length\n"
" W write entire mmap-ed region\n"
" y fsync\n"
int rc, len, fd = -1;
int flags;
int save_errno;
+ int verbose = 0;
if (argc < 3) {
fprintf(stderr, usage, argv[0]);
exit(1);
}
+ memset(&st, 0, sizeof(st));
signal(SIGUSR1, usr1_handler);
fname = argv[1];
for (commands = argv[2]; *commands; commands++) {
switch (*commands) {
case '_':
- if (usr1_received == 0)
+ if (usr1_received == 0) {
+ if (verbose) {
+ printf("PAUSING\n");
+ fflush(stdout);
+ }
pause();
+ }
usr1_received = 0;
signal(SIGUSR1, usr1_handler);
break;
}
fd = -1;
break;
+ case 'C':
+ len = atoi(commands+1);
+ fd = llapi_file_open(fname, O_CREAT | O_WRONLY, 0644,
+ 0, 0, len, 0);
+ if (fd == -1) {
+ save_errno = errno;
+ perror("create stripe file");
+ exit(save_errno);
+ }
+ break;
case 'd':
if (mkdir(fname, 0755) == -1) {
save_errno = errno;
}
break;
case 'M':
+ if (st.st_size == 0) {
+ fprintf(stderr, "mmap without preceeding stat, or on"
+ " zero length file.\n");
+ exit(-1);
+ }
mmap_len = st.st_size;
mmap_ptr = mmap(NULL, mmap_len, PROT_WRITE | PROT_READ,
MAP_SHARED, fd, 0);
fprintf(stderr, "short read: %u/%u\n",
rc, len);
len -= rc;
+ if (verbose >= 2)
+ printf("%.*s\n", rc, buf_align);
}
break;
case 'R':
exit(save_errno);
}
break;
+ case 'v':
+ verbose++;
+ break;
case 'w':
len = atoi(commands+1);
if (len <= 0)