From: Nathan Scott Date: Mon, 19 May 2003 04:56:35 +0000 (+0000) Subject: QA source updates and some associated test changes X-Git-Tag: v1.1.0~992 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=9fcfacdeb55b8823b0c7177818401d1feffb1523;p=users%2Fhch%2Fxfstests-dev.git QA source updates and some associated test changes --- diff --git a/034 b/034 index f2bcbcd24..36fcd0205 100755 --- a/034 +++ b/034 @@ -2,7 +2,7 @@ # XFS QA Test No. 034 # $Id: 1.1 $ # -# pv 801241 - check for reference leaks from the *handle ioctls +# pv 801241 - check for reference leaks from the *handle xfsctls # #----------------------------------------------------------------------- # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. @@ -82,9 +82,9 @@ then exit fi -if ! src/ioctl $SCRATCH_MNT $SCRATCH_MNT/fish >/dev/null 2>&1 +if ! src/xfsctl $SCRATCH_MNT $SCRATCH_MNT/fish >/dev/null 2>&1 then - echo "!!! failed to run ioctl test program" + echo "!!! failed to run xfsctl test program" exit fi diff --git a/048 b/048 index c56952364..bab0d16cc 100755 --- a/048 +++ b/048 @@ -2,7 +2,7 @@ # XFS QA Test No. 048 # $Id: 1.1 $ # -# test return codes from ioctl on bad userspace address +# test return codes from xfsctl on bad userspace address # #----------------------------------------------------------------------- # Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. diff --git a/048.out b/048.out index e6feb5f56..76278b601 100644 --- a/048.out +++ b/048.out @@ -1,5 +1,5 @@ QA output created by 048 ---- ioctl with bad output address +--- xfsctl with bad output address --- got error 14 as expected ---- ioctl with bad input address +--- xfsctl with bad input address --- got error 14 as expected diff --git a/src/alloc.c b/src/alloc.c index 07fa68b9a..17359fdf0 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -78,8 +78,9 @@ void usage(void) } -int fd; -int blocksize = 0; +int fd = -1; +int blocksize; +char *filename; /* params are in bytes */ void map(off64_t off, off64_t len) @@ -103,7 +104,7 @@ void map(off64_t off, off64_t len) printf(" [ofs,count]: start..end\n"); for (;;) { - if (ioctl(fd, XFS_IOC_GETBMAP, bm) < 0) { + if (xfsctl(filename, fd, XFS_IOC_GETBMAP, bm) < 0) { perror("getbmap"); break; } @@ -129,8 +130,8 @@ main(int argc, char **argv) int c; char *dirname = NULL; int done = 0; + int status = 0; struct flock64 f; - char *filename = NULL; off64_t len; char line[1024]; off64_t off; @@ -201,31 +202,33 @@ main(int argc, char **argv) perror(filename); exit(1); } - if (unlinkit) - unlink(filename); if (!blocksize) { - if (fstatvfs64(fd, &svfs) < 0) { - perror(filename); - exit(1); - } + if (fstatvfs64(fd, &svfs) < 0) { + perror(filename); + status = 1; + goto done; + } blocksize = (int)svfs.f_bsize; - } - if (blocksize<0) { - fprintf(stderr,"illegal blocksize %d\n", blocksize); - exit(1); - } + } + if (blocksize<0) { + fprintf(stderr,"illegal blocksize %d\n", blocksize); + status = 1; + goto done; + } printf(" blocksize %d\n", blocksize); if (rflag) { struct fsxattr a; - if (ioctl(fd, XFS_IOC_FSGETXATTR, &a) < 0) { + if (xfsctl(filename, fd, XFS_IOC_FSGETXATTR, &a) < 0) { perror("XFS_IOC_FSGETXATTR"); - exit(1); + status = 1; + goto done; } a.fsx_xflags |= XFS_XFLAG_REALTIME; - if (ioctl(fd, XFS_IOC_FSSETXATTR, &a) < 0) { + if (xfsctl(filename, fd, XFS_IOC_FSSETXATTR, &a) < 0) { perror("XFS_IOC_FSSETXATTR"); - exit(1); + status = 1; + goto done; } } while (!done) { @@ -269,7 +272,7 @@ main(int argc, char **argv) opnames[opno], (__s64)off, (__s64)len); f.l_len = len; - c = ioctl(fd, optab[opno], &f); + c = xfsctl(filename, fd, optab[opno], &f); if (c < 0) { perror(opnames[opno]); break; @@ -327,8 +330,12 @@ main(int argc, char **argv) break; } } - if (!nflag) printf("\n"); - close(fd); - exit(0); + if (!nflag) printf("\n"); +done: + if (fd != -1) + close(fd); + if (unlinkit) + unlink(filename); + exit(status); /* NOTREACHED */ } diff --git a/src/bstat.c b/src/bstat.c index aee1b1b68..f8939c767 100644 --- a/src/bstat.c +++ b/src/bstat.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -30,10 +30,8 @@ * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ */ -#include -#include -#include -#include +#include +#include void dotime(void *ti, char *s) @@ -171,7 +169,7 @@ main(int argc, char **argv) bulkreq.ubuffer = t; bulkreq.ocount = &count; - while ((ret = ioctl(fsfd, XFS_IOC_FSBULKSTAT, &bulkreq)) == 0) { + while ((ret = xfsctl(name, fsfd, XFS_IOC_FSBULKSTAT, &bulkreq)) == 0) { total += count; if (verbose) @@ -269,7 +267,7 @@ main(int argc, char **argv) close(fsfd); if (ret < 0 ) - perror("ioctl(XFS_IOC_FSBULKSTAT)"); + perror("xfsctl(XFS_IOC_FSBULKSTAT)"); if (verbose) printf( diff --git a/src/devzero.c b/src/devzero.c index c172c47b1..920290a85 100644 --- a/src/devzero.c +++ b/src/devzero.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -30,8 +30,7 @@ * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ */ -#include -#include +#include int main(int argc, char **argv) diff --git a/src/fault.c b/src/fault.c index 011a9076c..bfeb0a8b0 100644 --- a/src/fault.c +++ b/src/fault.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -30,8 +30,7 @@ * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ */ -#include -#include +#include void expect_error(int r, int err) { @@ -63,10 +62,10 @@ main(int argc, char **argv) exit(1); } - printf("--- ioctl with bad output address\n"); - expect_error(ioctl(fsfd, XFS_IOC_FSCOUNTS, NULL), EFAULT); - printf("--- ioctl with bad input address\n"); - expect_error(ioctl(fsfd, XFS_IOC_SET_RESBLKS, NULL), EFAULT); + printf("--- xfsctl with bad output address\n"); + expect_error(xfsctl(argv[1], fsfd, XFS_IOC_FSCOUNTS, NULL), EFAULT); + printf("--- xfsctl with bad input address\n"); + expect_error(xfsctl(argv[1], fsfd, XFS_IOC_SET_RESBLKS, NULL), EFAULT); close(fsfd); diff --git a/src/feature.c b/src/feature.c index 9e9ade6b1..57b3a2f92 100644 --- a/src/feature.c +++ b/src/feature.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -42,11 +42,11 @@ * Return code: 0 is true, anything else is error/not supported */ -#include +#include #include #include #include -#include +#include int verbose = 0; diff --git a/src/fill2.c b/src/fill2.c index 1d77530d0..78260d44f 100644 --- a/src/fill2.c +++ b/src/fill2.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -42,25 +42,9 @@ * and is more careful about checking when write operations fail - this is * needed by fill2fs to ensure that the number of bytes written is accurately * determined. - * - * To compile standalone on IRIX: cc -DTOOL_ONLY -o fill2 fill2.c -lgen - * - * $Id$ */ -#include -#include -#include -#include -#include -#include -#include - -#ifndef TOOL_ONLY -#include -#else -#define constpp char * const * -#endif /* TOOL_ONLY */ +#include #define N(x) (sizeof(x)/sizeof(x[0])) diff --git a/src/global.h b/src/global.h index 2227ff043..5120c12c0 100644 --- a/src/global.h +++ b/src/global.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -35,17 +35,14 @@ /* xfs-specific includes */ -#include -#include +#include +#include /* libc includes */ -#include #include #include -#include #include -#include #include #endif diff --git a/src/loggen.c b/src/loggen.c index 9c0108764..3dfab9de9 100644 --- a/src/loggen.c +++ b/src/loggen.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -39,10 +39,9 @@ * - dxm 29/09/00 */ -#include -#include -#include -#include +#include +#include +#include void usage() diff --git a/src/mmapcat.c b/src/mmapcat.c index c42427050..f40b20783 100644 --- a/src/mmapcat.c +++ b/src/mmapcat.c @@ -1,10 +1,11 @@ /* mmapcat.c - derived from source by misiek@pld.ORG.PL */ -#include +#include +#include +#include #include #include #include -#include int main(int argc, char **argv) { diff --git a/src/randholes.c b/src/randholes.c index a75ebac2e..cf290cf7c 100644 --- a/src/randholes.c +++ b/src/randholes.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -56,7 +56,7 @@ struct fsxattr rtattr; void usage(char *progname); int findblock(void); -void writeblks(int fd); +void writeblks(char *fname, int fd); int readblks(int fd); void dumpblock(int *buffer, __uint64_t offset, int blocksize); @@ -154,8 +154,8 @@ main(int argc, char *argv[]) return 1; } if (rt) { - if (ioctl(fd, XFS_IOC_FSGETXATTR, &rtattr) < 0) { - perror("ioctl(XFS_IOC_FSGETXATTR)"); + if (xfsctl(filename, fd, XFS_IOC_FSGETXATTR, &rtattr) < 0) { + perror("xfsctl(XFS_IOC_FSGETXATTR)"); return 1; } if ((rtattr.fsx_xflags & XFS_XFLAG_REALTIME) == 0 || @@ -163,15 +163,15 @@ main(int argc, char *argv[]) rtattr.fsx_xflags |= XFS_XFLAG_REALTIME; if (extsize) rtattr.fsx_extsize = extsize * blocksize; - if (ioctl(fd, XFS_IOC_FSSETXATTR, &rtattr) < 0) { - perror("ioctl(XFS_IOC_FSSETXATTR)"); + if (xfsctl(filename, fd, XFS_IOC_FSSETXATTR, &rtattr) < 0) { + perror("xfsctl(XFS_IOC_FSSETXATTR)"); return 1; } } } if (direct) { - if (ioctl(fd, XFS_IOC_DIOINFO, &diob) < 0) { - perror("ioctl(XFS_IOC_FIOINFO)"); + if (xfsctl(filename, fd, XFS_IOC_DIOINFO, &diob) < 0) { + perror("xfsctl(XFS_IOC_FIOINFO)"); return 1; } if (blocksize % diob.d_miniosz) { @@ -180,7 +180,7 @@ main(int argc, char *argv[]) } } printf(test?"write (skipped)\n":"write\n"); - writeblks(fd); + writeblks(filename, fd); printf("readback\n"); r=readblks(fd); if (close(fd) < 0) { @@ -199,7 +199,7 @@ main(int argc, char *argv[]) } void -writeblks(int fd) +writeblks(char *fname, int fd) { __uint64_t offset; char *buffer; @@ -229,8 +229,8 @@ writeblks(int fd) fl.l_start = offset; fl.l_len = blocksize; fl.l_whence = 0; - if (ioctl(fd, XFS_IOC_RESVSP64, &fl) < 0) { - perror("ioctl(XFS_IOC_RESVSP64)"); + if (xfsctl(fname, fd, XFS_IOC_RESVSP64, &fl) < 0) { + perror("xfsctl(XFS_IOC_RESVSP64)"); exit(1); } continue;