]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - io/imap.c
progs: clean up all remaining xfs*h includes
[thirdparty/xfsprogs-dev.git] / io / imap.c
1 /*
2 * Copyright (c) 2001-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 "xfs/xfs.h"
20 #include "xfs/command.h"
21 #include "xfs/input.h"
22 #include "init.h"
23 #include "io.h"
24
25 static cmdinfo_t imap_cmd;
26
27 int
28 imap_f(int argc, char **argv)
29 {
30 int count;
31 int nent;
32 int i;
33 __u64 last = 0;
34 xfs_inogrp_t *t;
35 xfs_fsop_bulkreq_t bulkreq;
36
37 if (argc != 2)
38 nent = 1;
39 else
40 nent = atoi(argv[1]);
41
42 t = malloc(nent * sizeof(*t));
43
44 bulkreq.lastip = &last;
45 bulkreq.icount = nent;
46 bulkreq.ubuffer = (void *)t;
47 bulkreq.ocount = &count;
48
49 while (xfsctl(file->name, file->fd, XFS_IOC_FSINUMBERS, &bulkreq) == 0) {
50 if (count == 0)
51 return 0;
52 for (i = 0; i < count; i++) {
53 printf(_("ino %10llu count %2d mask %016llx\n"),
54 (unsigned long long)t[i].xi_startino,
55 t[i].xi_alloccount,
56 (unsigned long long)t[i].xi_allocmask);
57 }
58 }
59 perror("xfsctl(XFS_IOC_FSINUMBERS)");
60 exitcode = 1;
61 return 0;
62 }
63
64 void
65 imap_init(void)
66 {
67 imap_cmd.name = "imap";
68 imap_cmd.cfunc = imap_f;
69 imap_cmd.argmin = 0;
70 imap_cmd.argmax = 1;
71 imap_cmd.args = _("[nentries]");
72 imap_cmd.flags = CMD_NOMAP_OK;
73 imap_cmd.oneline = _("inode map for filesystem of current file");
74
75 if (expert)
76 add_command(&imap_cmd);
77 }