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