#include <sys/ioctl.h>
#include <fcntl.h>
#include <stdlib.h>
+#include <unistd.h>
#include "busybox.h"
/* From <linux/fd.h> */
extern int fdflush_main(int argc, char **argv)
{
- int fd;
+ int fd, result;
if (argc <= 1)
- show_usage();
- if ((fd = open(*(++argv), 0)) < 0)
- goto die_the_death;
+ bb_show_usage();
- if (ioctl(fd, FDFLUSH, 0))
- goto die_the_death;
+ fd = bb_xopen(argv[1], 0);
- return EXIT_SUCCESS;
+ result = ioctl(fd, FDFLUSH, 0);
+#ifdef CONFIG_FEATURE_CLEAN_UP
+ close(fd);
+#endif
+ if (result) {
+ bb_perror_nomsg_and_die();
+ }
-die_the_death:
- perror_msg_and_die(NULL);
+ /* Don't bother closing. Exit does
+ * that, so we can save a few bytes */
+ return EXIT_SUCCESS;
}