11 /****************** Custom includes ********************/
12 #include <linux/lustre_lite.h>
13 #include <linux/lustre_idl.h>
16 /****************** Functions ******************/
18 void usage(char *prog)
20 fprintf(stderr, "usage: %s <filename> <stripe size> <stripe start> "
21 "<stripe count>\n", prog);
24 "\tstripe size: number of bytes in each stripe (0 default)\n");
26 "\tstripe start: OST index of first stripe (-1 default)\n");
28 "\tstripe count: number of OSTs to stripe over (0 default)\n");
31 int create_file(char *name, long stripe_size, int stripe_offset,
34 struct lov_mds_md a_striping;
37 /* Initialize IOCTL striping pattern structure */
38 a_striping.lmm_magic = LOV_MAGIC;
39 a_striping.lmm_stripe_size = stripe_size;
40 a_striping.lmm_stripe_offset = stripe_offset;
41 a_striping.lmm_stripe_count = stripe_count;
43 fd = open(name, O_CREAT | O_RDWR | O_LOV_DELAY_CREATE, 0644);
45 fprintf(stderr, "\nUnable to open '%s': %s\n",
46 name, strerror(errno));
48 } else if (ioctl(fd, LL_IOC_LOV_SETSTRIPE, &a_striping)) {
49 fprintf(stderr, "\nError on ioctl for '%s' (%d): %s\n",
50 name, fd, strerror(errno));
52 } else if (close(fd) < 0) {
53 fprintf(stderr, "\nError on close for '%s' (%d): %s\n",
54 name, fd, strerror(errno));
61 int main(int argc, char *argv[])
69 /* Check to make sure we have enough parameters */
75 /* Get the stripe size */
76 st_size = strtoul(argv[2], &end, 0);
78 fprintf(stderr, "bad stripe size '%s'\n", argv[2]);
85 fprintf(stderr, "stripe size must be multiple of page size\n");
91 /* Get the stripe offset*/
92 st_offset = strtoul(argv[3], &end, 0);
94 fprintf(stderr, "bad stripe offset '%s'\n", argv[3]);
99 /* Get the stripe count */
100 st_count = strtoul(argv[4], &end, 0);
102 fprintf(stderr, "bad stripe count '%s'\n", argv[4]);
107 /* Create the file, as specified. Return and display any errors. */
108 result = create_file(argv[1], st_size, st_offset, st_count);