Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/newfs_lfs If invoked with -D and creating an image file...



details:   https://anonhg.NetBSD.org/src/rev/6e98837460c6
branches:  trunk
changeset: 773437:6e98837460c6
user:      perseant <perseant%NetBSD.org@localhost>
date:      Thu Feb 02 03:49:22 2012 +0000

description:
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.

diffstat:

 sbin/newfs_lfs/newfs.c |  18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diffs (39 lines):

diff -r 9019080a8156 -r 6e98837460c6 sbin/newfs_lfs/newfs.c
--- a/sbin/newfs_lfs/newfs.c    Thu Feb 02 03:47:11 2012 +0000
+++ b/sbin/newfs_lfs/newfs.c    Thu Feb 02 03:49:22 2012 +0000
@@ -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 @@
 #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 @@
                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



Home | Main Index | Thread Index | Old Index