diff options
author | ananthmg@rediffmail.com <ananthmg@rediffmail.com> | 2004-01-14 22:21:38 -0800 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 21:13:16 -0700 |
commit | 616a7078071362b32a4db73fe3314feb46438258 (patch) | |
tree | e41db664958d69cde4bcc7bcf91a96a1ba8eec78 /libsysfs/sysfs_bus.c | |
parent | 1782087e4f80fd1d8c4d8bd9a6edeed27414426e (diff) |
[PATCH] libsysfs update for refresh + namedev.c changes
Please find inlined a patch which contains updates to libsysfs
(pre-release) for refresh and also changes to namedev.c to take
advantage of it.
Diffstat (limited to 'libsysfs/sysfs_bus.c')
-rw-r--r-- | libsysfs/sysfs_bus.c | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/libsysfs/sysfs_bus.c b/libsysfs/sysfs_bus.c index d9da0f84cf..aca392875e 100644 --- a/libsysfs/sysfs_bus.c +++ b/libsysfs/sysfs_bus.c @@ -209,9 +209,7 @@ struct sysfs_bus *sysfs_open_bus(const unsigned char *name) return NULL; } - if (sysfs_trailing_slash(buspath) == 0) - strcat(buspath, "/"); - + strcat(buspath, "/"); strcat(buspath, SYSFS_BUS_NAME); strcat(buspath, "/"); strcat(buspath, name); @@ -226,6 +224,11 @@ struct sysfs_bus *sysfs_open_bus(const unsigned char *name) } strcpy(bus->name, name); strcpy(bus->path, buspath); + if ((sysfs_remove_trailing_slash(bus->path)) != 0) { + dprintf("Incorrect path to bus %s\n", bus->path); + sysfs_close_bus(bus); + return NULL; + } return bus; } @@ -296,21 +299,38 @@ struct dlist *sysfs_get_bus_attributes(struct sysfs_bus *bus) if (bus->directory->attributes == NULL) { if ((sysfs_read_dir_attributes(bus->directory)) != 0) return NULL; - } else { - if ((sysfs_path_is_dir(bus->path)) != 0) { - dprintf("Bus at %s no longer exists\n", bus->path); - return NULL; - } - if ((sysfs_refresh_attributes - (bus->directory->attributes)) != 0) { - dprintf("Error refreshing bus attributes\n"); - return NULL; - } } return bus->directory->attributes; } /** + * sysfs_refresh_bus_attributes: refreshes the bus's list of attributes + * @bus: sysfs_bus whose attributes to refresh + * + * NOTE: Upon return, prior references to sysfs_attributes for this bus + * _may_ not be valid + * + * Returns list of attributes on success and NULL on failure + */ +struct dlist *sysfs_refresh_bus_attributes(struct sysfs_bus *bus) +{ + if (bus == NULL) { + errno = EINVAL; + return NULL; + } + + if (bus->directory == NULL) + return (sysfs_get_bus_attributes(bus)); + + if ((sysfs_refresh_dir_attributes(bus->directory)) != 0) { + dprintf("Error refreshing bus attributes\n"); + return NULL; + } + + return (bus->directory->attributes); +} + +/** * sysfs_get_bus_attribute: gets a specific bus attribute, if buses had * attributes. * @bus: bus to retrieve attribute from @@ -357,8 +377,7 @@ struct sysfs_device *sysfs_open_bus_device(unsigned char *busname, return NULL; } - if (sysfs_trailing_slash(path) == 0) - strcat(path, "/"); + strcat(path, "/"); strcat(path, SYSFS_BUS_NAME); strcat(path, "/"); strcat(path, busname); |