]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - io/resblks.c
xfs_io: hook up statx
[thirdparty/xfsprogs-dev.git] / io / resblks.c
CommitLineData
e246ba5f 1/*
da23017d
NS
2 * Copyright (c) 2003-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
dfc130f3 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
e246ba5f 7 * published by the Free Software Foundation.
dfc130f3 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.
dfc130f3 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
e246ba5f
NS
17 */
18
6b803e5a
CH
19#include "command.h"
20#include "input.h"
e246ba5f 21#include "init.h"
48c46ee3 22#include "io.h"
e246ba5f
NS
23
24static cmdinfo_t resblks_cmd;
25static int resblks_f(int argc, char **argv);
26
27static int
28resblks_f(
29 int argc,
30 char **argv)
31{
32 xfs_fsop_resblks_t res;
638473d8 33 long long blks;
e246ba5f
NS
34
35 if (argc == 2) {
48c46ee3 36 blks = cvtnum(file->geom.blocksize, file->geom.sectsize, argv[1]);
638473d8 37 if (blks < 0) {
e246ba5f
NS
38 printf(_("non-numeric argument -- %s\n"), argv[1]);
39 return 0;
40 }
638473d8 41 res.resblks = blks;
48c46ee3
NS
42 if (xfsctl(file->name, file->fd, XFS_IOC_SET_RESBLKS, &res) < 0) {
43 perror("XFS_IOC_SET_RESBLKS");
e246ba5f
NS
44 return 0;
45 }
48c46ee3
NS
46 } else if (xfsctl(file->name, file->fd, XFS_IOC_GET_RESBLKS, &res) < 0) {
47 perror("XFS_IOC_GET_RESBLKS");
e246ba5f
NS
48 return 0;
49 }
50 printf(_("reserved blocks = %llu\n"),
51 (unsigned long long) res.resblks);
52 printf(_("available reserved blocks = %llu\n"),
53 (unsigned long long) res.resblks_avail);
54 return 0;
55}
56
57void
58resblks_init(void)
59{
ad765595 60 resblks_cmd.name = "resblks";
e246ba5f
NS
61 resblks_cmd.cfunc = resblks_f;
62 resblks_cmd.argmin = 0;
63 resblks_cmd.argmax = 1;
16bf0464 64 resblks_cmd.flags = CMD_NOMAP_OK | CMD_FLAG_ONESHOT;
e246ba5f
NS
65 resblks_cmd.args = _("[blocks]");
66 resblks_cmd.oneline =
67 _("get and/or set count of reserved filesystem blocks");
68
48c46ee3
NS
69 if (expert)
70 add_command(&resblks_cmd);
e246ba5f 71}