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