Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Sep 2006 11:34:22 -0500
From:      "Christian S.J. Peron" <csjp@FreeBSD.org>
To:        freebsd-standards@FreeBSD.org
Subject:   [Fwd: Re: df -kP != df -Pk]
Message-ID:  <45101C0E.4010202@FreeBSD.org>

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

Anyone have any objections to me committing this patch?


-------- Original Message --------
Subject: 	Re: df -kP != df -Pk
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
References: 	<45101281.7090508@icyb.net.ua>



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



--------------060507050802060600000403
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++)


--------------060507050802060600000403
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
	name="file:///tmp/nsmail-2.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="file:///tmp/nsmail-2.txt"

_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscribe@freebsd.org"

--------------060507050802060600000403--



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