10 #include <lustre/lustreapi.h>
12 int main(int argc, char **argv)
16 char *xval = "UUID@UUID";
18 struct lov_foreign_md *lfm;
20 __u32 type = LU_FOREIGN_TYPE_SYMLINK, flags = 0xda05;
22 while ((c = getopt(argc, argv, "f:x:t:F:")) != -1) {
31 type = strtoul(optarg, &end, 0);
34 "%s: invalid type '%s'\n", argv[0],
41 flags = strtoul(optarg, &end, 0);
42 if (errno != 0 || *end != '\0' ||
43 flags >= UINT32_MAX) {
45 "%s: invalid flags '%s'\n", argv[0],
52 "Usage: %s -f <filename> -x <LOV EA content>\n",
59 if (len > XATTR_SIZE_MAX || len <= 0) {
61 "invalid LOV EA length %zu > XATTR_SIZE_MAX (%u)\n",
66 fd = open(fname, O_WRONLY|O_CREAT|O_LOV_DELAY_CREATE, 0644);
72 lfm = malloc(len + offsetof(struct lov_foreign_md, lfm_value));
78 lfm->lfm_magic = LOV_USER_MAGIC_FOREIGN;
79 lfm->lfm_length = len;
81 lfm->lfm_flags = flags;
82 memcpy(lfm->lfm_value, xval, len);
84 if (ioctl(fd, LL_IOC_LOV_SETSTRIPE, lfm) != 0) {
85 perror("ioctl(LL_IOC_LOV_SETSTRIPE)");