]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - io/imap.c
configure: remove unecessary definitions of _FILE_OFFSET_BITS
[thirdparty/xfsprogs-dev.git] / io / imap.c
CommitLineData
8c4a2bb0 1/*
da23017d
NS
2 * Copyright (c) 2001-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
dfc130f3 4 *
da23017d
NS
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
8c4a2bb0 7 * published by the Free Software Foundation.
dfc130f3 8 *
da23017d
NS
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.
dfc130f3 13 *
da23017d
NS
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
8c4a2bb0
NS
17 */
18
6b803e5a
CH
19#include "command.h"
20#include "input.h"
9527f2d5
NS
21#include "init.h"
22#include "io.h"
23
9527f2d5
NS
24static cmdinfo_t imap_cmd;
25
26int
27imap_f(int argc, char **argv)
8c4a2bb0
NS
28{
29 int count;
30 int nent;
8c4a2bb0 31 int i;
d026b19e 32 __u64 last = 0;
8c4a2bb0
NS
33 xfs_inogrp_t *t;
34 xfs_fsop_bulkreq_t bulkreq;
8c4a2bb0 35
9527f2d5 36 if (argc != 2)
8c4a2bb0
NS
37 nent = 1;
38 else
9527f2d5 39 nent = atoi(argv[1]);
8c4a2bb0
NS
40
41 t = malloc(nent * sizeof(*t));
5d3a5d81
VT
42 if (!t)
43 return 0;
8c4a2bb0 44
ce8d0b3a 45 bulkreq.lastip = &last;
8c4a2bb0 46 bulkreq.icount = nent;
9527f2d5 47 bulkreq.ubuffer = (void *)t;
8c4a2bb0
NS
48 bulkreq.ocount = &count;
49
9527f2d5 50 while (xfsctl(file->name, file->fd, XFS_IOC_FSINUMBERS, &bulkreq) == 0) {
8c4a2bb0 51 if (count == 0)
5d3a5d81 52 goto out_free;
8c4a2bb0 53 for (i = 0; i < count; i++) {
9440d84d 54 printf(_("ino %10llu count %2d mask %016llx\n"),
36cf2b92
NS
55 (unsigned long long)t[i].xi_startino,
56 t[i].xi_alloccount,
57 (unsigned long long)t[i].xi_allocmask);
8c4a2bb0
NS
58 }
59 }
93d9f139 60 perror("xfsctl(XFS_IOC_FSINUMBERS)");
9527f2d5 61 exitcode = 1;
5d3a5d81
VT
62out_free:
63 free(t);
9527f2d5
NS
64 return 0;
65}
66
67void
68imap_init(void)
69{
ad765595 70 imap_cmd.name = "imap";
9527f2d5
NS
71 imap_cmd.cfunc = imap_f;
72 imap_cmd.argmin = 0;
eecbd583 73 imap_cmd.argmax = 1;
9527f2d5
NS
74 imap_cmd.args = _("[nentries]");
75 imap_cmd.flags = CMD_NOMAP_OK;
76 imap_cmd.oneline = _("inode map for filesystem of current file");
77
78 if (expert)
79 add_command(&imap_cmd);
8c4a2bb0 80}