]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - io/freeze.c
xfs: support removing extents from CoW fork
[thirdparty/xfsprogs-dev.git] / io / freeze.c
CommitLineData
48c46ee3 1/*
da23017d
NS
2 * Copyright (c) 2001-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
48c46ee3 4 *
da23017d
NS
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
48c46ee3
NS
7 * published by the Free Software Foundation.
8 *
da23017d
NS
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.
48c46ee3 13 *
da23017d
NS
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
48c46ee3
NS
17 */
18
6b803e5a
CH
19#include "command.h"
20#include "input.h"
48c46ee3
NS
21#include "init.h"
22#include "io.h"
23
24static cmdinfo_t freeze_cmd;
25static cmdinfo_t thaw_cmd;
26
27int
28freeze_f(
29 int argc,
30 char **argv)
31{
32 int level = 1;
33
34 if (xfsctl(file->name, file->fd, XFS_IOC_FREEZE, &level) < 0) {
35 fprintf(stderr,
36 _("%s: cannot freeze filesystem at %s: %s\n"),
37 progname, file->name, strerror(errno));
38 exitcode = 1;
39 return 0;
40 }
41 return 0;
42}
43
44int
45thaw_f(
46 int argc,
47 char **argv)
48{
49 int level = 1;
50
51 if (xfsctl(file->name, file->fd, XFS_IOC_THAW, &level) < 0) {
52 fprintf(stderr,
53 _("%s: cannot unfreeze filesystem mounted at %s: %s\n"),
54 progname, file->name, strerror(errno));
55 exitcode = 1;
56 return 0;
57 }
58 return 0;
59}
60
61void
62freeze_init(void)
63{
ad765595 64 freeze_cmd.name = "freeze";
48c46ee3
NS
65 freeze_cmd.cfunc = freeze_f;
66 freeze_cmd.argmin = 0;
67 freeze_cmd.argmax = 0;
cd67dabb 68 freeze_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
48c46ee3
NS
69 freeze_cmd.oneline = _("freeze filesystem of current file");
70
ad765595 71 thaw_cmd.name = "thaw";
48c46ee3
NS
72 thaw_cmd.cfunc = thaw_f;
73 thaw_cmd.argmin = 0;
74 thaw_cmd.argmax = 0;
cd67dabb 75 thaw_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
48c46ee3
NS
76 thaw_cmd.oneline = _("unfreeze filesystem of current file");
77
78 if (expert) {
79 add_command(&freeze_cmd);
80 add_command(&thaw_cmd);
81 }
82}