Module Name: src Committed By: perseant Date: Thu Feb 2 03:49:22 UTC 2012
Modified Files: src/sbin/newfs_lfs: newfs.c Log Message: If invoked with -D and creating an image file, ensure that the image file is filled to the given size. This prevents false failures with "lfs: ifile read: 22" in ATF tests. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sbin/newfs_lfs/newfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/newfs_lfs/newfs.c diff -u src/sbin/newfs_lfs/newfs.c:1.25 src/sbin/newfs_lfs/newfs.c:1.26 --- src/sbin/newfs_lfs/newfs.c:1.25 Tue Feb 16 23:20:30 2010 +++ src/sbin/newfs_lfs/newfs.c Thu Feb 2 03:49:22 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: newfs.c,v 1.25 2010/02/16 23:20:30 mlelstv Exp $ */ +/* $NetBSD: newfs.c,v 1.26 2012/02/02 03:49:22 perseant Exp $ */ /*- * Copyright (c) 1989, 1992, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19 #if 0 static char sccsid[] = "@(#)newfs.c 8.5 (Berkeley) 5/24/95"; #else -__RCSID("$NetBSD: newfs.c,v 1.25 2010/02/16 23:20:30 mlelstv Exp $"); +__RCSID("$NetBSD: newfs.c,v 1.26 2012/02/02 03:49:22 perseant Exp $"); #endif #endif /* not lint */ @@ -275,8 +275,18 @@ main(int argc, char **argv) special = device; } if (!Nflag) { - fso = open(special, - (debug ? O_CREAT : 0) | O_RDWR, DEFFILEMODE); + fso = open(special, O_RDWR, DEFFILEMODE); + if (debug && fso < 0) { + /* Create a file of the requested size. */ + fso = open(special, O_CREAT | O_RDWR, DEFFILEMODE); + if (fso >= 0) { + char buf[512]; + int i; + for (i = 0; i < fssize; i++) + write(fso, buf, sizeof(buf)); + lseek(fso, 0, SEEK_SET); + } + } if (fso < 0) fatal("%s: %s", special, strerror(errno)); } else