diff options
author | mananth <mananth> | 2003-11-06 06:30:45 +0000 |
---|---|---|
committer | mananth <mananth> | 2003-11-06 06:30:45 +0000 |
commit | 2412af53b271f998713307aea1e76d744fff733d (patch) | |
tree | cc3af77f18155953b572db201ef46090263f31a1 /lib/sysfs_utils.c | |
parent | d874adee536019b3565f5b6620c30bc27c2b799b (diff) | |
download | sysfsutils_0_3_0.tar.gz |
Final set of patches for release 0.3.0sysfsutils_0_3_0
Diffstat (limited to 'lib/sysfs_utils.c')
-rw-r--r-- | lib/sysfs_utils.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/sysfs_utils.c b/lib/sysfs_utils.c index 2465eb0..7563dff 100644 --- a/lib/sysfs_utils.c +++ b/lib/sysfs_utils.c @@ -205,8 +205,10 @@ void sysfs_close_list(struct dlist *list) struct dlist *sysfs_open_subsystem_list(unsigned char *name) { unsigned char sysfs_path[SYSFS_PATH_MAX], *subsys_name = NULL; + unsigned char *c = NULL; struct sysfs_directory *dir = NULL, *cur = NULL; struct dlist *list = NULL; + struct stat astats; if (name == NULL) return NULL; @@ -246,6 +248,27 @@ struct dlist *sysfs_open_subsystem_list(unsigned char *name) } } 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_DIR) == 0) { + c = strstr(sysfs_path, SYSFS_CLASS_NAME); + if (c == NULL) + goto out; + strcpy(c, SYSFS_BLOCK_NAME); + if ((lstat(sysfs_path, &astats)) != 0) { + dprintf("stat() failed\n"); + goto out; + } + if (S_ISDIR(astats.st_mode)) { + subsys_name = (char *)calloc(1, SYSFS_NAME_LEN); + strcpy(subsys_name, SYSFS_BLOCK_NAME); + dlist_unshift(list, subsys_name); + } + } +out: return list; } |