* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2012, 2013, Intel Corporation.
+ * Copyright (c) 2012, 2015, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#include <sys/mman.h>
#include <sys/vfs.h>
#include <sys/ioctl.h>
+#include <sys/xattr.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
int bufsize = 0;
sem_t sem;
#define ALIGN_LEN 65535
+#define XATTR "user.multiop"
char usage[] =
"Usage: %s filename command-sequence [path...]\n"
" command-sequence items:\n"
+" A fsetxattr(\"user.multiop\")\n"
+" a fgetxattr(\"user.multiop\")\n"
" c close\n"
" B[num] call setstripe ioctl to create stripes\n"
" C[num] create with optional stripes\n"
ts.tv_nsec = 0;
while (sem_timedwait(&sem, &ts) < 0 && errno == EINTR);
break;
+ case 'A':
+ if (fsetxattr(fd, XATTR, "multiop", 8, 0)) {
+ save_errno = errno;
+ perror("fsetxattr");
+ exit(save_errno);
+ }
+ break;
+ case 'a':
+ if (fgetxattr(fd, XATTR, NULL, 0) == -1) {
+ save_errno = errno;
+ perror("fgetxattr");
+ exit(save_errno);
+ }
+ break;
case 'c':
if (close(fd) == -1) {
save_errno = errno;
if (len <= 0)
len = 1;
if (bufsize < len) {
- buf = realloc(buf, len + ALIGN_LEN);
- if (buf == NULL) {
+ void *tmp;
+ tmp = realloc(buf, len + ALIGN_LEN);
+ if (tmp == NULL) {
+ free(buf);
save_errno = errno;
perror("allocating buf for read\n");
exit(save_errno);
}
+ buf = tmp;
bufsize = len;
buf_align = (char *)((long)(buf + ALIGN_LEN) &
~ALIGN_LEN);
if (len <= 0)
len = 1;
if (bufsize < len) {
- buf = realloc(buf, len + ALIGN_LEN);
- if (buf == NULL) {
+ void *tmp;
+ tmp = realloc(buf, len + ALIGN_LEN);
+ if (tmp == NULL) {
+ free(buf);
save_errno = errno;
perror("allocating buf for write\n");
exit(save_errno);
}
+ buf = tmp;
bufsize = len;
buf_align = (char *)((long)(buf + ALIGN_LEN) &
~ALIGN_LEN);