]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - io/sync.c
xfs: support removing extents from CoW fork
[thirdparty/xfsprogs-dev.git] / io / sync.c
CommitLineData
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
24static cmdinfo_t sync_cmd;
25
26static int
27sync_f(
28 int argc,
29 char **argv)
30{
31 /* sync can't fail */
32 sync();
33 return 0;
34}
35
36#ifdef HAVE_SYNCFS
37static cmdinfo_t syncfs_cmd;
38
39static int
40syncfs_f(
41 int argc,
42 char **argv)
43{
44 /* syncfs can't fail */
45 syncfs(file->fd);
46 return 0;
47}
48#endif
49
50void
51sync_init(void)
52{
53 sync_cmd.name = "sync";
54 sync_cmd.cfunc = sync_f;
55 sync_cmd.flags = CMD_NOMAP_OK | CMD_NOFILE_OK | CMD_FOREIGN_OK;
56 sync_cmd.oneline =
57 _("calls sync(2) to flush all in-core filesystem state to disk");
58
59 add_command(&sync_cmd);
60
61#ifdef HAVE_SYNCFS
62 syncfs_cmd.name = "syncfs";
63 syncfs_cmd.cfunc = syncfs_f;
64 syncfs_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
65 syncfs_cmd.oneline =
66 _("calls syncfs(2) to flush all in-core filesystem state to disk");
67
68 add_command(&syncfs_cmd);
69#endif
70}