]>
Commit | Line | Data |
---|---|---|
959ef981 | 1 | // SPDX-License-Identifier: GPL-2.0 |
e246ba5f | 2 | /* |
da23017d NS |
3 | * Copyright (c) 2003-2005 Silicon Graphics, Inc. |
4 | * All Rights Reserved. | |
e246ba5f NS |
5 | */ |
6 | ||
6b803e5a CH |
7 | #include "command.h" |
8 | #include "input.h" | |
e246ba5f | 9 | #include "init.h" |
48c46ee3 | 10 | #include "io.h" |
e246ba5f NS |
11 | |
12 | static cmdinfo_t resblks_cmd; | |
13 | static int resblks_f(int argc, char **argv); | |
14 | ||
15 | static int | |
16 | resblks_f( | |
17 | int argc, | |
18 | char **argv) | |
19 | { | |
20 | xfs_fsop_resblks_t res; | |
638473d8 | 21 | long long blks; |
e246ba5f NS |
22 | |
23 | if (argc == 2) { | |
48c46ee3 | 24 | blks = cvtnum(file->geom.blocksize, file->geom.sectsize, argv[1]); |
638473d8 | 25 | if (blks < 0) { |
e246ba5f | 26 | printf(_("non-numeric argument -- %s\n"), argv[1]); |
9e1595e6 | 27 | exitcode = 1; |
e246ba5f NS |
28 | return 0; |
29 | } | |
638473d8 | 30 | res.resblks = blks; |
48c46ee3 NS |
31 | if (xfsctl(file->name, file->fd, XFS_IOC_SET_RESBLKS, &res) < 0) { |
32 | perror("XFS_IOC_SET_RESBLKS"); | |
9e1595e6 | 33 | exitcode = 1; |
e246ba5f NS |
34 | return 0; |
35 | } | |
48c46ee3 NS |
36 | } else if (xfsctl(file->name, file->fd, XFS_IOC_GET_RESBLKS, &res) < 0) { |
37 | perror("XFS_IOC_GET_RESBLKS"); | |
9e1595e6 | 38 | exitcode = 1; |
e246ba5f NS |
39 | return 0; |
40 | } | |
41 | printf(_("reserved blocks = %llu\n"), | |
42 | (unsigned long long) res.resblks); | |
43 | printf(_("available reserved blocks = %llu\n"), | |
44 | (unsigned long long) res.resblks_avail); | |
45 | return 0; | |
46 | } | |
47 | ||
48 | void | |
49 | resblks_init(void) | |
50 | { | |
ad765595 | 51 | resblks_cmd.name = "resblks"; |
e246ba5f NS |
52 | resblks_cmd.cfunc = resblks_f; |
53 | resblks_cmd.argmin = 0; | |
54 | resblks_cmd.argmax = 1; | |
16bf0464 | 55 | resblks_cmd.flags = CMD_NOMAP_OK | CMD_FLAG_ONESHOT; |
e246ba5f NS |
56 | resblks_cmd.args = _("[blocks]"); |
57 | resblks_cmd.oneline = | |
58 | _("get and/or set count of reserved filesystem blocks"); | |
59 | ||
48c46ee3 NS |
60 | if (expert) |
61 | add_command(&resblks_cmd); | |
e246ba5f | 62 | } |