#include <limits.h>
#include "obdctl.h"
+#include "lustreapi_internal.h"
#include <libcfs/util/list.h>
#include <libcfs/util/ioctl.h>
#include <libcfs/util/param.h>
#include <libcfs/util/string.h>
#include <lnet/nidstr.h>
-#include <lustre/lustre_ostid.h>
-#include <lustre_cfg.h>
-#include <lustre_ioctl.h>
+#include <linux/lustre_ostid.h>
+#include <linux/lustre_cfg.h>
+#include <linux/lustre_ioctl.h>
#include <lustre_ver.h>
#include <lnet/lnetctl.h>
#include <lustre/lustreapi.h>
-#include <lustre_param.h>
+#include <linux/lustre_param.h>
#include <lustre/lustre_barrier_user.h>
#define MAX_STRING_SIZE 128
char *name = NULL;
struct jt_fid_space fid_space = {0};
int version = 0;
- struct option long_opts[] = {
- {"child_base_id", required_argument, 0, 'b'},
- {"stripe_count", required_argument, 0, 'c'},
- {"parent_basedir", required_argument, 0, 'd'},
- {"parent_dircount", required_argument, 0, 'D'},
- {"stripe_index", required_argument, 0, 'i'},
- {"mode", required_argument, 0, 'm'},
- {"count", required_argument, 0, 'n'},
- {"time", required_argument, 0, 't'},
- {"version", no_argument, 0, 'v'},
- {0, 0, 0, 0}
- };
+ struct option long_opts[] = {
+ { .val = 'b', .name = "child_base_id",
+ .has_arg = required_argument },
+ { .val = 'c', .name = "stripe_count",
+ .has_arg = required_argument },
+ { .val = 'd', .name = "parent_basedir",
+ .has_arg = required_argument },
+ { .val = 'D', .name = "parent_dircount",
+ .has_arg = required_argument },
+ { .val = 'i', .name = "stripe_index", .has_arg = required_argument },
+ { .val = 'm', .name = "mode", .has_arg = required_argument },
+ { .val = 'n', .name = "count", .has_arg = required_argument },
+ { .val = 't', .name = "time", .has_arg = required_argument },
+ { .val = 'v', .name = "version", .has_arg = no_argument },
+ { .name = NULL } };
while ((c = getopt_long(argc, argv, "b:c:d:D:m:n:t:v",
long_opts, NULL)) >= 0) {
fprintf(stderr, "Allocate fids error %d.\n",rc);
return rc;
}
- fid_to_ostid(&fid, &data.ioc_obdo1.o_oi);
+ data.ioc_obdo1.o_oi.oi_fid = fid;
}
child_base_id += data.ioc_count;
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
for (i = 1, next_count = verbose; i <= count && shmem_running(); i++) {
+ /*
+ * base_id is 1 so we don't need to worry about it being
+ * greater than OBIF_MAX_OID
+ */
+ data.ioc_obdo1.o_oi.oi_fid.f_oid = base_id;
data.ioc_obdo1.o_mode = mode;
- ostid_set_id(&data.ioc_obdo1.o_oi, base_id);
data.ioc_obdo1.o_uid = 0;
data.ioc_obdo1.o_gid = 0;
+ data.ioc_obdo1.o_projid = 0;
data.ioc_obdo1.o_valid = OBD_MD_FLTYPE | OBD_MD_FLMODE |
OBD_MD_FLID | OBD_MD_FLUID |
- OBD_MD_FLGID | OBD_MD_FLGROUP;
+ OBD_MD_FLGID | OBD_MD_FLGROUP |
+ OBD_MD_FLPROJID;
memset(buf, 0, sizeof(rawbuf));
rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
int jt_obd_setattr(int argc, char **argv)
{
- struct obd_ioctl_data data;
- char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
- char *end;
- int rc;
+ struct obd_ioctl_data data;
+ char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
+ __u64 objid;
+ char *end;
+ int mode;
+ int rc;
memset(&data, 0, sizeof(data));
data.ioc_dev = cur_device;
if (argc != 2)
return CMD_HELP;
- ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
- ostid_set_id(&data.ioc_obdo1.o_oi, strtoull(argv[1], &end, 0));
- if (*end) {
+ objid = strtoull(argv[1], &end, 0);
+ if (*end) {
+ fprintf(stderr, "error: %s: objid '%s' is not a number\n",
+ jt_cmdname(argv[0]), argv[1]);
+ return CMD_HELP;
+ }
+
+ if (objid >= OBIF_MAX_OID) {
fprintf(stderr, "error: %s: invalid objid '%s'\n",
jt_cmdname(argv[0]), argv[1]);
return CMD_HELP;
}
- data.ioc_obdo1.o_mode = S_IFREG | strtoul(argv[2], &end, 0);
+
+ mode = strtoul(argv[2], &end, 0);
if (*end) {
fprintf(stderr, "error: %s: invalid mode '%s'\n",
jt_cmdname(argv[0]), argv[2]);
return CMD_HELP;
}
- data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMODE;
+
+ ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
+ data.ioc_obdo1.o_mode = S_IFREG | mode;
+ data.ioc_obdo1.o_oi.oi_fid.f_oid = objid;
+ data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMODE;
memset(buf, 0, sizeof(rawbuf));
rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
for (i = 1, next_count = verbose; i <= count && shmem_running(); i++) {
- ostid_set_id(&data.ioc_obdo1.o_oi, objid);
+ if (objid >= OBIF_MAX_OID) {
+ fprintf(stderr, "errr: %s: invalid objid '%llu'\n",
+ jt_cmdname(argv[0]), objid);
+ return -E2BIG;
+ }
+
+ data.ioc_obdo1.o_oi.oi_fid.f_oid = objid;
data.ioc_obdo1.o_mode = S_IFREG;
data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMODE;
memset(buf, 0, sizeof(rawbuf));
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
for (i = 1, next_count = verbose; i <= count && shmem_running(); i++, id++) {
- ostid_set_id(&data.ioc_obdo1.o_oi, id);
+ if (id >= OBIF_MAX_OID) {
+ fprintf(stderr, "errr: %s: invalid objid '%llu'\n",
+ jt_cmdname(argv[0]), id);
+ return -E2BIG;
+ }
+
+ data.ioc_obdo1.o_oi.oi_fid.f_oid = id;
data.ioc_obdo1.o_mode = S_IFREG | 0644;
data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLMODE;
{
struct obd_ioctl_data data;
char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
+ __u64 objid;
char *end;
int rc;
if (argc != 2)
return CMD_HELP;
- memset(&data, 0, sizeof(data));
- data.ioc_dev = cur_device;
- ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
- ostid_set_id(&data.ioc_obdo1.o_oi, strtoull(argv[1], &end, 0));
+ objid = strtoull(argv[1], &end, 0);
if (*end) {
+ fprintf(stderr, "error: %s: objid '%s' is not a number\n",
+ jt_cmdname(argv[0]), argv[1]);
+ return CMD_HELP;
+ }
+
+ if (objid >= OBIF_MAX_OID) {
fprintf(stderr, "error: %s: invalid objid '%s'\n",
jt_cmdname(argv[0]), argv[1]);
return CMD_HELP;
}
+
+ memset(&data, 0, sizeof(data));
+ data.ioc_dev = cur_device;
+ ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
+ data.ioc_obdo1.o_oi.oi_fid.f_oid = objid;
/* to help obd filter */
data.ioc_obdo1.o_mode = 0100644;
data.ioc_obdo1.o_valid = 0xffffffff;
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
for (i = 1, next_count = verbose; i <= count && shmem_running(); i++) {
- ostid_set_id(&data.ioc_obdo1.o_oi, objid);
+ if (objid >= OBIF_MAX_OID) {
+ fprintf(stderr, "errr: %s: invalid objid '%llu'\n",
+ jt_cmdname(argv[0]), objid);
+ return -E2BIG;
+ }
+
+ data.ioc_obdo1.o_oi.oi_fid.f_oid = objid;
data.ioc_obdo1.o_mode = S_IFREG;
data.ioc_obdo1.o_valid = 0xffffffff;
memset(buf, 0, sizeof(rawbuf));
#endif
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
- ostid_set_id(&data.ioc_obdo1.o_oi, objid);
+ if (objid >= OBIF_MAX_OID) {
+ fprintf(stderr, "errr: %s: invalid objid '%llu'\n",
+ jt_cmdname(argv[0]), objid);
+ return -E2BIG;
+ }
+
+ data.ioc_obdo1.o_oi.oi_fid.f_oid = objid;
data.ioc_obdo1.o_mode = S_IFREG;
data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMODE |
OBD_MD_FLFLAGS | OBD_MD_FLGROUP;
struct obd_ioctl_data *data)
{
int cOpt;
- const char *const short_options = "c:l:i:h";
- const struct option long_options[] = {
- {"catalog", required_argument, NULL, 'c'},
- {"log_id", required_argument, NULL, 'l'},
- {"log_idx", required_argument, NULL, 'i'},
- {"help", no_argument, NULL, 'h'},
- {NULL, 0, NULL, 0}
- };
+ const char *const short_opts = "c:l:i:h";
+ const struct option long_opts[] = {
+ { .val = 'c', .name = "catalog", .has_arg = required_argument },
+ { .val = 'h', .name = "help", .has_arg = no_argument },
+ { .val = 'i', .name = "log_idx", .has_arg = required_argument },
+ { .val = 'l', .name = "log_id", .has_arg = required_argument },
+ { .name = NULL } };
/* sanity check */
if (!data || argc <= 1) {
}
/*now process command line arguments*/
- while ((cOpt = getopt_long(argc, argv, short_options,
- long_options, NULL)) != -1) {
+ while ((cOpt = getopt_long(argc, argv, short_opts,
+ long_opts, NULL)) != -1) {
switch (cOpt) {
case 'c':
data->ioc_inllen1 = strlen(optarg) + 1;
if (ostname != NULL)
lustre_cfg_bufs_set_string(&bufs, 2, ostname);
- lcfg = lustre_cfg_new(cmd, &bufs);
+
+ lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
if (lcfg == NULL)
return -ENOMEM;
+ lustre_cfg_init(lcfg, cmd, &bufs);
memset(&data, 0, sizeof(data));
rc = data.ioc_dev = get_mgs_device();
if (rc) {
fprintf(stderr, "error: %s: invalid ioctl\n",
jt_cmdname(cmdname));
- lustre_cfg_free(lcfg);
+ free(lcfg);
return rc;
}
rc = l_ioctl(OBD_DEV_ID, OBD_IOC_POOL, buf);
out:
if (rc)
rc = -errno;
- lustre_cfg_free(lcfg);
+ free(lcfg);
return rc;
}
}
va_end(ap);
- lcfg = lustre_cfg_new(cmd, &bufs);
+ lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
if (lcfg == NULL)
return -ENOMEM;
+ lustre_cfg_init(lcfg, cmd, &bufs);
memset(&data, 0, sizeof(data));
rc = data.ioc_dev = get_mgs_device();
memcpy(ret_data, data.ioc_pbuf1, ret_size);
}
out:
- lustre_cfg_free(lcfg);
+ free(lcfg);
return rc;
}
int rc = 0;
int c;
- static struct option long_options[] = {
- {
- .name = "name",
- .has_arg = required_argument,
- .flag = 0,
- .val = 'n',
- },
- {
- .name = "range",
- .has_arg = required_argument,
- .flag = 0,
- .val = 'r',
- },
- {
- NULL
- }
- };
+ static struct option long_opts[] = {
+ { .val = 'n', .name = "name", .has_arg = required_argument },
+ { .val = 'r', .name = "range", .has_arg = required_argument },
+ { .name = NULL } };
INIT_LIST_HEAD(&nidlist);
while ((c = getopt_long(argc, argv, "n:r:",
- long_options, NULL)) != -1) {
+ long_opts, NULL)) != -1) {
switch (c) {
case 'n':
nodemap_name = optarg;
int rc = 0;
int c;
- static struct option long_options[] = {
- {
- .name = "name",
- .has_arg = required_argument,
- .flag = 0,
- .val = 'n',
- },
- {
- .name = "fileset",
- .has_arg = required_argument,
- .flag = 0,
- .val = 'f',
- },
- {
- NULL
- }
- };
+ static struct option long_opts[] = {
+ { .val = 'f', .name = "fileset", .has_arg = required_argument },
+ { .val = 'n', .name = "name", .has_arg = required_argument },
+ { .name = NULL } };
while ((c = getopt_long(argc, argv, "n:f:",
- long_options, NULL)) != -1) {
+ long_opts, NULL)) != -1) {
switch (c) {
case 'n':
nodemap_name = optarg;
char *param = NULL;
char *value = NULL;
- static struct option long_options[] = {
- {
- .name = "name",
- .has_arg = required_argument,
- .flag = 0,
- .val = 'n',
- },
- {
- .name = "property",
- .has_arg = required_argument,
- .flag = 0,
- .val = 'p',
- },
- {
- .name = "value",
- .has_arg = required_argument,
- .flag = 0,
- .val = 'v',
- },
- {
- NULL
- }
- };
+ static struct option long_opts[] = {
+ { .val = 'n', .name = "name", .has_arg = required_argument },
+ { .val = 'p', .name = "property", .has_arg = required_argument },
+ { .val = 'v', .name = "value", .has_arg = required_argument },
+ { .name = NULL } };
while ((c = getopt_long(argc, argv, "n:p:v:",
- long_options, NULL)) != -1) {
+ long_opts, NULL)) != -1) {
switch (c) {
case 'n':
nodemap_name = optarg;
if (nodemap_name == NULL || param == NULL || value == NULL) {
fprintf(stderr, "usage: nodemap_modify --name <nodemap_name> "
"--property <property_name> --value <value>\n");
- fprintf(stderr, "valid properties: admin trusted "
+ fprintf(stderr, "valid properties: admin trusted map_mode "
"squash_uid squash_gid deny_unknown\n");
return -1;
}
cmd = LCFG_NODEMAP_SQUASH_UID;
} else if (strcmp("squash_gid", param) == 0) {
cmd = LCFG_NODEMAP_SQUASH_GID;
+ } else if (strcmp("map_mode", param) == 0) {
+ cmd = LCFG_NODEMAP_MAP_MODE;
} else {
fprintf(stderr, "error: %s: nodemap_modify invalid "
"subcommand: %s\n",
*ptr = '\0';
++ptr;
- rc = lustre_is_fsname_valid(fsname, 1, LUSTRE_MAXFSNAME);
- if (rc < 0) {
- fprintf(stderr, "filesystem name %s must be 1-%d chars\n",
- fsname, LUSTRE_MAXFSNAME);
- rc = -EINVAL;
- goto err;
- } else if (rc > 0) {
- fprintf(stderr, "char '%c' not allowed in filesystem name\n",
- rc);
- rc = -EINVAL;
- goto err;
- }
-
- rc = lustre_is_poolname_valid(ptr, 1, LOV_MAXPOOLNAME);
- if (rc == -1) {
+ if (strlen(ptr) == 0) {
fprintf(stderr, "poolname is empty\n");
rc = -EINVAL;
goto err;
- } else if (rc == -2) {
- fprintf(stderr,
- "poolname %s is too long (max is %d)\n",
- ptr, LOV_MAXPOOLNAME);
- rc = -ENAMETOOLONG;
- goto err;
- } else if (rc > 0) {
- fprintf(stderr, "char '%c' not allowed in pool name '%s'\n",
- rc, ptr);
- rc = -EINVAL;
- goto err;
}
strncpy(poolname, ptr, LOV_MAXPOOLNAME);