From nobody Thu Aug 27 08:29:58 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hVvpG6J0zz6qjcf for ; Thu, 27 Aug 2026 08:29:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hVvpG5ctxz4CqD for ; Thu, 27 Aug 2026 08:29:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787819398; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nMdGWT+lL4yoUAijLawanrMngzywKyNgDp49aPnLK7k=; b=Dy9LS5LD5kw0yJ9ZDAi+iL2lEf+gCyQOdWqOtLKrS5Y5ive9hliLZG4Vbb9rGnepheWyWF VmIj9Y/Xt++n06uOLZR2RDyjSQa28QoVW3UXXLgc4cHs+tqn6uvUvW//DhYjj6MIaosC80 YtTPgXez3CgLL/xXUbQJb/eR5puNyV42bLnHsZd47rhTE13/U6GvbfmpQbQKw7v8R4W+Vr VmlOKKn3vJGRZ3XZojK6dKIt8jqhEdZNsxAy7HA3lOV3xPNQ/4r9Gf4tZgx5e5t+Z8sooS ENNT+TGFjcaY2EcMIPHtMRROUe/M6OEIZmOSkWT9RbdcdE87PL4exF7H0W15eg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1787819398; a=rsa-sha256; cv=none; b=jKGrl2qXpmo+TtQAP0Jog7F9qr06+IfCRGZ4qYNoJxC+ldjQdweaL2fny3CJsDaEHwgQdq SepF3PFqeXrPIufwIpvszdPePYJpDtJfUbEBtjlX9O0P47fOwbXVaEUI7WJofmW1SZQuyO KQ1Tid8zM8df23FHTEA0c5bWssbmPI2cr1TTF7I/Lkg8AMX3Cc8I3Of1oB1n8ybyd+arOP gWGJB6eiNxO/njNPoYvapzEx/h1BUOGLfvzppwBKrQK/1j+SjDjKHdAeCW3QqJF1iByF+X ftQLv2PKljRIQf3Vv3nlYjavpGjWC7K/7jJqEeJchczSDKsHKHvjB9h5pYY7Ig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787819398; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nMdGWT+lL4yoUAijLawanrMngzywKyNgDp49aPnLK7k=; b=ScSPuB8p7vBNMtVBkJkPScudGlWQPRZFxI833aPNf5KoMgdGzmKo0gdJsmA1FuKFBIRc7J LybDzDZZmAvyz8iayYnS3+l1y3AADTCJdcnmCB7LyGkpXBEH6ehG9crgJiV4dkqPA3tOTg 2Zpfc0Td8EIqaZPaa3QSyR75q+ccDbgpYbiTG7+viApPhtFRSs6m9p2WnGOhvOcW2BZHJy 41QXkuW9snMWDQoR7Nimmoyn6fDF0efi1jgkSIfpP0qvFCWfYS/okn8fO3jf9/y170ZIHc 8YVCMAwT5QOBRZLjyHzJJ4LJnNZ0Aftti7+86J2HDS6/TQBcbTwQ3IeWu88cDQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hVvpG4DWQz1DY for ; Thu, 27 Aug 2026 08:29:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 30a57 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 27 Aug 2026 08:29:58 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Peter Holm Subject: git: 2b93d98aab53 - main - stress2: Use the new version of fsx in ports instead of the older one in tools/regression List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pho X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2b93d98aab5386f923fb5e6fef2b7457222bb554 Auto-Submitted: auto-generated Date: Thu, 27 Aug 2026 08:29:58 +0000 Message-Id: <6a8ff586.30a57.7e70e217@gitrepo.freebsd.org> The branch main has been updated by pho: URL: https://cgit.FreeBSD.org/src/commit/?id=2b93d98aab5386f923fb5e6fef2b7457222bb554 commit 2b93d98aab5386f923fb5e6fef2b7457222bb554 Author: Peter Holm AuthorDate: 2026-08-27 08:28:45 +0000 Commit: Peter Holm CommitDate: 2026-08-27 08:28:45 +0000 stress2: Use the new version of fsx in ports instead of the older one in tools/regression Suggested by: asomers --- tools/test/stress2/misc/1st.sh | 1 + tools/test/stress2/misc/ext2fs3.sh | 12 +- tools/test/stress2/misc/msdos10.sh | 30 +- tools/test/stress2/misc/msdos9.sh | 14 +- tools/test/stress2/misc/tmpfs5.sh | 16 +- tools/test/stress2/misc/umountf2.sh | 1209 +---------------------------------- 6 files changed, 30 insertions(+), 1252 deletions(-) diff --git a/tools/test/stress2/misc/1st.sh b/tools/test/stress2/misc/1st.sh index 59edb7957bfb..4e8de35cef85 100755 --- a/tools/test/stress2/misc/1st.sh +++ b/tools/test/stress2/misc/1st.sh @@ -56,6 +56,7 @@ fi [ -z "`type mke2fs 2>/dev/null`" ] && echo "Consider installing e2fsprogs" [ -z "`type mkisofs 2>/dev/null`" ] && echo "Consider installing cdrtools" [ -z "`type mDNSNetMonitor 2>/dev/null`" ] && echo "Consider installing mDNSResponder" +[ -z "`type fsx 2>/dev/null`" ] && echo "Consider installing fsx" [ ! -x /usr/local/lib/libmill.so ] && echo "Consider installing libmill" # Random sanity checks diff --git a/tools/test/stress2/misc/ext2fs3.sh b/tools/test/stress2/misc/ext2fs3.sh index 5c904d218a5f..c8b0b7c03843 100755 --- a/tools/test/stress2/misc/ext2fs3.sh +++ b/tools/test/stress2/misc/ext2fs3.sh @@ -31,20 +31,14 @@ # "Fatal trap 12: page fault while in kernel mode" seen. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 -[ -r /usr/src/tools/regression/fsx/fsx.c ] || exit 0 . ../default.cfg # Uses mke2fs from filesystems/e2fsprogs [ -z "`type mke2fs 2>/dev/null`" ] && echo "Skipping test as mke2fs not installed" && exit 0 - -dir=/tmp -odir=`pwd` -cd $dir -cc -o fsx -Wall -Wextra -O2 -g /usr/src/tools/regression/fsx/fsx.c || exit 1 -rm -f fsx.c -cd $odir +[ -z "`which fsx`" ] && + { echo "fsx is not installed"; exit 0; } mount | grep "$mntpoint" | grep -q md$mdstart && umount $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart @@ -55,7 +49,7 @@ mke2fs -m 0 -b 1024 /dev/md$mdstart > /dev/null mount -t ext2fs /dev/md$mdstart $mntpoint chmod 777 $mntpoint -cp /tmp/fsx $mntpoint +cp `which fsx` $mntpoint cd $mntpoint ./fsx -S 2016 -N 2000 ./TEST_FILE cd $here diff --git a/tools/test/stress2/misc/msdos10.sh b/tools/test/stress2/misc/msdos10.sh index b581a71d3519..956bbb4ba6ce 100755 --- a/tools/test/stress2/misc/msdos10.sh +++ b/tools/test/stress2/misc/msdos10.sh @@ -34,15 +34,10 @@ . ../default.cfg [ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 -[ -r /usr/src/tools/regression/fsx/fsx.c ] || exit 0 - +[ -z "`which fsx`" ] && + { echo "fsx is not installed"; exit 0; } [ -x /sbin/mount_msdosfs ] || exit 0 -dir=/tmp -odir=`pwd` -cd $dir -cc -o fsx -Wall -Wextra -O2 -g /usr/src/tools/regression/fsx/fsx.c || exit 1 -rm -f fsx.c -cd $odir + log=/tmp/fsx.sh.log mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart @@ -56,20 +51,19 @@ newfs_msdos -b 1024 /dev/md${mdstart}$part > /dev/null mount -t msdosfs /dev/md${mdstart}$part $mntpoint set +e -cp /tmp/fsx $mntpoint - +cp `which fsx` $mntpoint cd $mntpoint NUM_OPS=2000 SEED=2016 ( -./fsx -S ${SEED} -N ${NUM_OPS} ./TEST_FILE0 & -./fsx -S ${SEED} -l 5234123 -o 5156343 -N ${NUM_OPS} ./TEST_FILE1 & -./fsx -S ${SEED} -l 2311244 -o 2311200 -N ${NUM_OPS} ./TEST_FILE2 & -./fsx -S ${SEED} -l 8773121 -o 863672 -N ${NUM_OPS} ./TEST_FILE3 & -./fsx -S ${SEED} -l 234521 -o 234521 -N ${NUM_OPS} ./TEST_FILE4 & -./fsx -S ${SEED} -l 454321 -o 33 -N ${NUM_OPS} ./TEST_FILE5 & -./fsx -S ${SEED} -l 7234125 -o 7876728 -N ${NUM_OPS} ./TEST_FILE6 & +./fsx -S ${SEED} -N ${NUM_OPS} ./TEST_FILE0 & +./fsx -S ${SEED} -N ${NUM_OPS} ./TEST_FILE1 & +./fsx -S ${SEED} -N ${NUM_OPS} ./TEST_FILE2 & +./fsx -S ${SEED} -N ${NUM_OPS} ./TEST_FILE3 & +./fsx -S ${SEED} -N ${NUM_OPS} ./TEST_FILE4 & +./fsx -S ${SEED} -N ${NUM_OPS} ./TEST_FILE5 & +./fsx -S ${SEED} -N ${NUM_OPS} ./TEST_FILE6 & wait ) > /dev/null cd / @@ -87,5 +81,5 @@ if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then umount $mntpoint fi mdconfig -d -u $mdstart -rm /tmp/fsx $log +rm $log exit $s diff --git a/tools/test/stress2/misc/msdos9.sh b/tools/test/stress2/misc/msdos9.sh index d325d4300067..ec9b1e507334 100755 --- a/tools/test/stress2/misc/msdos9.sh +++ b/tools/test/stress2/misc/msdos9.sh @@ -34,15 +34,9 @@ . ../default.cfg [ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 -[ -r /usr/src/tools/regression/fsx/fsx.c ] || exit 0 -[ -x /sbin/mount_msdosfs ] || exit 0 -dir=/tmp -odir=`pwd` -cd $dir -cc -o fsx -Wall -Wextra -O2 -g /usr/src/tools/regression/fsx/fsx.c || exit 1 -rm -f fsx.c -cd $odir +[ -z "`which fsx`" ] && + { echo "fsx is not installed"; exit 0; } log=/tmp/fsx.sh.log mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart @@ -56,7 +50,7 @@ newfs_msdos -b 1024 /dev/md${mdstart}$part > /dev/null mount -t msdosfs /dev/md${mdstart}$part $mntpoint set +e -cp /tmp/fsx $mntpoint +cp `which fsx` $mntpoint cd $mntpoint ./fsx -S 2016 -N 2000 ./TEST_FILE > /dev/null @@ -75,5 +69,5 @@ if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then umount $mntpoint fi mdconfig -d -u $mdstart -rm /tmp/fsx $log +rm $log exit $s diff --git a/tools/test/stress2/misc/tmpfs5.sh b/tools/test/stress2/misc/tmpfs5.sh index 1dd8bbe9a6eb..942c3eb13bfe 100755 --- a/tools/test/stress2/misc/tmpfs5.sh +++ b/tools/test/stress2/misc/tmpfs5.sh @@ -29,25 +29,21 @@ # tmpfs + fsx test scenario. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 +[ -z "`which fsx`" ] && + { echo "fsx is not installed"; exit 0; } . ../default.cfg -here=`pwd` -cd /tmp -sed '1,/^EOF/d' < $here/umountf2.sh > /tmp/fsx.c -mycc -o /tmp/fsx -O2 /tmp/fsx.c || exit 1 -rm -f fsx.c - mount | grep "$mntpoint" | grep -q tmpfs && umount $mntpoint mount -t tmpfs tmpfs $mntpoint ( - /tmp/fsx -q -N 100000 $mntpoint/file.1 & - /tmp/fsx -q -N 100000 $mntpoint/file.2 & + fsx -q -N 100000 $mntpoint/file.1 & + fsx -q -N 100000 $mntpoint/file.2 & ) | grep -v A-OK -wait;wait +wait while mount | grep "$mntpoint" | grep -q tmpfs; do umount $mntpoint || sleep 1 done -rm -f /tmp/fsx +exit 0 diff --git a/tools/test/stress2/misc/umountf2.sh b/tools/test/stress2/misc/umountf2.sh index 5018a804c403..4aa8fdf94d4e 100755 --- a/tools/test/stress2/misc/umountf2.sh +++ b/tools/test/stress2/misc/umountf2.sh @@ -37,9 +37,8 @@ . ../default.cfg -sed '1,/^EOF/d' < $0 > /tmp/fsx.c -mycc -o /tmp/fsx -O2 /tmp/fsx.c || exit 1 -rm -f /tmp/fsx.c +[ -z "`which fsx`" ] && + { echo "fsx is not installed"; exit 0; } D=$diskimage dd if=/dev/zero of=$D bs=1m count=1k status=none || exit 1 @@ -52,7 +51,7 @@ newfs md$mdstart > /dev/null 2>&1 mount /dev/md$mdstart $mntpoint sleep 5 for i in `jot 100`; do - /tmp/fsx -S $i -q $mntpoint/xxx$i > /dev/null & + fsx -S $i -q $mntpoint/xxx$i > /dev/null 2>&1 & done sleep 30 umount -f $mntpoint & @@ -68,1205 +67,5 @@ fi sleep 5 wait mdconfig -d -u $mdstart -rm -f $D /tmp/fsx +rm -f $D ./fsx.core exit 0 -EOF -/* - * Copyright (c) 1998-2001 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 2.0 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - * - * File: fsx.c - * Author: Avadis Tevanian, Jr. - * - * File system exerciser. - * - * Rewrite and enhancements 1998-2001 Conrad Minshall -- conrad@mac.com - * - * Various features from Joe Sokol, Pat Dirks, and Clark Warner. - * - * Small changes to work under Linux -- davej@suse.de - * - * Sundry porting patches from Guy Harris 12/2001 - * - * Checks for mmap last-page zero fill. - * - * Updated license to APSL 2.0, 2004/7/27 - Jordan Hubbard - * - */ - -#include -#include -#ifdef _UWIN -# include -# include -# include -# include -#endif -#include -#include -#ifndef MAP_FILE -# define MAP_FILE 0 -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -#define NUMPRINTCOLUMNS 32 /* # columns of data to print on each line */ - -/* - * A log entry is an operation and a bunch of arguments. - */ - -struct log_entry { - int operation; - int args[3]; -}; - -#define LOGSIZE 1000 - -struct log_entry oplog[LOGSIZE]; /* the log */ -int logptr = 0; /* current position in log */ -int logcount = 0; /* total ops */ - -/* - * Define operations - */ - -#define OP_READ 1 -#define OP_WRITE 2 -#define OP_TRUNCATE 3 -#define OP_CLOSEOPEN 4 -#define OP_MAPREAD 5 -#define OP_MAPWRITE 6 -#define OP_SKIPPED 7 -#define OP_INVALIDATE 8 - -int page_size; -int page_mask; - -char *original_buf; /* a pointer to the original data */ -char *good_buf; /* a pointer to the correct data */ -char *temp_buf; /* a pointer to the current data */ -char *fname; /* name of our test file */ -int fd; /* fd for our test file */ - -off_t file_size = 0; -off_t biggest = 0; -char state[256]; -unsigned long testcalls = 0; /* calls to function "test" */ - -unsigned long simulatedopcount = 0; /* -b flag */ -int closeprob = 0; /* -c flag */ -int invlprob = 0; /* -i flag */ -int debug = 0; /* -d flag */ -unsigned long debugstart = 0; /* -D flag */ -unsigned long maxfilelen = 256 * 1024; /* -l flag */ -int sizechecks = 1; /* -n flag disables them */ -int maxoplen = 64 * 1024; /* -o flag */ -int quiet = 0; /* -q flag */ -unsigned long progressinterval = 0; /* -p flag */ -int readbdy = 1; /* -r flag */ -int style = 0; /* -s flag */ -int truncbdy = 1; /* -t flag */ -int writebdy = 1; /* -w flag */ -long monitorstart = -1; /* -m flag */ -long monitorend = -1; /* -m flag */ -int lite = 0; /* -L flag */ -long numops = -1; /* -N flag */ -int randomoplen = 1; /* -O flag disables it */ -int seed = 1; /* -S flag */ -int mapped_writes = 1; /* -W flag disables */ -int mapped_reads = 1; /* -R flag disables it */ -int mapped_msync = 1; /* -U flag disables */ -int fsxgoodfd = 0; -FILE * fsxlogf = NULL; -int badoff = -1; -int closeopen = 0; -int invl = 0; - -void -vwarnc(code, fmt, ap) - int code; - const char *fmt; - va_list ap; -{ - fprintf(stderr, "fsx: "); - if (fmt != NULL) { - vfprintf(stderr, fmt, ap); - fprintf(stderr, ": "); - } - fprintf(stderr, "%s\n", strerror(code)); -} - -void -warn(const char * fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - vwarnc(errno, fmt, ap); - va_end(ap); -} - -void -prt(char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - vfprintf(stdout, fmt, args); - va_end(args); - - if (fsxlogf) { - va_start(args, fmt); - vfprintf(fsxlogf, fmt, args); - va_end(args); - } -} - -void -prterr(char *prefix) -{ - prt("%s%s%s\n", prefix, prefix ? ": " : "", strerror(errno)); -} - -void -do_log4(int operation, int arg0, int arg1, int arg2) -{ - struct log_entry *le; - - le = &oplog[logptr]; - le->operation = operation; - le->args[0] = arg0; - le->args[1] = arg1; - le->args[2] = arg2; - logptr++; - logcount++; - if (logptr >= LOGSIZE) - logptr = 0; -} - -void -log4(int operation, int arg0, int arg1, int arg2) -{ - do_log4(operation, arg0, arg1, arg2); - if (closeopen) - do_log4(OP_CLOSEOPEN, 0, 0, 0); - if (invl) - do_log4(OP_INVALIDATE, 0, 0, 0); -} - -void -logdump(void) -{ - struct log_entry *lp; - int i, count, down, opnum; - - prt("LOG DUMP (%d total operations):\n", logcount); - if (logcount < LOGSIZE) { - i = 0; - count = logcount; - } else { - i = logptr; - count = LOGSIZE; - } - - opnum = i + 1 + (logcount/LOGSIZE)*LOGSIZE; - for ( ; count > 0; count--) { - lp = &oplog[i]; - - if (lp->operation == OP_CLOSEOPEN || - lp->operation == OP_INVALIDATE) { - switch (lp->operation) { - case OP_CLOSEOPEN: - prt("\t\tCLOSE/OPEN\n"); - break; - case OP_INVALIDATE: - prt("\t\tMS_INVALIDATE\n"); - break; - } - i++; - if (i == LOGSIZE) - i = 0; - continue; - } - - prt("%d(%d mod 256): ", opnum, opnum%256); - switch (lp->operation) { - case OP_MAPREAD: - prt("MAPREAD\t0x%x thru 0x%x\t(0x%x bytes)", - lp->args[0], lp->args[0] + lp->args[1] - 1, - lp->args[1]); - if (badoff >= lp->args[0] && badoff < - lp->args[0] + lp->args[1]) - prt("\t***RRRR***"); - break; - case OP_MAPWRITE: - prt("MAPWRITE 0x%x thru 0x%x\t(0x%x bytes)", - lp->args[0], lp->args[0] + lp->args[1] - 1, - lp->args[1]); - if (badoff >= lp->args[0] && badoff < - lp->args[0] + lp->args[1]) - prt("\t******WWWW"); - break; - case OP_READ: - prt("READ\t0x%x thru 0x%x\t(0x%x bytes)", - lp->args[0], lp->args[0] + lp->args[1] - 1, - lp->args[1]); - if (badoff >= lp->args[0] && - badoff < lp->args[0] + lp->args[1]) - prt("\t***RRRR***"); - break; - case OP_WRITE: - prt("WRITE\t0x%x thru 0x%x\t(0x%x bytes)", - lp->args[0], lp->args[0] + lp->args[1] - 1, - lp->args[1]); - if (lp->args[0] > lp->args[2]) - prt(" HOLE"); - else if (lp->args[0] + lp->args[1] > lp->args[2]) - prt(" EXTEND"); - if ((badoff >= lp->args[0] || badoff >=lp->args[2]) && - badoff < lp->args[0] + lp->args[1]) - prt("\t***WWWW"); - break; - case OP_TRUNCATE: - down = lp->args[0] < lp->args[1]; - prt("TRUNCATE %s\tfrom 0x%x to 0x%x", - down ? "DOWN" : "UP", lp->args[1], lp->args[0]); - if (badoff >= lp->args[!down] && - badoff < lp->args[!!down]) - prt("\t******WWWW"); - break; - case OP_SKIPPED: - prt("SKIPPED (no operation)"); - break; - default: - prt("BOGUS LOG ENTRY (operation code = %d)!", - lp->operation); - } - prt("\n"); - opnum++; - i++; - if (i == LOGSIZE) - i = 0; - } -} - -void -save_buffer(char *buffer, off_t bufferlength, int fd) -{ - off_t ret; - ssize_t byteswritten; - - if (fd <= 0 || bufferlength == 0) - return; - - if (bufferlength > SSIZE_MAX) { - prt("fsx flaw: overflow in save_buffer\n"); - exit(67); - } - if (lite) { - off_t size_by_seek = lseek(fd, (off_t)0, SEEK_END); - if (size_by_seek == (off_t)-1) - prterr("save_buffer: lseek eof"); - else if (bufferlength > size_by_seek) { - warn("save_buffer: .fsxgood file too short... will save 0x%llx bytes instead of 0x%llx\n", (unsigned long long)size_by_seek, - (unsigned long long)bufferlength); - bufferlength = size_by_seek; - } - } - - ret = lseek(fd, (off_t)0, SEEK_SET); - if (ret == (off_t)-1) - prterr("save_buffer: lseek 0"); - - byteswritten = write(fd, buffer, (size_t)bufferlength); - if (byteswritten != bufferlength) { - if (byteswritten == -1) - prterr("save_buffer write"); - else - warn("save_buffer: short write, 0x%x bytes instead of 0x%llx\n", - (unsigned)byteswritten, - (unsigned long long)bufferlength); - } -} - -void -report_failure(int status) -{ - logdump(); - - if (fsxgoodfd) { - if (good_buf) { - save_buffer(good_buf, file_size, fsxgoodfd); - prt("Correct content saved for comparison\n"); - prt("(maybe hexdump \"%s\" vs \"%s.fsxgood\")\n", - fname, fname); - } - close(fsxgoodfd); - } - exit(status); -} - -#define short_at(cp) ((unsigned short)((*((unsigned char *)(cp)) << 8) | \ - *(((unsigned char *)(cp)) + 1))) - -void -check_buffers(unsigned offset, unsigned size) -{ - unsigned char c, t; - unsigned i = 0; - unsigned n = 0; - unsigned op = 0; - unsigned bad = 0; - - if (memcmp(good_buf + offset, temp_buf, size) != 0) { - prt("READ BAD DATA: offset = 0x%x, size = 0x%x\n", - offset, size); - prt("OFFSET\tGOOD\tBAD\tRANGE\n"); - while (size > 0) { - c = good_buf[offset]; - t = temp_buf[i]; - if (c != t) { - if (n == 0) { - bad = short_at(&temp_buf[i]); - prt("0x%5x\t0x%04x\t0x%04x", offset, - short_at(&good_buf[offset]), bad); - op = temp_buf[offset & 1 ? i+1 : i]; - } - n++; - badoff = offset; - } - offset++; - i++; - size--; - } - if (n) { - prt("\t0x%5x\n", n); - if (bad) - prt("operation# (mod 256) for the bad data may be %u\n", ((unsigned)op & 0xff)); - else - prt("operation# (mod 256) for the bad data unknown, check HOLE and EXTEND ops\n"); - } else - prt("????????????????\n"); - report_failure(110); - } -} - -void -check_size(void) -{ - struct stat statbuf; - off_t size_by_seek; - - if (fstat(fd, &statbuf)) { - prterr("check_size: fstat"); - statbuf.st_size = -1; - } - size_by_seek = lseek(fd, (off_t)0, SEEK_END); - if (file_size != statbuf.st_size || file_size != size_by_seek) { - prt("Size error: expected 0x%llx stat 0x%llx seek 0x%llx\n", - (unsigned long long)file_size, - (unsigned long long)statbuf.st_size, - (unsigned long long)size_by_seek); - report_failure(120); - } -} - -void -check_trunc_hack(void) -{ - struct stat statbuf; - - ftruncate(fd, (off_t)0); - ftruncate(fd, (off_t)100000); - fstat(fd, &statbuf); - if (statbuf.st_size != (off_t)100000) { - prt("no extend on truncate! not posix!\n"); - exit(130); - } - ftruncate(fd, (off_t)0); -} - -void -doread(unsigned offset, unsigned size) -{ - off_t ret; - unsigned iret; - - offset -= offset % readbdy; - if (size == 0) { - if (!quiet && testcalls > simulatedopcount) - prt("skipping zero size read\n"); - log4(OP_SKIPPED, OP_READ, offset, size); - return; - } - if (size + offset > file_size) { - if (!quiet && testcalls > simulatedopcount) - prt("skipping seek/read past end of file\n"); - log4(OP_SKIPPED, OP_READ, offset, size); - return; - } - - log4(OP_READ, offset, size, 0); - - if (testcalls <= simulatedopcount) - return; - - if (!quiet && ((progressinterval && - testcalls % progressinterval == 0) || - (debug && - (monitorstart == -1 || - (offset + size > monitorstart && - (monitorend == -1 || offset <= monitorend)))))) - prt("%lu read\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, - offset, offset + size - 1, size); - ret = lseek(fd, (off_t)offset, SEEK_SET); - if (ret == (off_t)-1) { - prterr("doread: lseek"); - report_failure(140); - } - iret = read(fd, temp_buf, size); - if (iret != size) { - if (iret == -1) - prterr("doread: read"); - else - prt("short read: 0x%x bytes instead of 0x%x\n", - iret, size); - report_failure(141); - } - check_buffers(offset, size); -} - -void -check_eofpage(char *s, unsigned offset, char *p, int size) -{ - uintptr_t last_page, should_be_zero; - - if (offset + size <= (file_size & ~page_mask)) - return; - /* - * we landed in the last page of the file - * test to make sure the VM system provided 0's - * beyond the true end of the file mapping - * (as required by mmap def in 1996 posix 1003.1) - */ - last_page = ((uintptr_t)p + (offset & page_mask) + size) & ~page_mask; - - for (should_be_zero = last_page + (file_size & page_mask); - should_be_zero < last_page + page_size; - should_be_zero++) - if (*(char *)should_be_zero) { - prt("Mapped %s: non-zero data past EOF (0x%llx) page offset 0x%x is 0x%04x\n", - s, file_size - 1, should_be_zero & page_mask, - short_at(should_be_zero)); - report_failure(205); - } -} - -void -domapread(unsigned offset, unsigned size) -{ - unsigned pg_offset; - unsigned map_size; - char *p; - - offset -= offset % readbdy; - if (size == 0) { - if (!quiet && testcalls > simulatedopcount) - prt("skipping zero size read\n"); - log4(OP_SKIPPED, OP_MAPREAD, offset, size); - return; - } - if (size + offset > file_size) { - if (!quiet && testcalls > simulatedopcount) - prt("skipping seek/read past end of file\n"); - log4(OP_SKIPPED, OP_MAPREAD, offset, size); - return; - } - - log4(OP_MAPREAD, offset, size, 0); - - if (testcalls <= simulatedopcount) - return; - - if (!quiet && ((progressinterval && - testcalls % progressinterval == 0) || - (debug && - (monitorstart == -1 || - (offset + size > monitorstart && - (monitorend == -1 || offset <= monitorend)))))) - prt("%lu mapread\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, - offset, offset + size - 1, size); - - pg_offset = offset & page_mask; - map_size = pg_offset + size; - - if ((p = (char *)mmap(0, map_size, PROT_READ, MAP_FILE | MAP_SHARED, fd, - (off_t)(offset - pg_offset))) == (char *)-1) { - prterr("domapread: mmap"); - report_failure(190); - } - memcpy(temp_buf, p + pg_offset, size); - - check_eofpage("Read", offset, p, size); - - if (munmap(p, map_size) != 0) { - prterr("domapread: munmap"); - report_failure(191); - } - - check_buffers(offset, size); -} - -void -gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size) -{ - while (size--) { - good_buf[offset] = testcalls % 256; - if (offset % 2) - good_buf[offset] += original_buf[offset]; - offset++; - } -} - -void -dowrite(unsigned offset, unsigned size) -{ - off_t ret; - unsigned iret; - - offset -= offset % writebdy; - if (size == 0) { - if (!quiet && testcalls > simulatedopcount) - prt("skipping zero size write\n"); - log4(OP_SKIPPED, OP_WRITE, offset, size); - return; - } - - log4(OP_WRITE, offset, size, file_size); - - gendata(original_buf, good_buf, offset, size); - if (file_size < offset + size) { - if (file_size < offset) - memset(good_buf + file_size, '\0', offset - file_size); - file_size = offset + size; - if (lite) { - warn("Lite file size bug in fsx!"); - report_failure(149); - } - } - - if (testcalls <= simulatedopcount) - return; - - if (!quiet && ((progressinterval && - testcalls % progressinterval == 0) || - (debug && - (monitorstart == -1 || - (offset + size > monitorstart && - (monitorend == -1 || offset <= monitorend)))))) - prt("%lu write\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, - offset, offset + size - 1, size); - ret = lseek(fd, (off_t)offset, SEEK_SET); - if (ret == (off_t)-1) { - prterr("dowrite: lseek"); - report_failure(150); - } - iret = write(fd, good_buf + offset, size); - if (iret != size) { - if (iret == -1) - prterr("dowrite: write"); - else - prt("short write: 0x%x bytes instead of 0x%x\n", - iret, size); - report_failure(151); - } -} - -void -domapwrite(unsigned offset, unsigned size) -{ - unsigned pg_offset; - unsigned map_size; - off_t cur_filesize; - char *p; - - offset -= offset % writebdy; - if (size == 0) { - if (!quiet && testcalls > simulatedopcount) - prt("skipping zero size write\n"); - log4(OP_SKIPPED, OP_MAPWRITE, offset, size); - return; - } - cur_filesize = file_size; - - log4(OP_MAPWRITE, offset, size, 0); - - gendata(original_buf, good_buf, offset, size); - if (file_size < offset + size) { - if (file_size < offset) - memset(good_buf + file_size, '\0', offset - file_size); - file_size = offset + size; - if (lite) { - warn("Lite file size bug in fsx!"); - report_failure(200); - } - } - - if (testcalls <= simulatedopcount) - return; - - if (!quiet && ((progressinterval && - testcalls % progressinterval == 0) || - (debug && - (monitorstart == -1 || - (offset + size > monitorstart && - (monitorend == -1 || offset <= monitorend)))))) - prt("%lu mapwrite\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, - offset, offset + size - 1, size); - - if (file_size > cur_filesize) { - if (ftruncate(fd, file_size) == -1) { - prterr("domapwrite: ftruncate"); - exit(201); - } - } - pg_offset = offset & page_mask; - map_size = pg_offset + size; - - if ((p = (char *)mmap(0, map_size, PROT_READ | PROT_WRITE, - MAP_FILE | MAP_SHARED, fd, - (off_t)(offset - pg_offset))) == MAP_FAILED) { - prterr("domapwrite: mmap"); - report_failure(202); - } - memcpy(p + pg_offset, good_buf + offset, size); - if (mapped_msync && msync(p, map_size, MS_SYNC) != 0) { - prterr("domapwrite: msync"); - report_failure(203); - } - - check_eofpage("Write", offset, p, size); - - if (munmap(p, map_size) != 0) { - prterr("domapwrite: munmap"); - report_failure(204); - } -} - -void -dotruncate(unsigned size) -{ - int oldsize = file_size; - - size -= size % truncbdy; - if (size > biggest) { - biggest = size; - if (!quiet && testcalls > simulatedopcount) - prt("truncating to largest ever: 0x%x\n", size); - } - - log4(OP_TRUNCATE, size, (unsigned)file_size, 0); - - if (size > file_size) - memset(good_buf + file_size, '\0', size - file_size); - file_size = size; - - if (testcalls <= simulatedopcount) - return; - - if ((progressinterval && testcalls % progressinterval == 0) || - (debug && (monitorstart == -1 || monitorend == -1 || - size <= monitorend))) - prt("%lu trunc\tfrom 0x%x to 0x%x\n", testcalls, oldsize, size); - if (ftruncate(fd, (off_t)size) == -1) { - prt("ftruncate1: %x\n", size); - prterr("dotruncate: ftruncate"); - report_failure(160); - } -} - -void -writefileimage() -{ - ssize_t iret; - - if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) { - prterr("writefileimage: lseek"); - report_failure(171); - } - iret = write(fd, good_buf, file_size); - if ((off_t)iret != file_size) { - if (iret == -1) - prterr("writefileimage: write"); - else *** 448 LINES SKIPPED ***