- * sysfs_open_subsystem_list: gets a list of all supported "name" subsystem
- * details from the system
- * @name: name of the subsystem, eg., "bus", "class", "devices"
- * Returns a dlist of supported names or NULL if subsystem not supported
- */
-struct dlist *sysfs_open_subsystem_list(char *name)
-{
- char sysfs_path[SYSFS_PATH_MAX], *subsys_name = NULL;
- char *c = NULL;
- struct sysfs_directory *dir = NULL, *cur = NULL;
- struct dlist *list = NULL;
-
- if (name == NULL)
- return NULL;
-
- if (sysfs_get_mnt_path(sysfs_path, SYSFS_PATH_MAX) != 0) {
- dprintf("Error getting sysfs mount point\n");
- return NULL;
- }
-
- safestrcat(sysfs_path, "/");
- safestrcat(sysfs_path, name);
- dir = sysfs_open_directory(sysfs_path);
- if (dir == NULL) {
- dprintf("Error opening sysfs_directory at %s\n", sysfs_path);
- return NULL;
- }
-
- if ((sysfs_read_dir_subdirs(dir)) != 0) {
- dprintf("Error reading sysfs_directory at %s\n", sysfs_path);
- sysfs_close_directory(dir);
- return NULL;
- }
-
- if (dir->subdirs != NULL) {
- list = dlist_new_with_delete(SYSFS_NAME_LEN,
- sysfs_del_name);
- if (list == NULL) {
- dprintf("Error creating list\n");
- sysfs_close_directory(dir);
- return NULL;
- }
-
- dlist_for_each_data(dir->subdirs, cur,
- struct sysfs_directory) {
- subsys_name = (char *)calloc(1, SYSFS_NAME_LEN);
- safestrcpymax(subsys_name, cur->name, SYSFS_NAME_LEN);
- dlist_unshift_sorted(list, subsys_name, sort_char);
- }
- }
- sysfs_close_directory(dir);
- /*
- * We are now considering "block" as a "class". Hence, if the subsys
- * name requested here is "class", verify if "block" is supported on
- * this system and return the same.
- */
- if (strcmp(name, SYSFS_CLASS_NAME) == 0) {
- c = strstr(sysfs_path, SYSFS_CLASS_NAME);
- if (c == NULL)
- goto out;
- *c = '\0';
- safestrcpymax(c, SYSFS_BLOCK_NAME,
- sizeof(sysfs_path) - strlen(sysfs_path));
- if ((sysfs_path_is_dir(sysfs_path)) == 0) {
- subsys_name = (char *)calloc(1, SYSFS_NAME_LEN);
- safestrcpymax(subsys_name, SYSFS_BLOCK_NAME,
- SYSFS_NAME_LEN);
- dlist_unshift_sorted(list, subsys_name, sort_char);
- }
- }
-out:
- return list;
-}
-
-
-/**
- * sysfs_open_bus_devices_list: gets a list of all devices on "name" bus
- * @name: name of the subsystem, eg., "pci", "scsi", "usb"
- * Returns a dlist of supported names or NULL if subsystem not supported
- */
-struct dlist *sysfs_open_bus_devices_list(char *name)