diff --git a/lustre/include/linux/lustre_lib.h b/lustre/include/linux/lustre_lib.h index 79671e8e0e075a00ca5ed8790bc5cf71041531fc..0ad0ec78a069906226cb96222c3ca49a87c4f752 100644 --- a/lustre/include/linux/lustre_lib.h +++ b/lustre/include/linux/lustre_lib.h @@ -413,7 +413,6 @@ static inline void obd_ioctl_freedata(char *buf, int len) #define OBD_IOC_BRW_READ _IOWR('f', 125, long) #define OBD_IOC_BRW_WRITE _IOWR('f', 126, long) #define OBD_IOC_NAME2DEV _IOWR('f', 127, long) -#define OBD_IOC_LIST _IOWR('f', 129, long) #define OBD_IOC_UUID2DEV _IOWR('f', 130, long) #define OBD_IOC_LOV_GET_CONFIG _IOWR('f', 132, long) diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 4bc582803480c977281216ddb89c267f054dad15..a807fd84af163c5ab07d5219ea55a77c535cb3ab 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -220,50 +220,6 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) GOTO(out, err); } - case OBD_IOC_LIST: { - int i; - char *buf2 = data->ioc_bulk; - int remains = data->ioc_inllen1; - - if (!data->ioc_inlbuf1) { - CERROR("No buffer passed!\n"); - GOTO(out, err = -EINVAL); - } - - - for (i = 0 ; i < MAX_OBD_DEVICES ; i++) { - int l; - char *status; - struct obd_device *obd = &obd_dev[i]; - - if (!obd->obd_type) - continue; - if (obd->obd_stopping) - status = "ST"; - else if (obd->obd_set_up) - status = "UP"; - else if (obd->obd_attached) - status = "AT"; - else - status = "-"; - l = snprintf(buf2, remains, "%2d %s %s %s %s %d\n", - i, status, obd->obd_type->typ_name, - obd->obd_name, obd->obd_uuid.uuid, - obd->obd_type->typ_refcnt); - buf2 +=l; - remains -=l; - if (remains <= 0) { - CERROR("not enough space for device listing\n"); - break; - } - } - - err = copy_to_user((void *)arg, data, len); - if (err) - err = -EFAULT; - GOTO(out, err); - } - case OBD_GET_VERSION: if (!data->ioc_inlbuf1) { CERROR("No buffer passed in ioctl\n"); diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 6fcfc4d9b2029e2970810608c7155a828304d04b..0cf4489b6d011956d0ef81b01ed94fa5994c6bde 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -461,57 +461,47 @@ out: } #define MAX_STRING_SIZE 128 +#define DEVICES_LIST "/proc/fs/lustre/devices" int op_check(int type_num, char **obd_type, char *dir) { - int rc=0; - int i=0,j=0,k; - char buf[OBD_MAX_IOCTL_BUFFER]; - char *buf2; - struct obd_ioctl_data *data = (struct obd_ioctl_data *)buf; - - memset(buf, 0, sizeof(buf)); - data->ioc_version = OBD_IOCTL_VERSION; - data->ioc_inllen1 = sizeof(buf) - size_round(sizeof(*data)); - data->ioc_len = obd_ioctl_packlen(data); - - rc = l_ioctl(OBD_DEV_ID, OBD_IOC_LIST, data); - - buf2 = data->ioc_bulk; - - if (!data->ioc_inlbuf1) { - err_msg("No buffer passed!\n"); - rc = errno; + int rc = 0; + int i; + + char buf[MAX_STRING_SIZE]; + FILE *fp = fopen(DEVICES_LIST, "r"); + + if (fp == NULL) { + fprintf(stderr, "error: %s could not open file " + DEVICES_LIST " .\n", strerror(rc = errno)); + return rc; } - do { - char status[3]; - char obd_type_name[sizeof(struct obd_type)]; - char obd_name[MAX_STRING_SIZE]; - char obd_uuid[sizeof(struct obd_uuid)]; - int obd_type_refcnt; + while (fgets(buf, sizeof(buf), fp) != NULL) { + char *obd_type_name = NULL; + char *obd_name = NULL; char rawbuf[OBD_MAX_IOCTL_BUFFER]; char *bufl = rawbuf; + char *bufp = buf; int max = sizeof(rawbuf); struct obd_ioctl_data datal; struct obd_statfs osfs_buffer; + while(bufp[0] == ' ') bufp += 1; + for(i = 0; i < 3; i++) { + obd_type_name = strsep(&bufp, " "); + } + obd_name = strsep(&bufp, " "); + memset (&osfs_buffer, 0, sizeof (osfs_buffer)); memset(bufl, 0, sizeof(rawbuf)); datal.ioc_pbuf1 = (char *)&osfs_buffer; datal.ioc_plen1 = sizeof (osfs_buffer); - j = sscanf(buf2,"%d %s %s %s %s %d",&j, - status,obd_type_name, - obd_name, obd_uuid, - &obd_type_refcnt); - - if (j != 6) break; - - for (k=0;k<type_num;k++) - if (strcmp(obd_type_name, obd_type[k]) == 0) { + for (i=0;i<type_num;i++) + if (strcmp(obd_type_name, obd_type[i]) == 0) { datal.ioc_inlbuf1 = obd_name; datal.ioc_inllen1 = strlen(obd_name) + 1; @@ -527,13 +517,8 @@ int op_check(int type_num, char **obd_type, char *dir) } } - if (j==6) - for (i=0;buf2[i]!= '\n';i++); - - buf2 +=(i+1); - - } while (j==6); - + } + fclose(fp); return rc; } diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index bdd533a76fda8a9ad66702263a4e489b19fb372b..9de30587ae244e703777e64b10817ac4246a6108 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -60,6 +60,9 @@ #include <stdio.h> #define SHMEM_STATS 1 +#define MAX_STRING_SIZE 128 +#define DEVICES_LIST "/proc/fs/lustre/devices" + #if SHMEM_STATS # include <sys/ipc.h> # include <sys/shm.h> @@ -774,26 +777,25 @@ int jt_get_version(int argc, char **argv) int jt_obd_list(int argc, char **argv) { int rc; - char buf[OBD_MAX_IOCTL_BUFFER]; - struct obd_ioctl_data *data = (struct obd_ioctl_data *)buf; - + char buf[MAX_STRING_SIZE]; + FILE *fp = fopen(DEVICES_LIST, "r"); + + if (fp == NULL) { + fprintf(stderr, "error: %s: %s could not open file " + DEVICES_LIST " .\n", + jt_cmdname(argv[0]), strerror(rc = errno)); + return rc; + } + if (argc != 1) return CMD_HELP; - - memset(buf, 0, sizeof(buf)); - data->ioc_version = OBD_IOCTL_VERSION; - data->ioc_inllen1 = sizeof(buf) - size_round(sizeof(*data)); - data->ioc_len = obd_ioctl_packlen(data); - - rc = l2_ioctl(OBD_DEV_ID, OBD_IOC_LIST, data); - if (rc < 0) - fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]), - strerror(rc = errno)); - else { - printf("%s", data->ioc_bulk); - } - - return rc; + + while (fgets(buf, sizeof(buf), fp) != NULL) + printf("%s", buf); + + fclose(fp); + + return 0; } /* Get echo client's stripe meta-data for the given object