Last change
on this file since 3721 was 3320, checked in by Bruno Cornec, 10 years ago |
- Re-add (thanks git BTW) the 2.2.9 branch which had been destroyed in
the move to 3.0
|
-
Property svn:eol-style
set to
native
|
File size:
905 bytes
|
Rev | Line | |
---|
[3320] | 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 source tree.
|
---|
| 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 = open_or_warn(*argv, O_NOATIME | O_NOCTTY | O_RDONLY);
|
---|
| 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 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.