]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - imap/xfs_imap.c
Merge whitespace changes over
[thirdparty/xfsprogs-dev.git] / imap / xfs_imap.c
CommitLineData
8c4a2bb0 1/*
93d9f139 2 * Copyright (c) 2001-2003 Silicon Graphics, Inc. All Rights Reserved.
dfc130f3 3 *
8c4a2bb0
NS
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
dfc130f3 7 *
8c4a2bb0
NS
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
dfc130f3 11 *
8c4a2bb0
NS
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
dfc130f3 18 *
8c4a2bb0
NS
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
dfc130f3 22 *
8c4a2bb0
NS
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
dfc130f3
RC
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
8c4a2bb0
NS
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
dfc130f3 33/*
8c4a2bb0
NS
34 * Inode map display utility for XFS.
35 */
36
37#include <libxfs.h>
8c4a2bb0
NS
38
39int main(int argc, char **argv)
40{
41 int count;
42 int nent;
43 int fd;
44 int i;
45 char *name;
46 char *progname;
47 __s64 last = 0;
48 xfs_inogrp_t *t;
49 xfs_fsop_bulkreq_t bulkreq;
8c4a2bb0
NS
50
51 progname = basename(argv[0]);
9440d84d
NS
52 setlocale(LC_ALL, "");
53 bindtextdomain(PACKAGE, LOCALEDIR);
54 textdomain(PACKAGE);
8c4a2bb0
NS
55
56 if (argc < 2)
57 name = ".";
58 else
59 name = argv[1];
60 fd = open(name, O_RDONLY);
61 if (fd < 0) {
62 perror(name);
63 return 1;
64 }
93d9f139 65 if (!platform_test_xfs_fd(fd)) {
9440d84d
NS
66 fprintf(stderr, _("%s: specified file "
67 "[\"%s\"] is not on an XFS filesystem\n"),
8c4a2bb0
NS
68 progname, name);
69 exit(1);
70 }
71
72 if (argc < 3)
73 nent = 1;
74 else
75 nent = atoi(argv[2]);
76
77 t = malloc(nent * sizeof(*t));
78
79 bulkreq.lastip = &last;
80 bulkreq.icount = nent;
81 bulkreq.ubuffer = t;
82 bulkreq.ocount = &count;
83
93d9f139 84 while (xfsctl(name, fd, XFS_IOC_FSINUMBERS, &bulkreq) == 0) {
8c4a2bb0
NS
85 if (count == 0)
86 return 0;
87 for (i = 0; i < count; i++) {
9440d84d 88 printf(_("ino %10llu count %2d mask %016llx\n"),
36cf2b92
NS
89 (unsigned long long)t[i].xi_startino,
90 t[i].xi_alloccount,
91 (unsigned long long)t[i].xi_allocmask);
8c4a2bb0
NS
92 }
93 }
93d9f139 94 perror("xfsctl(XFS_IOC_FSINUMBERS)");
8c4a2bb0
NS
95 return 1;
96}