From eb4488d77fb71e7891708a763df3829d655a0a66 Mon Sep 17 00:00:00 2001 From: adilger Date: Thu, 12 Feb 2004 19:55:35 +0000 Subject: [PATCH] Update b_smallfix from HEAD (20040212_1234) --- lustre/utils/liblustreapi.c | 65 +++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 40 deletions(-) diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 6fcfc4d..0cf4489 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