src/dpdk/drivers/bus/vmbus/linux/vmbus_bus.c
static int
parse_sysfs_uuid(const char *filename, rte_uuid_t uu)
{
	char buf[BUFSIZ];
	char *cp, *in = buf;
	FILE *f;

	f = fopen(filename, "r");
	if (f == NULL) {
		VMBUS_LOG(ERR, "cannot open sysfs value %s: %s",
			  filename, strerror(errno));
		return -1;
	}

	if (fgets(buf, sizeof(buf), f) == NULL) {
		VMBUS_LOG(ERR, "cannot read sysfs value %s",
				filename);
		fclose(f);
		return -1;
	}
	fclose(f);

	cp = strchr(buf, '\n');
	if (cp)
		*cp = '\0';

	/* strip { } notation */
	if (buf[0] == '{') {
		in = buf + 1;
		cp = strchr(in, '}');
		if (cp)
			*cp = '\0';
	}

	if (rte_uuid_parse(in, uu) < 0) {
		VMBUS_LOG(ERR, "%s %s not a valid UUID",
			filename, buf);
		return -1;
	}

	return 0;
}
/* Read sysfs file to get UUID */
Read sysfs file to get UUID
Read sysfs file to get UUID
static int
parse_sysfs_uuid(const char *filename, rte_uuid_t uu)
{
	char buf[BUFSIZ];
	char *cp, *in = buf;
	FILE *f;
	f = fopen(filename, "r");
	if (f == NULL) {
		VMBUS_LOG(ERR, "cannot open sysfs value %s: %s",
			  filename, strerror(errno));
		return -1;
	}
	if (fgets(buf, sizeof(buf), f) == NULL) {
		VMBUS_LOG(ERR, "cannot read sysfs value %s",
				filename);
		fclose(f);
		return -1;
	}
	fclose(f);
	cp = strchr(buf, '\n');
	if (cp)
		*cp = '\0';
	if (buf[0] == '{') {
		in = buf + 1;
		cp = strchr(in, '}');
		if (cp)
			*cp = '\0';
	}
	if (rte_uuid_parse(in, uu) < 0) {
		VMBUS_LOG(ERR, "%s %s not a valid UUID",
			filename, buf);
		return -1;
	}
	return 0;
}
static int parse_sysfs_uuid ( const char * filename , rte_uuid_t uu ) { char buf [ BUFSIZ ] ; char * cp , * in = buf ; FILE * f ; f = fopen ( filename , " " ) ; if ( f == NULL ) { VMBUS_LOG ( ERR , " " , filename , strerror ( errno ) ) ; return -1 ; } if ( fgets ( buf , sizeof ( buf ) , f ) == NULL ) { VMBUS_LOG ( ERR , " " , filename ) ; fclose ( f ) ; return -1 ; } fclose ( f ) ; cp = strchr ( buf , ' \n ' ) ; if ( cp ) * cp = ' \0 ' ; if ( buf [ 0 ] == ' ' ) { in = buf + 1 ; cp = strchr ( in , ' ' ) ; if ( cp ) * cp = ' \0 ' ; } if ( rte_uuid_parse ( in , uu ) < 0 ) { VMBUS_LOG ( ERR , " " , filename , buf ) ; return -1 ; } return 0 ; }
Read sysfs file to get UUID
Read sysfs file to get UUID
/* strip { } notation */