* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
-#include "sysfs/libsysfs.h"
+#include "libsysfs.h"
#include "sysfs.h"
/**
sysattr->value = (char *)realloc
(sysattr->value, length);
sysattr->len = length;
- safestrncpy(sysattr->value, new_value, length);
+ safestrcpymax(sysattr->value, new_value, length);
} else {
/*"length" of the new value is same as old one */
- safestrncpy(sysattr->value, new_value, length);
+ safestrcpymax(sysattr->value, new_value, length);
}
}
errno = EACCES;
return -1;
}
- pgsize = getpagesize();
+ pgsize = sysconf(_SC_PAGESIZE);
fbuf = (char *)calloc(1, pgsize+1);
if (fbuf == NULL) {
dprintf("calloc failed\n");
if (length > vsize)
dprintf("Value length %d is larger than supplied buffer %d\n",
length, vsize);
- safestrncpy(value, attr->value, vsize);
+ safestrcpymax(value, attr->value, vsize);
sysfs_close_attribute(attr);
return 0;
safestrcpy(ln->path, linkpath);
if ((sysfs_get_name_from_path(linkpath, ln->name, SYSFS_NAME_LEN)) != 0
|| (sysfs_get_link(linkpath, ln->target, SYSFS_PATH_MAX)) != 0) {
+ sysfs_close_link(ln);
errno = EINVAL;
dprintf("Invalid link path %s\n", linkpath);
return NULL;
attr = (struct sysfs_attribute *)dlist_find_custom
(dir->attributes, attrname, dir_attribute_name_equal);
if (attr != NULL) {
- if ((sysfs_read_attribute(attr)) != 0) {
+ if ((attr->method & SYSFS_METHOD_SHOW) &&
+ (sysfs_read_attribute(attr)) != 0) {
dprintf("Error reading attribute %s\n", attr->name);
return NULL;
}