xfs
[Top] [All Lists]

Re: [PATCH 15/19] mkfs: don't treat files as though they are block devic

To: xfs@xxxxxxxxxxx
Subject: Re: [PATCH 15/19] mkfs: don't treat files as though they are block devices
From: Eric Sandeen <sandeen@xxxxxxxxxxx>
Date: Mon, 2 May 2016 18:13:39 -0500
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1461231593-31294-16-git-send-email-jtulak@xxxxxxxxxx>
References: <1461231593-31294-1-git-send-email-jtulak@xxxxxxxxxx> <1461231593-31294-16-git-send-email-jtulak@xxxxxxxxxx>
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.0
Add const to other copy of check_overwrite
Move "no mkfs target" check to a higher, more obvious location
Do not truncate file unless it needs to be grown to full fs (as in
Jan's v2)

Eric Sandeen <sandeen@xxxxxxxxxx>: move check for no mkfs target
Eric Sandeen <sandeen@xxxxxxxxxx>: other minor fixes
---

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index ec24884..1643289 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -951,7 +951,7 @@ out_free_probe:
  access are not working!
 static int
 check_overwrite(
-       char            *device)
+       const char      *device)
 {
        return 1;
 }
@@ -1037,10 +1037,6 @@ check_device_type(
                usage();
        }
 
-       if (name == NULL) {
-               usage();
-       }
-
        if (stat64(name, &statbuf)) {
                if (errno == ENOENT && *isfile) {
                        if (create)
@@ -2218,6 +2214,11 @@ main(
        } else
                dfile = xi.dname;
 
+       if (!dfile) {
+               fprintf(stderr, _("no device name given in argument list\n"));
+               usage();
+       }
+
        /*
         * Blocksize and sectorsize first, other things depend on them
         * For RAID4/5/6 we want to align sector size and block size,
@@ -3127,13 +3128,15 @@ _("size %s specified for log subvolume is too large, 
maximum is %lld blocks\n"),
 
        /*
         * If the data area is a file, then grow it out to its final size
-        * so that the reads for the end of the device in the mount code
-        * will succeed.
+        * if needed so that the reads for the end of the device in the mount
+        * code will succeed.
         */
-       if (xi.disfile && ftruncate64(xi.dfd, dblocks * blocksize) < 0) {
-               fprintf(stderr, _("%s: Growing the data section failed\n"),
-                       progname);
-               exit(1);
+       if (xi.disfile && xi.dsize * xi.dbsize < dblocks * blocksize) {
+               if (ftruncate64(xi.dfd, dblocks * blocksize) < 0) {
+                       fprintf(stderr, _("%s: Growing the data section 
failed\n"),
+                               progname);
+                       exit(1);
+               }
        }
 
        /*


<Prev in Thread] Current Thread [Next in Thread>
  • Re: [PATCH 15/19] mkfs: don't treat files as though they are block devices, Eric Sandeen <=