* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2013, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#define ALIGN_LEN 65535
char usage[] =
-"Usage: %s filename command-sequence\n"
+"Usage: %s filename command-sequence [path...]\n"
" command-sequence items:\n"
" c close\n"
+" B[num] call setstripe ioctl to create stripes\n"
" C[num] create with optional stripes\n"
" d mkdir\n"
" D open(O_DIRECTORY)\n"
" F print FID\n"
" G gid get grouplock\n"
" g gid put grouplock\n"
-" L link\n"
-" l symlink\n"
+" K link path to filename\n"
+" L link filename to path\n"
+" l symlink filename to path\n"
" m mknod\n"
" M rw mmap to EOF (must open and stat prior)\n"
-" N rename\n"
+" n rename path to filename\n"
+" N rename filename to path\n"
" o open(O_RDONLY)\n"
" O open(O_CREAT|O_RDWR)\n"
" r[num] read [optional length]\n"
}
struct flag_mapping {
- const char *string;
- const int flag;
+ const char *string;
+ const int flag;
} flag_table[] = {
- {"O_RDONLY", O_RDONLY},
- {"O_WRONLY", O_WRONLY},
- {"O_RDWR", O_RDWR},
- {"O_CREAT", O_CREAT},
- {"O_EXCL", O_EXCL},
- {"O_NOCTTY", O_NOCTTY},
- {"O_TRUNC", O_TRUNC},
- {"O_APPEND", O_APPEND},
- {"O_NONBLOCK", O_NONBLOCK},
- {"O_NDELAY", O_NDELAY},
- {"O_SYNC", O_SYNC},
+ {"O_RDONLY", O_RDONLY},
+ {"O_WRONLY", O_WRONLY},
+ {"O_RDWR", O_RDWR},
+ {"O_CREAT", O_CREAT},
+ {"O_EXCL", O_EXCL},
+ {"O_NOCTTY", O_NOCTTY},
+ {"O_TRUNC", O_TRUNC},
+ {"O_APPEND", O_APPEND},
+ {"O_NONBLOCK", O_NONBLOCK},
+ {"O_NDELAY", O_NDELAY},
+ {"O_SYNC", O_SYNC},
#ifdef O_DIRECT
- {"O_DIRECT", O_DIRECT},
+ {"O_DIRECT", O_DIRECT},
#endif
- {"O_LARGEFILE", O_LARGEFILE},
- {"O_DIRECTORY", O_DIRECTORY},
- {"O_NOFOLLOW", O_NOFOLLOW},
- {"", -1}
+ {"O_LARGEFILE", O_LARGEFILE},
+ {"O_DIRECTORY", O_DIRECTORY},
+ {"O_NOFOLLOW", O_NOFOLLOW},
+ {"O_LOV_DELAY_CREATE", O_LOV_DELAY_CREATE},
+ {"", -1}
};
int get_flags(char *data, int *rflags)
{
char *fname, *commands;
const char *newfile;
+ const char *oldpath;
struct stat st;
struct statfs stfs;
size_t mmap_len = 0, i;
int gid = 0;
lustre_fid fid;
struct timespec ts;
+ struct lov_user_md_v3 lum;
if (argc < 3) {
fprintf(stderr, usage, argv[0]);
}
fd = -1;
break;
+ case 'B':
+ lum = (struct lov_user_md_v3) {
+ .lmm_magic = LOV_USER_MAGIC_V3,
+ .lmm_stripe_count = atoi(commands + 1),
+ };
+
+ if (ioctl(fd, LL_IOC_LOV_SETSTRIPE, &lum) < 0) {
+ save_errno = errno;
+ perror("LL_IOC_LOV_SETSTRIPE");
+ exit(save_errno);
+ }
+ break;
case 'C':
len = atoi(commands+1);
fd = llapi_file_open(fname, O_CREAT | O_WRONLY, 0644,
exit(save_errno);
}
break;
+ case 'K':
+ oldpath = POP_ARG();
+ if (oldpath == NULL)
+ oldpath = fname;
+
+ if (link(oldpath, fname)) {
+ save_errno = errno;
+ perror("link()");
+ exit(save_errno);
+ }
+ break;
case 'l':
newfile = POP_ARG();
if (!newfile)
exit(save_errno);
}
break;
- case 'L':
- newfile = POP_ARG();
- if (!newfile)
- newfile = fname;
- if (link(fname, newfile)) {
- save_errno = errno;
- perror("symlink()");
- exit(save_errno);
- }
- break;
+ case 'L':
+ newfile = POP_ARG();
+ if (newfile == NULL)
+ newfile = fname;
+
+ if (link(fname, newfile)) {
+ save_errno = errno;
+ perror("link()");
+ exit(save_errno);
+ }
+ break;
case 'm':
if (mknod(fname, S_IFREG | 0644, 0) == -1) {
save_errno = errno;
exit(save_errno);
}
break;
+ case 'n':
+ oldpath = POP_ARG();
+ if (oldpath == NULL)
+ oldpath = fname;
+
+ if (rename(oldpath, fname) < 0) {
+ save_errno = errno;
+ perror("rename()");
+ exit(save_errno);
+ }
+ break;
case 'N':
newfile = POP_ARG();
if (!newfile)
exit(save_errno);
}
break;
+ case '-':
case '0':
case '1':
case '2':