[maemo-developers] [maemo-developers] Adding swapon/off to Jakub's Load-Plugin applet

From: Armin M. Warda Armin.Warda at Web.De
Date: Thu Feb 23 01:12:18 EET 2006
  Hi,

I am currently adding a swapon/off menu-item to Jakub's Load-Plugin,

  http://koti.welho.com/jpavelek/tmp/770/

which he recently released under the LGPL. The new swapon/off feature 
might look like this:

  http://www.arminwarda.mynetcologne.de/load-applet-1.png
  http://www.arminwarda.mynetcologne.de/load-applet-2.png
  http://www.arminwarda.mynetcologne.de/load-applet-3.png

This feature will be useful for those who have a swap on the RS-MMC. 
(You really should swapoff before you unplug the RS-MMS...)

What I achieved yet by modifying Jakub's released source:
- add the 'swapon/off' menu entry (does nothing yet)
- this menu entry automatically changes from swapoff to
  swapon and vice versa, depending on the current state
- shows the current swap usage in MB
- add a 'Swapfile' config string to the settings menu
- make all settings persistent over reboots via gconf
- discover an active swapfile on start (=boot), if none set via gconf

Any suggestions?

There is still (at least) one open issue: the Load-Plugin applet runs 
as 'user', swapon/off needs 'root'. I don' want to have every user 
add two lines to /etc/sudoers, I need a more elegant way to solve 
this.

Andrew Flegg recommends to
> Open a pty and drive a root-enabled shell through `sudo gainroot'?

Unfortunately, I do not know how to do that. I am not an experienced 
hacker or C coder, but I try to contribute. Can anybody provide some 
C code sniplet that demonstrates how I can open a pty and drive a 
root-enabled shell through sudo gainroot?

> Then users will only have to ensure R&D mode is enabled without any
> further hacking.

Yes, that would be much better than hacking /etc/sudoers. 
Everybody who wants to use swap has to enable R&D mode anyway...

I will create a patch of my changes and will ask Jakub to include it. 
I hope he will continue to maintain the load-plugin, otherwise I (or 
someone else) would have to fork it. But I am no experienced coder,
thus I would prefer to not have to maintain it myself. (Hmm, I feel 
shame for my code quality, so actually I'd also like to have somebody 
clean it up...)

  Armin.

-- 
   --- May the Source be with you! Linux. ---
   --- http://www.arminwarda.mynetcologne.de/
   --- secure eMail: http://www.gnupg.de/ ---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.maemo.org/pipermail/maemo-developers/attachments/20060223/17029d9e/attachment.pgp 
More information about the maemo-developers mailing list