]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - io/sync.c
configure: don't check for readdir
[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
24#ifdef HAVE_SYNCFS
25static cmdinfo_t syncfs_cmd;
26
27static int
28syncfs_f(
29 int argc,
30 char **argv)
31{
7c4889e8
JL
32 if (syncfs(file->fd) < 0) {
33 perror("syncfs");
34 exitcode = 1;
35 }
c7dd81c7
ES
36 return 0;
37}
38#endif
39
40void
41sync_init(void)
42{
43 sync_cmd.name = "sync";
44 sync_cmd.cfunc = sync_f;
16bf0464
DC
45 sync_cmd.flags = CMD_NOMAP_OK | CMD_NOFILE_OK |
46 CMD_FOREIGN_OK | CMD_FLAG_ONESHOT;
c7dd81c7
ES
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}