source: branches/3.2/mindi-busybox/util-linux/freeramdisk.c @ 3232

Last change on this file since 3232 was 3232, checked in by bruno, 5 years ago
  • Update mindi-busybox to 1.21.1
File size: 1.3 KB
Line 
1/* vi: set sw=4 ts=4: */
2/*
3 * freeramdisk and fdflush implementations for busybox
4 *
5 * Copyright (C) 2000 and written by Emanuele Caratti <wiz@iol.it>
6 * Adjusted a bit by Erik Andersen <andersen@codepoet.org>
7 * Unified with fdflush by Tito Ragusa <farmatito@tiscali.it>
8 *
9 * Licensed under GPLv2, see file LICENSE in this source tree.
10 */
11
12//usage:#define freeramdisk_trivial_usage
13//usage:       "DEVICE"
14//usage:#define freeramdisk_full_usage "\n\n"
15//usage:       "Free all memory used by the specified ramdisk"
16//usage:
17//usage:#define freeramdisk_example_usage
18//usage:       "$ freeramdisk /dev/ram2\n"
19//usage:
20//usage:#define fdflush_trivial_usage
21//usage:       "DEVICE"
22//usage:#define fdflush_full_usage "\n\n"
23//usage:       "Force floppy disk drive to detect disk change"
24
25#include <sys/mount.h>
26#include "libbb.h"
27
28/* From <linux/fd.h> */
29#define FDFLUSH  _IO(2,0x4b)
30
31int freeramdisk_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
32int freeramdisk_main(int argc UNUSED_PARAM, char **argv)
33{
34    int fd;
35
36    fd = xopen(single_argv(argv), O_RDWR);
37
38    // Act like freeramdisk, fdflush, or both depending on configuration.
39    ioctl_or_perror_and_die(fd, (ENABLE_FREERAMDISK && applet_name[1] == 'r')
40            || !ENABLE_FDFLUSH ? BLKFLSBUF : FDFLUSH, NULL, "%s", argv[1]);
41
42    if (ENABLE_FEATURE_CLEAN_UP) close(fd);
43
44    return EXIT_SUCCESS;
45}
Note: See TracBrowser for help on using the repository browser.