Mercurial > hg > toybox
annotate toys/pending/freeramdisk.c @ 1214:a31d747b0017 draft
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.
author | Vivek Bhagat <vivek.bhagat89@gmail.com> |
---|---|
date | Sun, 09 Mar 2014 14:27:11 -0500 |
parents | |
children | 4eaac3e63fa7 |
rev | line source |
---|---|
1214
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
1 /* freeramdisk.c - Free all memory allocated to ramdisk |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
2 * |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
3 * Copyright 2014 Vivek Kumar Bhagat <vivek.bhagat89@gmail.com> |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
4 * |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
5 * No Standard |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
6 |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
7 USE_FREERAMDISK(NEWTOY(freeramdisk, "<1>1", TOYFLAG_SBIN|TOYFLAG_NEEDROOT)) |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
8 |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
9 config FREERAMDISK |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
10 bool "freeramdisk" |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
11 default n |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
12 help |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
13 usage: freeramdisk <RAM device> |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
14 |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
15 Free all memory allocated to specified ramdisk |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
16 */ |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
17 |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
18 #include "toys.h" |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
19 |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
20 void freeramdisk_main(void) |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
21 { |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
22 int fd; |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
23 |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
24 fd = xopen(toys.optargs[0], O_RDWR); |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
25 xioctl(fd, BLKFLSBUF, toys.optargs[0]); |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
26 xclose(fd); |
a31d747b0017
Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff
changeset
|
27 } |