Issue1856

classification
Title: Permission denied when writing to files under /sys (sysfs) directory
Type: Severity: normal
Components: Core Versions: Jython 2.5
process
Status: open Resolution: remind
Dependencies: Superseder:
Assigned To: Nosy List: amak, fwierzbicki, halfie
Priority: Keywords:

Created on 2012-03-19.09:36:50 by halfie, last changed 2014-05-22.00:05:31 by zyasoft.

Files
File name Uploaded Description Edit Remove
jyproc.py halfie, 2012-03-19.09:36:50 test script
sysfs.java halfie, 2012-03-19.12:08:39 Test Case in Java
Messages
msg6816 (view) Author: halfie (halfie) Date: 2012-03-19.09:36:49
I am unable to write to files under /sys (sysfs) directory using Jython 2.5.2

When I run the attached "jyproc.py" file, I get

Traceback (most recent call last):
  File "jyproc.py", line 4, in <module>
    f.write("1")
IOError: [Errno 13] Permission denied: '/sys/block/sdc/device/delete'

...

Same code runs fine under Python 2.7.2. 

$ jython -V
Jython 2.5.2

$ java -version
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)
msg6817 (view) Author: halfie (halfie) Date: 2012-03-19.12:08:38
Attaching similar program written in Java which works just fine. So it doesn't seem to be a Java problem but a Jython problem.
msg7750 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2013-02-25.20:28:22
Sorry for the slow response - can you tell me more about your platform? Mainly what os you are on and some details about how /sys (sysfs) is mounted etc?
msg7782 (view) Author: halfie (halfie) Date: 2013-02-26.04:30:33
I am running CentOS 6.3 64-bit which uses Linux 2.6.32.x kernel.

$ mount | grep sysfs 
sysfs on /sys type sysfs (rw)

$ java -version
java version "1.7.0_09-icedtea"
OpenJDK Runtime Environment (rhel-2.3.7.1.el6_3-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Nothing fancy :)
msg7784 (view) Author: Alan Kennedy (amak) Date: 2013-02-26.08:32:47
Please can you run the following jython code on your system and report the results?

Thanks.

################
from java.io import BufferedWriter, FileWriter
import java.lang

if __name__ == "__main__":
    fileName = "/sys/block/sdb/device/delete"
    try:
        writer = BufferedWriter(FileWriter(fileName,True))
        writer.write("1")
        writer.close()
    except java.lang.Exception, e:
        e.printStackTrace()
################
History
Date User Action Args
2014-05-22 00:05:31zyasoftsetresolution: remind
2013-02-26 08:32:47amaksetmessages: + msg7784
2013-02-26 07:56:08amaksetnosy: + amak
2013-02-26 04:30:34halfiesetmessages: + msg7782
2013-02-25 20:28:22fwierzbickisetnosy: + fwierzbicki
messages: + msg7750
versions: + Jython 2.5, - 2.5.2
2012-03-19 12:08:39halfiesetfiles: + sysfs.java
messages: + msg6817
2012-03-19 09:36:50halfiecreate