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/
36 #include <sys/ioctl.h>
39 dotime(void *ti, char *s)
44 t = (xfs_bstime_t *)ti;
46 c = ctime(&t->tv_sec);
47 printf("\t%s %19.19s.%09d %s", s, c, t->tv_nsec, c + 20);
51 printbstat(xfs_bstat_t *sp)
53 printf("ino %lld mode %#o nlink %d uid %d gid %d rdev %#x\n",
54 sp->bs_ino, sp->bs_mode, sp->bs_nlink,
55 sp->bs_uid, sp->bs_gid, sp->bs_rdev);
56 printf("\tblksize %d size %lld blocks %lld xflags %#x extsize %d\n",
57 sp->bs_blksize, sp->bs_size, sp->bs_blocks,
58 sp->bs_xflags, sp->bs_extsize);
59 dotime(&sp->bs_atime, "atime");
60 dotime(&sp->bs_mtime, "mtime");
61 dotime(&sp->bs_ctime, "ctime");
62 printf( "\textents %d %d gen %d\n",
63 sp->bs_extents, sp->bs_aextents, sp->bs_gen);
64 printf( "\tDMI: event mask 0x%08x state 0x%04x\n",
65 sp->bs_dmevmask, sp->bs_dmstate);
69 printstat(struct stat64 *sp)
71 printf("ino %lld mode %#o nlink %d uid %d gid %d rdev %#x\n",
72 (xfs_ino_t)sp->st_ino, sp->st_mode, sp->st_nlink,
73 sp->st_uid, sp->st_gid, (unsigned int)sp->st_rdev);
74 printf("\tblksize %llu size %lld blocks %lld\n",
75 (__uint64_t)sp->st_blksize, sp->st_size, sp->st_blocks);
76 dotime(&sp->st_atime, "atime");
77 dotime(&sp->st_mtime, "mtime");
78 dotime(&sp->st_ctime, "ctime");
82 main(int argc, char **argv)
97 jdm_fshandle_t *fshandlep = NULL;
101 char *cc_readlinkbufp;
102 int cc_readlinkbufsz;
104 xfs_fsop_bulkreq_t bulkreq;
106 while ((c = getopt(argc, argv, "cdl:qv")) != -1) {
124 printf("usage: xfs_bstat [-c] [-q] [-v] [ dir [ batch_size ]]\n");
125 printf(" -c Check the results against stat(3) output\n");
126 printf(" -q Quiet\n");
127 printf(" -l _num_ Inode to start with\n");
128 printf(" -v Verbose output\n");
140 fsfd = open(name, O_RDONLY);
148 nent = atoi(*++argv);
151 printf("Bulkstat test on %s, batch size=%d statcheck=%d\n",
155 fshandlep = jdm_getfshandle( name );
157 printf("unable to construct sys handle for %s: %s\n",
158 name, strerror(errno));
163 t = malloc(nent * sizeof(*t));
167 "XFS_IOC_FSBULKSTAT test: last=%lld nent=%d\n", last, nent);
169 bulkreq.lastip = &last;
170 bulkreq.icount = nent;
172 bulkreq.ocount = &count;
174 while ((ret = ioctl(fsfd, XFS_IOC_FSBULKSTAT, &bulkreq)) == 0) {
179 "XFS_IOC_FSBULKSTAT test: last=%lld ret=%d count=%d total=%d\n",
180 last, ret, count, total);
184 if ( quiet && ! statit )
187 for (i = 0; i < count; i++) {
193 switch(t[i].bs_mode & S_IFMT) {
195 cc_readlinkbufsz = MAXPATHLEN;
196 cc_readlinkbufp = (char *)calloc(
199 nread = jdm_readlink(
204 if (verbose && nread > 0)
206 "readlink: ino %lld: <%*s>\n",
210 free(cc_readlinkbufp);
213 "could not read symlink ino %llu\n",
227 fd = jdm_open( fshandlep, &t[i], O_RDONLY);
230 "unable to open handle ino %lld: %s\n",
231 t[i].bs_ino, strerror(errno));
234 if (fstat64(fd, &sb) < 0) {
236 "unable to stat ino %lld: %s\n",
237 t[i].bs_ino, strerror(errno));
242 * Don't compare blksize or blocks,
243 * they are used differently by stat
246 if ( (t[i].bs_ino != sb.st_ino) ||
247 (t[i].bs_mode != sb.st_mode) ||
248 (t[i].bs_nlink != sb.st_nlink) ||
249 (t[i].bs_uid != sb.st_uid) ||
250 (t[i].bs_gid != sb.st_gid) ||
251 (t[i].bs_rdev != sb.st_rdev) ||
252 (t[i].bs_size != sb.st_size) ||
253 /* (t[i].bs_blksize != sb.st_blksize) || */
254 (t[i].bs_mtime.tv_sec != sb.st_mtime) ||
255 (t[i].bs_ctime.tv_sec != sb.st_ctime) ) {
256 printf("\nstat/bstat missmatch\n");
272 perror("ioctl(XFS_IOC_FSBULKSTAT)");
276 "XFS_IOC_FSBULKSTAT test: last=%lld nent=%d ret=%d count=%d\n",
277 last, nent, ret, count);