• Patrick Mochel's avatar
    sysfs: do permission checking on open. · 0de8c962
    Patrick Mochel authored
    sysfs has always had a bug that would allow a read-only file to be opened 
    for writing. It has also returned 0 on write when there was no store method
    defined for the file. 
    
    This addresses both via sysfs_open_file(). It checks the flags the file was
    opened with and compares them with the mode of the inode. If the mode does
    not support the flags passed, -EPERM is returned.
    
    If the sysfs_ops for the object does not have the correct method for the 
    flags, -EACCESS is returned. 
    
    Since all checks happen on open(), the corresponding checks in the read()
    and write() methods have been removed. 
    0de8c962
inode.c 15.1 KB