Contents of /trunk/mkinitrd-magellan/busybox/coreutils/fsync.c
Parent Directory | Revision Log
Revision 997 -
(show annotations)
(download)
Sun May 30 12:15:28 2010 UTC (14 years, 3 months ago) by niro
File MIME type: text/plain
File size: 917 byte(s)
Sun May 30 12:15:28 2010 UTC (14 years, 3 months ago) by niro
File MIME type: text/plain
File size: 917 byte(s)
-added missing file
1 | /* vi: set sw=4 ts=4: */ |
2 | /* |
3 | * Mini fsync implementation for busybox |
4 | * |
5 | * Copyright (C) 2008 Nokia Corporation. All rights reserved. |
6 | * |
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
8 | */ |
9 | #include "libbb.h" |
10 | #ifndef O_NOATIME |
11 | # define O_NOATIME 0 |
12 | #endif |
13 | |
14 | /* This is a NOFORK applet. Be very careful! */ |
15 | |
16 | int fsync_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
17 | int fsync_main(int argc UNUSED_PARAM, char **argv) |
18 | { |
19 | int status; |
20 | int opts; |
21 | |
22 | opts = getopt32(argv, "d"); /* fdatasync */ |
23 | argv += optind; |
24 | if (!*argv) { |
25 | bb_show_usage(); |
26 | } |
27 | |
28 | status = EXIT_SUCCESS; |
29 | do { |
30 | int fd = open3_or_warn(*argv, O_NOATIME | O_NOCTTY | O_RDONLY, 0); |
31 | |
32 | if (fd == -1) { |
33 | status = EXIT_FAILURE; |
34 | continue; |
35 | } |
36 | if ((opts ? fdatasync(fd) : fsync(fd))) { |
37 | //status = EXIT_FAILURE; - do we want this? |
38 | bb_simple_perror_msg(*argv); |
39 | } |
40 | close(fd); |
41 | } while (*++argv); |
42 | |
43 | return status; |
44 | } |