Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Sep 2006 11:17:54 -0500
From:      "Christian S.J. Peron" <csjp@FreeBSD.org>
To:        Andriy Gapon <avg@icyb.net.ua>
Cc:        freebsd-stable@freebsd.org
Subject:   Re: df -kP != df -Pk
Message-ID:  <45101832.7010009@FreeBSD.org>
In-Reply-To: <45101281.7090508@icyb.net.ua>
References:  <45101281.7090508@icyb.net.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------000507050408010505060703
Content-Type: text/plain; charset=KOI8-U; format=flowed
Content-Transfer-Encoding: 7bit

Andriy Gapon wrote:
> It seems that -P flag to df resets previously specified -k for no good
> reason. POSIX expressly talks about -P and -k being used together.
> http://www.opengroup.org/onlinepubs/009695399/utilities/df.html
>
> This is FreeBSD 6.1-RELEASE-p2 i386.
>
>   
Please test the attached patch and let me know if it's good for you.

Thanks for bringing this to our attention.

-- 
Christian S.J. Peron
csjp@FreeBSD.ORG
FreeBSD Committer
FreeBSD Security Team


--------------000507050408010505060703
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="df.c.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="df.c.diff"

? df
? df.1.gz
? df.c.diff
Index: df.c
===================================================================
RCS file: /home/ncvs/src/bin/df/df.c,v
retrieving revision 1.64
diff -u -r1.64 df.c
--- df.c	10 Jan 2005 08:39:21 -0000	1.64
+++ df.c	19 Sep 2006 16:14:37 -0000
@@ -93,7 +93,7 @@
 	return (a > b ? a : b);
 }
 
-static int	aflag = 0, cflag, hflag, iflag, nflag;
+static int	aflag = 0, cflag, hflag, kflag, iflag, nflag, Pflag;
 static struct	ufs_args mdev;
 
 int
@@ -123,6 +123,7 @@
 		case 'b':
 				/* FALLTHROUGH */
 		case 'P':
+			Pflag++;
 			putenv("BLOCKSIZE=512");
 			hflag = 0;
 			break;
@@ -143,6 +144,7 @@
 			iflag = 1;
 			break;
 		case 'k':
+			kflag++;
 			putenv("BLOCKSIZE=1k");
 			hflag = 0;
 			break;
@@ -171,6 +173,12 @@
 	argc -= optind;
 	argv += optind;
 
+	/*
+	 * POSIX specifies that if both -P and -k options are used together a
+	 * 1k blocksize should be used.
+	 */
+	if (Pflag != 0 && kflag != 0)
+		putenv("BLOCKSIZE=1k");
 	mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
 	bzero(&maxwidths, sizeof(maxwidths));
 	for (i = 0; i < mntsize; i++)

--------------000507050408010505060703--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?45101832.7010009>