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
[EMAIL PROTECTED]
FreeBSD Committer
FreeBSD Security Team

? 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++)
_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to