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