]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - io/fsync.c
xfs: force summary counter recalc at next mount
[thirdparty/xfsprogs-dev.git] / io / fsync.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2003-2005 Silicon Graphics, 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 fsync_cmd;
13 static cmdinfo_t fdatasync_cmd;
14
15 static int
16 fsync_f(
17 int argc,
18 char **argv)
19 {
20 if (fsync(file->fd) < 0) {
21 perror("fsync");
22 return 0;
23 }
24 return 0;
25 }
26
27 static int
28 fdatasync_f(
29 int argc,
30 char **argv)
31 {
32 if (fdatasync(file->fd) < 0) {
33 perror("fdatasync");
34 return 0;
35 }
36 return 0;
37 }
38
39 void
40 fsync_init(void)
41 {
42 fsync_cmd.name = "fsync";
43 fsync_cmd.altname = "s";
44 fsync_cmd.cfunc = fsync_f;
45 fsync_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
46 fsync_cmd.oneline =
47 _("calls fsync(2) to flush all in-core file state to disk");
48
49 fdatasync_cmd.name = "fdatasync";
50 fdatasync_cmd.altname = "ds";
51 fdatasync_cmd.cfunc = fdatasync_f;
52 fdatasync_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
53 fdatasync_cmd.oneline =
54 _("calls fdatasync(2) to flush the files in-core data to disk");
55
56 add_command(&fsync_cmd);
57 add_command(&fdatasync_cmd);
58 }