return rc;
}
-int jt_obd_lov_getconfig(int argc, char **argv)
-{
- struct obd_ioctl_data data;
- struct lov_desc desc;
- struct obd_uuid *uuidarray;
- char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
- __u32 *obdgens;
- char *path;
- int rc, fd;
-
- memset(&data, 0, sizeof(data));
- data.ioc_dev = cur_device;
-
- if (argc != 2)
- return CMD_HELP;
-
- path = argv[1];
- fd = open(path, O_RDONLY);
- if (fd < 0) {
- fprintf(stderr, "open \"%s\" failed: %s\n", path,
- strerror(errno));
- return -errno;
- }
-
- memset(&desc, 0, sizeof(desc));
- obd_str2uuid(&desc.ld_uuid, argv[1]);
- desc.ld_tgt_count = ((MAX_IOC_BUFLEN - sizeof(data) - sizeof(desc)) /
- (sizeof(*uuidarray) + sizeof(*obdgens)));
-
-repeat:
- uuidarray = calloc(desc.ld_tgt_count, sizeof(*uuidarray));
- if (!uuidarray) {
- fprintf(stderr, "error: %s: no memory for %d uuid's\n",
- jt_cmdname(argv[0]), desc.ld_tgt_count);
- rc = -ENOMEM;
- goto out;
- }
- obdgens = calloc(desc.ld_tgt_count, sizeof(*obdgens));
- if (!obdgens) {
- fprintf(stderr, "error: %s: no memory for %d generation #'s\n",
- jt_cmdname(argv[0]), desc.ld_tgt_count);
- rc = -ENOMEM;
- goto out_uuidarray;
- }
-
- memset(buf, 0, sizeof(rawbuf));
- data.ioc_inllen1 = sizeof(desc);
- data.ioc_inlbuf1 = (char *)&desc;
- data.ioc_inllen2 = desc.ld_tgt_count * sizeof(*uuidarray);
- data.ioc_inlbuf2 = (char *)uuidarray;
- data.ioc_inllen3 = desc.ld_tgt_count * sizeof(*obdgens);
- data.ioc_inlbuf3 = (char *)obdgens;
-
- if (llapi_ioctl_pack(&data, &buf, sizeof(rawbuf))) {
- fprintf(stderr, "error: %s: invalid ioctl\n",
- jt_cmdname(argv[0]));
- rc = -EINVAL;
- goto out_obdgens;
- }
- rc = ioctl(fd, OBD_IOC_LOV_GET_CONFIG, buf);
- if (rc == -ENOSPC) {
- free(uuidarray);
- free(obdgens);
- goto repeat;
- } else if (rc) {
- fprintf(stderr, "error: %s: ioctl error: %s\n",
- jt_cmdname(argv[0]), strerror(rc = errno));
- } else {
- struct obd_uuid *uuidp;
- __u32 *genp;
- int i;
-
- if (llapi_ioctl_unpack(&data, buf, sizeof(rawbuf))) {
- fprintf(stderr, "error: %s: invalid reply\n",
- jt_cmdname(argv[0]));
- rc = -EINVAL;
- goto out;
- }
- if (desc.ld_default_stripe_count == (__u32)-1)
- printf("default_stripe_count: %d\n", -1);
- else
- printf("default_stripe_count: %u\n",
- desc.ld_default_stripe_count);
- printf("default_stripe_size: %ju\n",
- (uintmax_t)desc.ld_default_stripe_size);
- printf("default_stripe_offset: %jd\n",
- (uintmax_t)desc.ld_default_stripe_offset);
- printf("default_stripe_pattern: %u\n", desc.ld_pattern);
- printf("obd_count: %u\n", desc.ld_tgt_count);
- printf("OBDS:\tobdidx\t\tobdgen\t\t obduuid\n");
- uuidp = uuidarray;
- genp = obdgens;
- for (i = 0; i < desc.ld_tgt_count; i++, uuidp++, genp++)
- printf("\t%6u\t%14u\t\t %s\n", i, *genp, (char *)uuidp);
- }
-out_obdgens:
- free(obdgens);
-out_uuidarray:
- free(uuidarray);
-out:
- close(fd);
- return rc;
-}
-
static int do_activate(int argc, char **argv, int flag)
{
struct obd_ioctl_data data;