2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
39 #include <sys/ioctl.h>
42 dotime(void *ti, char *s)
47 t = (xfs_bstime_t *)ti;
49 c = ctime(&t->tv_sec);
50 printf("\t%s %19.19s.%09d %s", s, c, t->tv_nsec, c + 20);
54 printbstat(xfs_bstat_t *sp)
56 printf("ino %lld mode %#o nlink %d uid %d gid %d rdev %#x\n",
57 sp->bs_ino, sp->bs_mode, sp->bs_nlink,
58 sp->bs_uid, sp->bs_gid, sp->bs_rdev);
59 printf("\tblksize %d size %lld blocks %lld xflags %#x extsize %d\n",
60 sp->bs_blksize, sp->bs_size, sp->bs_blocks,
61 sp->bs_xflags, sp->bs_extsize);
62 dotime(&sp->bs_atime, "atime");
63 dotime(&sp->bs_mtime, "mtime");
64 dotime(&sp->bs_ctime, "ctime");
65 printf( "\textents %d %d gen %d\n",
66 sp->bs_extents, sp->bs_aextents, sp->bs_gen);
67 printf( "\tDMI: event mask 0x%08x state 0x%04x\n",
68 sp->bs_dmevmask, sp->bs_dmstate);
72 printstat(struct stat64 *sp)
74 printf("ino %lld mode %#o nlink %d uid %d gid %d rdev %#x\n",
75 (xfs_ino_t)sp->st_ino, sp->st_mode, sp->st_nlink,
76 sp->st_uid, sp->st_gid, (unsigned int)sp->st_rdev);
77 printf("\tblksize %llu size %lld blocks %lld\n",
78 (__uint64_t)sp->st_blksize, sp->st_size, sp->st_blocks);
79 dotime(&sp->st_atime, "atime");
80 dotime(&sp->st_mtime, "mtime");
81 dotime(&sp->st_ctime, "ctime");
85 main(int argc, char **argv)
100 jdm_fshandle_t *fshandlep;
104 char *cc_readlinkbufp;
105 int cc_readlinkbufsz;
107 xfs_fsop_bulkreq_t bulkreq;
109 while ((c = getopt(argc, argv, "cdl:qv")) != -1) {
127 printf("usage: xfs_bstat [-c] [-q] [-v] [ dir [ batch_size ]]\n");
128 printf(" -c Check the results against stat(3) output\n");
129 printf(" -q Quiet\n");
130 printf(" -l _num_ Inode to start with\n");
131 printf(" -v Verbose output\n");
143 fsfd = open(name, O_RDONLY);
151 nent = atoi(*++argv);
154 printf("Bulkstat test on %s, batch size=%d statcheck=%d\n",
158 fshandlep = jdm_getfshandle( name );
160 printf("unable to construct sys handle for %s: %s\n",
161 name, strerror(errno));
166 t = malloc(nent * sizeof(*t));
170 "XFS_IOC_FSBULKSTAT test: last=%lld nent=%d\n", last, nent);
172 bulkreq.lastip = &last;
173 bulkreq.icount = nent;
175 bulkreq.ocount = &count;
177 while ((ret = ioctl(fsfd, XFS_IOC_FSBULKSTAT, &bulkreq)) == 0) {
182 "XFS_IOC_FSBULKSTAT test: last=%lld ret=%d count=%d total=%d\n",
183 last, ret, count, total);
187 if ( quiet && ! statit )
190 for (i = 0; i < count; i++) {
196 switch(t[i].bs_mode & S_IFMT) {
198 cc_readlinkbufsz = MAXPATHLEN;
199 cc_readlinkbufp = (char *)calloc(
202 nread = jdm_readlink(
207 if (verbose && nread > 0)
209 "readlink: ino %lld: <%*s>\n",
213 free(cc_readlinkbufp);
216 "could not read symlink ino %llu\n",
230 fd = jdm_open( fshandlep, &t[i], O_RDONLY);
233 "unable to open handle ino %lld: %s\n",
234 t[i].bs_ino, strerror(errno));
237 if (fstat64(fd, &sb) < 0) {
239 "unable to stat ino %lld: %s\n",
240 t[i].bs_ino, strerror(errno));
245 * Don't compare blksize or blocks,
246 * they are used differently by stat
249 if ( (t[i].bs_ino != sb.st_ino) ||
250 (t[i].bs_mode != sb.st_mode) ||
251 (t[i].bs_nlink != sb.st_nlink) ||
252 (t[i].bs_uid != sb.st_uid) ||
253 (t[i].bs_gid != sb.st_gid) ||
254 (t[i].bs_rdev != sb.st_rdev) ||
255 (t[i].bs_size != sb.st_size) ||
256 /* (t[i].bs_blksize != sb.st_blksize) || */
257 (t[i].bs_mtime.tv_sec != sb.st_mtime) ||
258 (t[i].bs_ctime.tv_sec != sb.st_ctime) ) {
259 printf("\nstat/bstat missmatch\n");
275 perror("ioctl(XFS_IOC_FSBULKSTAT)");
279 "XFS_IOC_FSBULKSTAT test: last=%lld nent=%d ret=%d count=%d\n",
280 last, nent, ret, count);