]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - io/resblks.c
Update copyright/license notices to match SGI legal prefered boilerplate.
[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
1d7e80ee 19#include <xfs/libxfs.h>
0717a7db
NS
20#include <xfs/command.h>
21#include <xfs/input.h>
e246ba5f 22#include "init.h"
48c46ee3 23#include "io.h"
e246ba5f
NS
24
25static cmdinfo_t resblks_cmd;
26static int resblks_f(int argc, char **argv);
27
28static int
29resblks_f(
30 int argc,
31 char **argv)
32{
33 xfs_fsop_resblks_t res;
638473d8 34 long long blks;
e246ba5f
NS
35
36 if (argc == 2) {
48c46ee3 37 blks = cvtnum(file->geom.blocksize, file->geom.sectsize, argv[1]);
638473d8 38 if (blks < 0) {
e246ba5f
NS
39 printf(_("non-numeric argument -- %s\n"), argv[1]);
40 return 0;
41 }
638473d8 42 res.resblks = blks;
48c46ee3
NS
43 if (xfsctl(file->name, file->fd, XFS_IOC_SET_RESBLKS, &res) < 0) {
44 perror("XFS_IOC_SET_RESBLKS");
e246ba5f
NS
45 return 0;
46 }
48c46ee3
NS
47 } else if (xfsctl(file->name, file->fd, XFS_IOC_GET_RESBLKS, &res) < 0) {
48 perror("XFS_IOC_GET_RESBLKS");
e246ba5f
NS
49 return 0;
50 }
51 printf(_("reserved blocks = %llu\n"),
52 (unsigned long long) res.resblks);
53 printf(_("available reserved blocks = %llu\n"),
54 (unsigned long long) res.resblks_avail);
55 return 0;
56}
57
58void
59resblks_init(void)
60{
61 resblks_cmd.name = _("resblks");
62 resblks_cmd.cfunc = resblks_f;
63 resblks_cmd.argmin = 0;
64 resblks_cmd.argmax = 1;
48c46ee3 65 resblks_cmd.flags = CMD_NOMAP_OK;
e246ba5f
NS
66 resblks_cmd.args = _("[blocks]");
67 resblks_cmd.oneline =
68 _("get and/or set count of reserved filesystem blocks");
69
48c46ee3
NS
70 if (expert)
71 add_command(&resblks_cmd);
e246ba5f 72}