Hi everybody,
i'm trying to write in a file (foo) using sysfs.
I'll post part of using code:
Code:
static char foo[1024];
static int baz;
static char bar[1024];
/*
* The "foo" file where a static variable is read from and written to.
*/
static ssize_t foo_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) {
return sprintf(buf, "%s\n\n\n\n\n\n", foo);
}
static ssize_t foo_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count)
{
sscanf(buf, "%s", &foo);
return count;
}
static struct kobj_attribute foo_attribute =
__ATTR(foo, 0666, foo_show, foo_store);
I need a help. When i write a string (using echo), it seems work. When i write another one, the new one OVERWRITE the old one. Can I avoid this problem?
I note that, after writing a string, when i open the file, the cursor is positioning at the begin of the file...
Can you help me?