Skip to content

Commit

Permalink
sysfs.txt: mention that store method buffers are null-terminated
Browse files Browse the repository at this point in the history
Without knowing this, the use of sysfs_streq() becomes puzzling.

The termination happens in kernfs_fop_write().

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
[jc: moved the new text to a different paragraph]
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
  • Loading branch information
Ulf Magnusson authored and Jonathan Corbet committed Sep 13, 2015
1 parent 9ba4132 commit 1766649
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Documentation/filesystems/sysfs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ implementations:
be called again, rearmed, to fill the buffer.

- On write(2), sysfs expects the entire buffer to be passed during the
first write. Sysfs then passes the entire buffer to the store()
method.

first write. Sysfs then passes the entire buffer to the store() method.
A terminating null is added after the data on stores. This makes
functions like sysfs_streq() safe to use.

When writing sysfs files, userspace processes should first read the
entire file, modify the values it wishes to change, then write the
entire buffer back.
Expand Down

0 comments on commit 1766649

Please sign in to comment.