]>
Commit | Line | Data |
---|---|---|
c7dd81c7 ES |
1 | /* |
2 | * Copyright (c) 2014 Red Hat, Inc. | |
3 | * All Rights Reserved. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or | |
6 | * modify it under the terms of the GNU General Public License as | |
7 | * published by the Free Software Foundation. | |
8 | * | |
9 | * This program is distributed in the hope that it would be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program; if not, write the Free Software Foundation, | |
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | */ | |
18 | ||
dcabd4e7 | 19 | #include "platform_defs.h" |
6b803e5a | 20 | #include "command.h" |
c7dd81c7 ES |
21 | #include "init.h" |
22 | #include "io.h" | |
23 | ||
24 | static cmdinfo_t sync_cmd; | |
25 | ||
26 | static int | |
27 | sync_f( | |
28 | int argc, | |
29 | char **argv) | |
30 | { | |
31 | /* sync can't fail */ | |
32 | sync(); | |
33 | return 0; | |
34 | } | |
35 | ||
36 | #ifdef HAVE_SYNCFS | |
37 | static cmdinfo_t syncfs_cmd; | |
38 | ||
39 | static int | |
40 | syncfs_f( | |
41 | int argc, | |
42 | char **argv) | |
43 | { | |
44 | /* syncfs can't fail */ | |
45 | syncfs(file->fd); | |
46 | return 0; | |
47 | } | |
48 | #endif | |
49 | ||
50 | void | |
51 | sync_init(void) | |
52 | { | |
53 | sync_cmd.name = "sync"; | |
54 | sync_cmd.cfunc = sync_f; | |
16bf0464 DC |
55 | sync_cmd.flags = CMD_NOMAP_OK | CMD_NOFILE_OK | |
56 | CMD_FOREIGN_OK | CMD_FLAG_ONESHOT; | |
c7dd81c7 ES |
57 | sync_cmd.oneline = |
58 | _("calls sync(2) to flush all in-core filesystem state to disk"); | |
59 | ||
60 | add_command(&sync_cmd); | |
61 | ||
62 | #ifdef HAVE_SYNCFS | |
63 | syncfs_cmd.name = "syncfs"; | |
64 | syncfs_cmd.cfunc = syncfs_f; | |
65 | syncfs_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK; | |
66 | syncfs_cmd.oneline = | |
67 | _("calls syncfs(2) to flush all in-core filesystem state to disk"); | |
68 | ||
69 | add_command(&syncfs_cmd); | |
70 | #endif | |
71 | } |