Annotation of /trunk/mkinitrd-magellan/busybox/util-linux/freeramdisk.c
Parent Directory | Revision Log
Revision 532 -
(hide annotations)
(download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 862 byte(s)
Sat Sep 1 22:45:15 2007 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 862 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd
1 | niro | 532 | /* 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 tarball for details. | ||
10 | */ | ||
11 | |||
12 | #include "busybox.h" | ||
13 | |||
14 | /* From <linux/fd.h> */ | ||
15 | #define FDFLUSH _IO(2,0x4b) | ||
16 | |||
17 | int freeramdisk_main(int argc, char **argv) | ||
18 | { | ||
19 | int result; | ||
20 | int fd; | ||
21 | |||
22 | if (argc != 2) bb_show_usage(); | ||
23 | |||
24 | fd = xopen(argv[1], O_RDWR); | ||
25 | |||
26 | // Act like freeramdisk, fdflush, or both depending on configuration. | ||
27 | result = ioctl(fd, (ENABLE_FREERAMDISK && applet_name[1]=='r') | ||
28 | || !ENABLE_FDFLUSH ? BLKFLSBUF : FDFLUSH); | ||
29 | |||
30 | if (ENABLE_FEATURE_CLEAN_UP) close(fd); | ||
31 | |||
32 | if (result) bb_perror_msg_and_die("%s", argv[1]); | ||
33 | return EXIT_SUCCESS; | ||
34 | } |