Skip to content
Advertisement

Are sysfs binary attributes allowed to return more than one page of data?

I’m writing a linux device driver that, among other things, exposes a readonly binary attribute in sysfs, the interface for which is

JavaScript

When I try to cat or hexdump the file, after the first 4096 bytes, my driver will be given a zero-sized read (It is passed 0 for size). Why is this happening, and how should my driver respond if it’s not logically at EOF? (A response of 0 would indicate EOF, but any longer response seems like it would be inviting some sort of a buffer overflow. Currently, I return -EINVAL.)

Are sysfs binary attributes allowed to return more than one page of information?

Advertisement

Answer

It turns out I had set the maximum size when registering the attribute to 4096… Oops.

Advertisement