Salve a tutti,
sto provando a scrivere in un file (foo) con sysfs.
Vi posto parte del codice utilizzato:
Mi serve un aiuto. Quando scrivo una stringa (tramite il comando echo da shell) la inserisce correttamente. Il problema è che quando ne scrivo un'altra, la nuova SOVRASCRIVE la vecchia, mentre invece a me servirebbe scrivere tante righe una sotto l'altra.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);
Come posso evitare ciò?
Quello che noto è che, dopo aver scritto una stringa, all'apertura del file, il cursore del mouse si trova ALL'INIZIO del file...
Mi aiutate?
grazie
Segnalibri