annotate toys/other/freeramdisk.c @ 1776:7bf68329eb3b draft default tip

Repository switched to git at https://github.com/landley/toybox
author Rob Landley <rob@landley.net>
date Thu, 09 Apr 2015 02:28:32 -0500
parents bd4e3608ad04
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
1216
bd4e3608ad04 Promote freeramdisk from pending to other, default y.
Rob Landley <rob@landley.net>
parents: 1215
diff changeset
11 default y
1214
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
12 help
1215
4eaac3e63fa7 Cleanup freeramdisk: tabs to 2 spaces, square brackets for option name, do optional cleanup under if (CFG_TOYBOX_FREE) guard.
Rob Landley <rob@landley.net>
parents: 1214
diff changeset
13 usage: freeramdisk [RAM device]
1214
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 {
1215
4eaac3e63fa7 Cleanup freeramdisk: tabs to 2 spaces, square brackets for option name, do optional cleanup under if (CFG_TOYBOX_FREE) guard.
Rob Landley <rob@landley.net>
parents: 1214
diff changeset
22 int fd;
1214
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
23
1215
4eaac3e63fa7 Cleanup freeramdisk: tabs to 2 spaces, square brackets for option name, do optional cleanup under if (CFG_TOYBOX_FREE) guard.
Rob Landley <rob@landley.net>
parents: 1214
diff changeset
24 fd = xopen(toys.optargs[0], O_RDWR);
4eaac3e63fa7 Cleanup freeramdisk: tabs to 2 spaces, square brackets for option name, do optional cleanup under if (CFG_TOYBOX_FREE) guard.
Rob Landley <rob@landley.net>
parents: 1214
diff changeset
25 xioctl(fd, BLKFLSBUF, toys.optargs[0]);
4eaac3e63fa7 Cleanup freeramdisk: tabs to 2 spaces, square brackets for option name, do optional cleanup under if (CFG_TOYBOX_FREE) guard.
Rob Landley <rob@landley.net>
parents: 1214
diff changeset
26 if (CFG_TOYBOX_FREE) xclose(fd);
1214
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
27 }