]>
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 NS |
26 | printf(_("non-numeric argument -- %s\n"), argv[1]); |
27 | return 0; | |
28 | } | |
638473d8 | 29 | res.resblks = blks; |
48c46ee3 NS |
30 | if (xfsctl(file->name, file->fd, XFS_IOC_SET_RESBLKS, &res) < 0) { |
31 | perror("XFS_IOC_SET_RESBLKS"); | |
e246ba5f NS |
32 | return 0; |
33 | } | |
48c46ee3 NS |
34 | } else if (xfsctl(file->name, file->fd, XFS_IOC_GET_RESBLKS, &res) < 0) { |
35 | perror("XFS_IOC_GET_RESBLKS"); | |
e246ba5f NS |
36 | return 0; |
37 | } | |
38 | printf(_("reserved blocks = %llu\n"), | |
39 | (unsigned long long) res.resblks); | |
40 | printf(_("available reserved blocks = %llu\n"), | |
41 | (unsigned long long) res.resblks_avail); | |
42 | return 0; | |
43 | } | |
44 | ||
45 | void | |
46 | resblks_init(void) | |
47 | { | |
ad765595 | 48 | resblks_cmd.name = "resblks"; |
e246ba5f NS |
49 | resblks_cmd.cfunc = resblks_f; |
50 | resblks_cmd.argmin = 0; | |
51 | resblks_cmd.argmax = 1; | |
16bf0464 | 52 | resblks_cmd.flags = CMD_NOMAP_OK | CMD_FLAG_ONESHOT; |
e246ba5f NS |
53 | resblks_cmd.args = _("[blocks]"); |
54 | resblks_cmd.oneline = | |
55 | _("get and/or set count of reserved filesystem blocks"); | |
56 | ||
48c46ee3 NS |
57 | if (expert) |
58 | add_command(&resblks_cmd); | |
e246ba5f | 59 | } |