• Patrick Mochel's avatar
    sysfs: Improve read/write buffer filling/flushing semantics. · 71074f8c
    Patrick Mochel authored
    These are sysfs internal changes only, though they have positive external 
    effects. 
    
    A new data type (struct sysfs_buffer) is defined to describe and maintain
    state of the data for an attribute file. This object is allocated and 
    initialized when the file is opened. It contains a page-sized buffer that
    is allocated during the first read or write. 
    
    For read(), the buffer is filled when it is allocated by calling the 
    attribute's show() method. This only happens when a read occurs from offset
    0 in the file. For all read()s, the portion of the file requested is copied
    to userspace. This finally fixes a long-standing bug in partial read()s.
    
    For write(), the buffer is filled when it is allocated by copying the user-
    supplied buffer from userspace into it. This buffer is then passed to the
    attribute's store() method. This is not much different than what was present
    before.
    
    Note that partial-writes are not-supported. There is no way to know if a 
    user process is doing a partial write, and has more buffer to write. So, we
    take the easy route and assume that the entire buffer is passed during the
    first write.
    71074f8c
inode.c 18.8 KB