]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - io/sync.c
xfs: convert to new timestamp accessors
[thirdparty/xfsprogs-dev.git] / io / sync.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2014 Red Hat, Inc.
4 * All Rights Reserved.
5 */
6
7 #include "platform_defs.h"
8 #include "command.h"
9 #include "init.h"
10 #include "io.h"
11
12 static cmdinfo_t sync_cmd;
13
14 static int
15 sync_f(
16 int argc,
17 char **argv)
18 {
19 /* sync can't fail */
20 sync();
21 return 0;
22 }
23
24 #ifdef HAVE_SYNCFS
25 static cmdinfo_t syncfs_cmd;
26
27 static int
28 syncfs_f(
29 int argc,
30 char **argv)
31 {
32 if (syncfs(file->fd) < 0) {
33 perror("syncfs");
34 exitcode = 1;
35 }
36 return 0;
37 }
38 #endif
39
40 void
41 sync_init(void)
42 {
43 sync_cmd.name = "sync";
44 sync_cmd.cfunc = sync_f;
45 sync_cmd.flags = CMD_NOMAP_OK | CMD_NOFILE_OK |
46 CMD_FOREIGN_OK | CMD_FLAG_ONESHOT;
47 sync_cmd.oneline =
48 _("calls sync(2) to flush all in-core filesystem state to disk");
49
50 add_command(&sync_cmd);
51
52 #ifdef HAVE_SYNCFS
53 syncfs_cmd.name = "syncfs";
54 syncfs_cmd.cfunc = syncfs_f;
55 syncfs_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
56 syncfs_cmd.oneline =
57 _("calls syncfs(2) to flush all in-core filesystem state to disk");
58
59 add_command(&syncfs_cmd);
60 #endif
61 }