summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormananth <mananth>2004-09-13 06:08:24 +0000
committermananth <mananth>2004-09-13 06:08:24 +0000
commita9ac2db48af3a0fabff0b4f31ec32f1ae18737ca (patch)
tree09980d8f2b940605ce6752ad6bf111ccdd594c5f
parente1b69e0eb78f426731bbbcd48dedfd61f7f7dd12 (diff)
downloadsysfsutils-a9ac2db48af3a0fabff0b4f31ec32f1ae18737ca.tar.gz
systool now throws error if sysfs is not mounted
-rw-r--r--ChangeLog4
-rw-r--r--cmd/systool.c24
2 files changed, 25 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 3b59dca..34e7ad4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
+09/13/2004 - Daniel Stekloff <dsteklof@us.ibm.com>
+ * Patch systool to print error if sysfs
+ is not mounted
+
09/10/2004 - Ananth Mavinakayanahalli <ananth@in.ibm.com>
* Changed version number in package files
to 1.2.0
diff --git a/cmd/systool.c b/cmd/systool.c
index 1bd0137..d3f938a 100644
--- a/cmd/systool.c
+++ b/cmd/systool.c
@@ -617,8 +617,8 @@ static int show_default_info(void)
fprintf(stdout, "Supported sysfs buses:\n");
dlist_for_each_data(list, cur, char)
fprintf(stdout, "\t%s\n", cur);
+ sysfs_close_list(list);
}
- sysfs_close_list(list);
safestrcpy(subsys, SYSFS_CLASS_NAME);
list = sysfs_open_subsystem_list(subsys);
@@ -626,8 +626,8 @@ static int show_default_info(void)
fprintf(stdout, "Supported sysfs classes:\n");
dlist_for_each_data(list, cur, char)
fprintf(stdout, "\t%s\n", cur);
+ sysfs_close_list(list);
}
- sysfs_close_list(list);
safestrcpy(subsys, SYSFS_DEVICES_NAME);
list = sysfs_open_subsystem_list(subsys);
@@ -635,12 +635,25 @@ static int show_default_info(void)
fprintf(stdout, "Supported sysfs devices:\n");
dlist_for_each_data(list, cur, char)
fprintf(stdout, "\t%s\n", cur);
+ sysfs_close_list(list);
}
- sysfs_close_list(list);
return retval;
}
+/**
+ * check_sysfs_mounted: Checks to see if sysfs is mounted.
+ * returns 0 if not and 1 if true.
+ */
+static int check_sysfs_is_mounted(void)
+{
+ char path[SYSFS_PATH_MAX];
+
+ if (sysfs_get_mnt_path(path, SYSFS_PATH_MAX) != 0)
+ return 0;
+ return 1;
+}
+
/* MAIN */
int main(int argc, char *argv[])
{
@@ -724,6 +737,11 @@ int main(int argc, char *argv[])
exit(1);
}
+ if (check_sysfs_is_mounted() == 0) {
+ fprintf(stderr, "Unable to find sysfs mount point!\n");
+ exit(1);
+ }
+
if ((show_bus == NULL && show_class == NULL && show_root == NULL) &&
(show_options & (SHOW_ATTRIBUTES |
SHOW_ATTRIBUTE_VALUE | SHOW_DEVICES |