[Toybox] [Patch] - freeramdisk, openvt & deallocvt

Vivek Bhagat vivek.bhagat89 at gmail.com
Wed Feb 5 05:19:03 PST 2014


Hi List,

This is my first post on ToyBox community.

Please find the patches attached herewith for adding 3 new commands -
1. freeramdisk - If we unmount or detach the RAM disk based file system the
Linux Kernel
   will not free the allocated memory associated with the RAM device. This
can be useful if
   one wants to mount this device again:  All data will be preserved.
   If we need to free the memory back to the Kernel, one can use the
command: "toybox freeramdisk <RAM device>".

2. openvt - Successfully opens a new virtual terminal as mentioned with -c
option
        otherwise search and open next available VT.
 with -s option it switches to new VT
with -s -w option, it switch back successfully to originating VT.

3. deallocvt - Deallocate specified virtual teminal.
    if no virtual terminal is specified, it deallocates all unused VT.

Please find the test log attached here for above 3 commands.
Your inputs are welcome.

Thanks.
Vivek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20140205/50ca7012/attachment-0003.htm>
-------------- next part --------------

vbhagat at Leo:~/toybox$ sudo mke2fs /dev/ram0
[sudo] password for vbhagat: 
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
16384 inodes, 65536 blocks
3276 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67108864
8 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks: 
	8193, 24577, 40961, 57345

Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
vbhagat at Leo:~/toybox$ sudo mkdir /mnt/ram0
vbhagat at Leo:~/toybox$ sudo mount /dev/ram0 /mnt/ram0/
vbhagat at Leo:~/toybox$ sudo dd if=/dev/ram0 bs=1k count=3072 of=/mnt/ram0/3mb
3072+0 records in
3072+0 records out
3145728 bytes (3.1 MB) copied, 0.0269973 s, 117 MB/s
vbhagat at Leo:~/toybox$ free -k
                       total       used          free     shared    buffers     cached
Mem:       1026460     451696     574764          0      90468     201452
-/+ buffers/cache:     159776       866684
Swap:      1128440          0          1128440
vbhagat at Leo:~/toybox$ sudo umount /dev/ram0
vbhagat at Leo:~/toybox$ free -k
                       total       used          free     shared    buffers     cached
Mem:       1026460     448340     578120          0      87140     198388
-/+ buffers/cache:       162812       863648
Swap:      1128440          0          1128440
vbhagat at Leo:~/toybox$ sudo ./toybox freeramdisk /dev/ram0
vbhagat at Leo:~/toybox$ free -k
                       total       used          free     shared    buffers     cached
Mem:       1026460     442884     583576          0      87148     198388
-/+ buffers/cache:       157348       869112
Swap:      1128440          0          1128440
vbhagat at Leo:~/toybox$


======================= openvt log ===================================================
vbhagat at Leo:~/toybox$ sudo ./toybox openvt -c 9 -s -w -- /bin/bash -c "/bin/date; sleep 3; /bin/date"
# below command successfully switch to the new VT (/dev/tty9), print the date, wait 5 seconds,
# print the new date, and switch back to the original VT.

vbhagat at Leo:~/toybox$ sudo ./toybox openvt -s -- /bin/bash -c "/bin/date; sleep 2; /bin/date"
#without -s option only, it switches to new VT and runs command over there.
# Also without -c option, it searches by itself for next available VT.


======================= deallocvt log =================================================
vbhagat at Leo:~/toybox$ sudo ./toybox openvt -c 9 -s -w -- /bin/bash -c "/bin/date; sleep 3; /bin/date"
vbhagat at Leo:~/toybox$ sudo ./toybox deallocvt 9
vbhagat at Leo:~/toybox$ sudo ./toybox openvt -c 10 -s -w -- /bin/bash -c "/bin/date; sleep 3; /bin/date"
vbhagat at Leo:~/toybox$ sudo ./toybox deallocvt

#Above deallocvt command successfully cleans up /dev/tty9 and /dev/tty10
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Added-freeramdisk-command.patch
Type: application/octet-stream
Size: 1098 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20140205/50ca7012/attachment-0015.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Added-openvt-command.patch
Type: application/octet-stream
Size: 3468 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20140205/50ca7012/attachment-0016.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Added-deallocvt-command.patch
Type: application/octet-stream
Size: 1349 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20140205/50ca7012/attachment-0017.obj>


More information about the Toybox mailing list