]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame_incremental - io/resblks.c
xfsprogs: Release v6.15.0
[thirdparty/xfsprogs-dev.git] / io / resblks.c
... / ...
CommitLineData
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2003-2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6
7#include "command.h"
8#include "input.h"
9#include "init.h"
10#include "io.h"
11
12static cmdinfo_t resblks_cmd;
13static int resblks_f(int argc, char **argv);
14
15static int
16resblks_f(
17 int argc,
18 char **argv)
19{
20 xfs_fsop_resblks_t res;
21 long long blks;
22
23 if (argc == 2) {
24 blks = cvtnum(file->geom.blocksize, file->geom.sectsize, argv[1]);
25 if (blks < 0) {
26 printf(_("non-numeric argument -- %s\n"), argv[1]);
27 exitcode = 1;
28 return 0;
29 }
30 res.resblks = blks;
31 if (xfsctl(file->name, file->fd, XFS_IOC_SET_RESBLKS, &res) < 0) {
32 perror("XFS_IOC_SET_RESBLKS");
33 exitcode = 1;
34 return 0;
35 }
36 } else if (xfsctl(file->name, file->fd, XFS_IOC_GET_RESBLKS, &res) < 0) {
37 perror("XFS_IOC_GET_RESBLKS");
38 exitcode = 1;
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
48void
49resblks_init(void)
50{
51 resblks_cmd.name = "resblks";
52 resblks_cmd.cfunc = resblks_f;
53 resblks_cmd.argmin = 0;
54 resblks_cmd.argmax = 1;
55 resblks_cmd.flags = CMD_NOMAP_OK | CMD_FLAG_ONESHOT;
56 resblks_cmd.args = _("[blocks]");
57 resblks_cmd.oneline =
58 _("get and/or set count of reserved filesystem blocks");
59
60 if (expert)
61 add_command(&resblks_cmd);
62}