summaryrefslogtreecommitdiffstats
path: root/include/sysfs.h
diff options
context:
space:
mode:
authorKarel Zak2011-05-18 11:57:17 +0200
committerKarel Zak2011-05-18 11:57:17 +0200
commit90e9fcda3bb3a215f027fc66c1182a18e0746972 (patch)
treecd10e1fd1fe586cf3d08287c82f30cd7e4edce72 /include/sysfs.h
parentbuild-sys: disable lib/ at.c tests building (diff)
downloadkernel-qcow2-util-linux-90e9fcda3bb3a215f027fc66c1182a18e0746972.tar.gz
kernel-qcow2-util-linux-90e9fcda3bb3a215f027fc66c1182a18e0746972.tar.xz
kernel-qcow2-util-linux-90e9fcda3bb3a215f027fc66c1182a18e0746972.zip
lib: [sysfs.c] make sysfs_read_* function more robust
The functions does not modify result if the requested sysfs attribute does not exist. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include/sysfs.h')
-rw-r--r--include/sysfs.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/include/sysfs.h b/include/sysfs.h
index ed11a5e19..5190ac482 100644
--- a/include/sysfs.h
+++ b/include/sysfs.h
@@ -44,9 +44,11 @@ extern int sysfs_has_attribute(struct sysfs_cxt *cxt, const char *attr);
extern int sysfs_scanf(struct sysfs_cxt *cxt, const char *attr,
const char *fmt, ...)
__attribute__ ((format (scanf, 3, 4)));
-extern int64_t sysfs_read_s64(struct sysfs_cxt *cxt, const char *attr);
-extern uint64_t sysfs_read_u64(struct sysfs_cxt *cxt, const char *attr);
-extern int sysfs_read_int(struct sysfs_cxt *cxt, const char *attr);
+
+extern int sysfs_read_s64(struct sysfs_cxt *cxt, const char *attr, int64_t *res);
+extern int sysfs_read_u64(struct sysfs_cxt *cxt, const char *attr, uint64_t *res);
+extern int sysfs_read_int(struct sysfs_cxt *cxt, const char *attr, int *res);
+
extern char *sysfs_strdup(struct sysfs_cxt *cxt, const char *attr);
extern int sysfs_count_dirents(struct sysfs_cxt *cxt, const char *attr);