Edmond Rodriguez on 7 Oct 2009 21:04:07 -0700 |
I just learned today that I can do something like echo -n "mem" > /sys/power/state and the system responds, though I am not sure exactly what it is doing. Earlier I mentioned an error with a script trying to do echo -n "disk" > /sys/power/state . >From Googling more, for this particular file, I believe there is more to this than just writing to the file. As Sean mentioned in an earlier mail, maybe not all the hierarchy can be written to. At least not anything you want to put in there. It seems, the file, in some cases, and whatever is monitoring it needs to accept what you wish to put in there. The write error seems sort of like a bad return code when invoking a function with some parameter. Now assuming that is true, how to find out the reason for the error? That is, why the system does not wish to accept the content that is being written to a particular file. I've not researched this a whole lot, but this is what I am getting out of this so far. Edmond ----- Original Message ---- > From: Edmond Rodriguez <erodrig_97@yahoo.com> > To: Philadelphia Linux User's Group Discussion List <plug@lists.phillylinux.org> > Sent: Tuesday, October 6, 2009 2:53:15 PM > Subject: Re: [PLUG] Failure trying to write to a file in a virtual file system > > Interesting, and I unsuccessfully tried a few quick perl scripts (sysread and > syswrite), though it seems a bit complicated doing things as they suggest with > the buffers. Maybe using "C" would be more appropriate. > > Curious though that I see other documentation using the "echo -n >" method to > write data to /sys. > > But the text you copied below looks pretty clear to me that they want the entire > buffer read first, and then the entire buffer written. Could it be saying that > if you read the file, you must read the entire buffer, and same for writing? > I also ask myself, in my case, why "echo -n" works with some files, and not > others. > > > Here is a random example I googled relating to some setting for a system: > http://eslam-linux.blogspot.com/2009/02/ibm-thinkpad-trackpoint-configuration.html > # echo -n 255 > /sys/devices/platform/i8042/serio1/serio2/sensitivity > # echo -n 255 > /sys/devices/platform/i8042/serio1/serio2/speed > # echo -n 0 > /sys/devices/platform/i8042/serio1/serio2/press_to_select > > > ----- Original Message ---- > > From: Sean Collins > > To: plug@lists.phillylinux.org > > Sent: Tuesday, October 6, 2009 12:43:11 PM > > Subject: Re: [PLUG] Failure trying to write to a file in a virtual file system > > > > Ah - it may be this bit right here > > > > > 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. > > > > http://delcom.sourceforge.net/sysfs.txt > > > > When you echo something and pipe it into the sysfs mount, that's a > > stream. I think sysfs wants an atomic write. > > > > Again, a bit out on a limb here, but that's my best guess without > > access to my linux box. > > > > > > > > Thank You, > > > > Sean Collins > > > > ---------------------------------------------------------------- > > This message was sent using IMP, the Internet Messaging Program. > > > > ___________________________________________________________________________ > > Philadelphia Linux Users Group -- http://www.phillylinux.org > > Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce > > General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug > > ___________________________________________________________________________ > Philadelphia Linux Users Group -- http://www.phillylinux.org > Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce > General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|