]>
Commit | Line | Data |
---|---|---|
e246ba5f NS |
1 | /* |
2 | * Copyright (c) 2003 Silicon Graphics, Inc. All Rights Reserved. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of version 2 of the GNU General Public License as | |
6 | * published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it would be useful, but | |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
11 | * | |
12 | * Further, this software is distributed without any warranty that it is | |
13 | * free of the rightful claim of any third person regarding infringement | |
14 | * or the like. Any license provided herein, whether implied or | |
15 | * otherwise, applies only to this software file. Patent licenses, if | |
16 | * any, provided herein do not apply to combinations of this program with | |
17 | * other software, or any other product whatsoever. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License along | |
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | |
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | |
22 | * | |
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | |
24 | * Mountain View, CA 94043, or: | |
25 | * | |
26 | * http://www.sgi.com | |
27 | * | |
28 | * For further information regarding this notice, see: | |
29 | * | |
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | |
31 | */ | |
32 | ||
33 | #include <libxfs.h> | |
34 | #include "command.h" | |
35 | #include "init.h" | |
36 | ||
37 | static cmdinfo_t resblks_cmd; | |
38 | static int resblks_f(int argc, char **argv); | |
39 | ||
40 | static int | |
41 | resblks_f( | |
42 | int argc, | |
43 | char **argv) | |
44 | { | |
45 | xfs_fsop_resblks_t res; | |
46 | char *sp; | |
47 | ||
48 | if (argc == 2) { | |
49 | res.resblks = strtoul(argv[1], &sp, 10); | |
50 | if (!sp || sp == argv[1]) { | |
51 | printf(_("non-numeric argument -- %s\n"), argv[1]); | |
52 | return 0; | |
53 | } | |
93d9f139 NS |
54 | if (xfsctl(fname, fdesc, XFS_IOC_SET_RESBLKS, &res) < 0) { |
55 | perror("xfsctl(XFS_IOC_SET_RESBLKS)"); | |
e246ba5f NS |
56 | return 0; |
57 | } | |
93d9f139 NS |
58 | } else if (xfsctl(fname, fdesc, XFS_IOC_GET_RESBLKS, &res) < 0) { |
59 | perror("xfsctl(XFS_IOC_GET_RESBLKS)"); | |
e246ba5f NS |
60 | return 0; |
61 | } | |
62 | printf(_("reserved blocks = %llu\n"), | |
63 | (unsigned long long) res.resblks); | |
64 | printf(_("available reserved blocks = %llu\n"), | |
65 | (unsigned long long) res.resblks_avail); | |
66 | return 0; | |
67 | } | |
68 | ||
69 | void | |
70 | resblks_init(void) | |
71 | { | |
72 | resblks_cmd.name = _("resblks"); | |
73 | resblks_cmd.cfunc = resblks_f; | |
74 | resblks_cmd.argmin = 0; | |
75 | resblks_cmd.argmax = 1; | |
76 | resblks_cmd.args = _("[blocks]"); | |
77 | resblks_cmd.oneline = | |
78 | _("get and/or set count of reserved filesystem blocks"); | |
79 | ||
80 | add_command(&resblks_cmd); | |
81 | } |