changeset 13892:3e7a63d0e0ea

3394 combine /usr/bin/df and /usr/xpg4/bin/df Reviewed by: Garrett D'Amore <garrett@damore.org> Reviewed by: Albert Lee <trisk@nexenta.com> Approved by: Eric Schrock <eric.schrock@delphix.com>
author Paul B. Henson <henson@acm.org>
date Fri, 30 Nov 2012 06:41:32 -0800
parents 4a1840e41e13
children b67bcd07cb92
files usr/src/cmd/fs.d/Makefile usr/src/cmd/fs.d/df.c usr/src/man/man1m/df.1m usr/src/pkg/manifests/system-xopen-xcu4.mf
diffstat 4 files changed, 26 insertions(+), 87 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/fs.d/Makefile	Fri Nov 30 06:26:32 2012 -0800
+++ b/usr/src/cmd/fs.d/Makefile	Fri Nov 30 06:41:32 2012 -0800
@@ -32,7 +32,6 @@
 DFPROG=		df
 PROG=		$(DFPROG) fsck volcopy ff
 ROOTFS_PROG=	mount umount
-XPG4PROG=	df
 SPPROG=		clri
 MNTTAB=		mnttab
 DEFAULTFILES=	fs.dfl
@@ -45,7 +44,6 @@
 SUBDIRS= $(SUBDIR1) $(SUBDIR2)
 I18NDIRS= $(SUBDIR2)
 
-CLOBBERFILES += $(POFILES_XPG4)
 
 all:=		TARGET= all
 install:=	TARGET= install
@@ -61,6 +59,7 @@
 ETC2SBIN=	mount umount
 ETC2USRSBIN=	clri fsdb mkfs fsck labelit dcopy volcopy ff ncheck
 USRBIN2USRSBIN=	df
+USRXPG4BIN2USRSBIN= df
 
 FSLIB=		fslib.o
 
@@ -74,6 +73,7 @@
 SYMETC2SBIN	=	$(ETC2SBIN:%=$(ROOTETC)/%)
 SYMETC2USRSBIN	=	$(ETC2USRSBIN:%=$(ROOTETC)/%)
 SYMUSRBIN2USRSBIN=	$(USRBIN2USRSBIN:%=$(ROOTBIN)/%)
+SYMUSRXPG4BIN2USRSBIN=	$(USRXPG4BIN2USRSBIN:%=$(ROOTXPG4BIN)/%)
 SYMDEVNM=		$(ROOTUSRSBIN)/devnm
 
 CPPFLAGS += -D_LARGEFILE64_SOURCE
@@ -84,7 +84,6 @@
 CERRWARN += -_gcc=-Wno-uninitialized
 CERRWARN += -_gcc=-Wno-unused-function
 
-%.xpg4.o := CPPFLAGS += -DXPG4
 $(SPPROG) :=	LDLIBS += -lkstat
 
 $(ROOTETCMNTTAB) := FILEMODE = 444
@@ -94,21 +93,10 @@
 POFILE= fs.d.po
 POFILES1= $(PROG:%=%.po) $(ROOTFS_PROG:%=%.po) switchout.po fssnapsup.po
 POFILES2= $(I18NDIRS:%=%/%.po)
-POFILES_XPG4 = df.po.xpg4
-POFILES=  $(POFILES1) $(POFILES2) $(POFILES_XPG4)
-$(POFILES_XPG4) := CFLAGS += -DXPG4
+POFILES=  $(POFILES1) $(POFILES2)
 volcopy.po :=   XGETFLAGS += -a -x volcopy.xcl
-$(POFILES_XPG4) :=	XGETFLAGS += -a -x df.xcl
 $(DFPROG).po := XGETFLAGS += -a -x df.xcl
 
-%.po.xpg4:	%.c
-	$(COMPILE.cpp) $< > $<.i
-	$(BUILD.po)
-
-# build rule for xpg4 objects
-%.xpg4.o: %.c
-	$(COMPILE.c) -o $@ $<
-
 .KEEP_STATE:
 
 # This is too intense when building the whole world.
@@ -116,22 +104,22 @@
 
 all:		$(FSLIB) .WAIT $(SUBDIRS) .WAIT all_local
 
-_msg: $(I18NDIRS) $(POFILES1) $(POFILES_XPG4)
+_msg: $(I18NDIRS) $(POFILES1)
 	$(RM) $(POFILE)
 	cat $(POFILES) > $(POFILE)
 	$(RM) $(MSGDOMAIN)/$(POFILE)
 	cp $(POFILE) $(MSGDOMAIN)
 
-all_local:	$(PROG) $(ROOTFS_PROG) $(XPG4PROG) $(SPPROG) $(MNTTAB) \
+all_local:	$(PROG) $(ROOTFS_PROG) $(SPPROG) $(MNTTAB) \
 		$(DEFAULTFILES)
 
 ff volcopy: deffs.o $$(@F).o
 		$(LINK.c) -o $@ $@.o deffs.o $(LDLIBS)
 		$(POST_PROCESS)
 
-df df.xpg4: deffs.o $(FSLIB) $$(@F).o
-		$(LINK.c) -o $@ $@.o deffs.o $(FSLIB) $(LDLIBS)
-		$(POST_PROCESS)
+df: deffs.o $(FSLIB) $$(@F).o
+	$(LINK.c) -o $@ $@.o deffs.o $(FSLIB) $(LDLIBS)
+	$(POST_PROCESS)
 
 fsck: fsck.o deffs.o preenlib.o
 	$(LINK.c) -o $@ fsck.o deffs.o preenlib.o $(LDLIBS)
@@ -153,8 +141,9 @@
 
 install_local:	all_local $(ROOTSBINPROG) $(ROOTUSRSBINF) $(ROOTUSRSBINCLRI) \
 		$(ROOTUSRSBINFF) $(ROOTETCMNTTAB) $(ROOTETCDEFAULTFILES) \
-		$(ROOTXPG4PROG) $(SYMETC2SBIN) $(SYMETC2USRSBIN) \
-		$(SYMUSRBIN2USRSBIN) $(SYMDEVNM) $(ROOTUSRSBINLINKS)
+		$(SYMETC2SBIN) $(SYMETC2USRSBIN) \
+		$(SYMUSRBIN2USRSBIN) $(SYMUSRXPG4BIN2USRSBIN) $(SYMDEVNM) \
+		$(ROOTUSRSBINLINKS)
 
 # Links from /etc to /sbin such as /etc/mount -> ../sbin/mount
 $(SYMETC2SBIN):
@@ -168,6 +157,10 @@
 $(SYMUSRBIN2USRSBIN):
 	-$(RM) $@; $(SYMLINK) ../sbin/$(@F) $@
 
+# Links from /usr/xpg4/bin to /usr/sbin such as /usr/xpg4/bin/df -> ../sbin/df
+$(SYMUSRXPG4BIN2USRSBIN):
+	-$(RM) $@; $(SYMLINK) ../../sbin/$(@F) $@
+
 # Links from /usr/sbin to /sbin such as /usr/sbin/mount -> ../../sbin/mount
 $(ROOTUSRSBINLINKS):
 	-$(RM) $@; $(SYMLINK) ../../sbin/$(@F) $@
--- a/usr/src/cmd/fs.d/df.c	Fri Nov 30 06:26:32 2012 -0800
+++ b/usr/src/cmd/fs.d/df.c	Fri Nov 30 06:41:32 2012 -0800
@@ -109,13 +109,8 @@
 #define	FSTYPE_WIDTH		8
 #define	BLOCK_WIDTH		8
 #define	NFILES_WIDTH		8
-#ifdef XPG4
 #define	KBYTE_WIDTH		11
 #define	AVAILABLE_WIDTH		10
-#else
-#define	KBYTE_WIDTH		7
-#define	AVAILABLE_WIDTH		6
-#endif
 #define	SCALED_WIDTH		6
 #define	CAPACITY_WIDTH		9
 #define	BSIZE_WIDTH		6
@@ -341,17 +336,10 @@
 static void
 usage(void)
 {
-#ifdef  XPG4
 	errmsg(ERR_NONAME,
-	    "Usage: %s [-F FSType] [-abeghklmntPVZ]"
+	    "Usage: %s [-F FSType] [-abeghklmntPVvZ]"
 	    " [-o FSType-specific_options]"
 	    " [directory | block_device | resource]", program_name);
-#else
-	errmsg(ERR_NONAME,
-	    "Usage: %s [-F FSType] [-abeghklmntVvZ]"
-	    " [-o FSType-specific_options]"
-	    " [directory | block_device | resource]", program_name);
-#endif
 	exit(1);
 	/* NOTREACHED */
 }
@@ -580,11 +568,7 @@
 
 	opterr = 0;	/* getopt shouldn't complain about unknown options */
 
-#ifdef XPG4
-	while ((arg = getopt(argc, argv, "F:o:abehkVtgnlmPZ")) != EOF) {
-#else
-	while ((arg = getopt(argc, argv, "F:o:abehkVtgnlmvZ")) != EOF) {
-#endif
+	while ((arg = getopt(argc, argv, "F:o:abehkVtgnlmPvZ")) != EOF) {
 		if (arg == 'F') {
 			if (F_option)
 				errmsg(ERR_FATAL + ERR_USAGE,
@@ -595,10 +579,8 @@
 			V_option = TRUE;
 		} else if (arg == 'v' && ! v_option) {
 			v_option = TRUE;
-#ifdef XPG4
 		} else if (arg == 'P' && ! P_option) {
 			SET_OPTION(P);
-#endif
 		} else if (arg == 'a' && ! a_option) {
 			SET_OPTION(a);
 		} else if (arg == 'b' && ! b_option) {
@@ -1077,17 +1059,10 @@
 
 		(void) printf("%-*s %*s %*s %*s %-*s %s\n",
 		    FILESYSTEM_WIDTH, TRANSLATE("Filesystem"),
-#ifdef XPG4
 		    SCALED_WIDTH, TRANSLATE("Size"),
 		    SCALED_WIDTH, TRANSLATE("Used"),
 		    AVAILABLE_WIDTH, TRANSLATE("Available"),
 		    CAPACITY_WIDTH, TRANSLATE("Capacity"),
-#else
-		    SCALED_WIDTH, TRANSLATE("size"),
-		    SCALED_WIDTH, TRANSLATE("used"),
-		    AVAILABLE_WIDTH, TRANSLATE("avail"),
-		    CAPACITY_WIDTH, TRANSLATE("capacity"),
-#endif
 		    TRANSLATE("Mounted on"));
 		SET_OPTION(h);
 		return;
@@ -1097,17 +1072,10 @@
 
 		(void) printf(gettext("%-*s %*s %*s %*s %-*s %s\n"),
 		    FILESYSTEM_WIDTH, TRANSLATE("Filesystem"),
-#ifdef XPG4
 		    KBYTE_WIDTH, TRANSLATE("1024-blocks"),
 		    KBYTE_WIDTH, TRANSLATE("Used"),
 		    KBYTE_WIDTH, TRANSLATE("Available"),
 		    CAPACITY_WIDTH, TRANSLATE("Capacity"),
-#else
-		    KBYTE_WIDTH, TRANSLATE("kbytes"),
-		    KBYTE_WIDTH, TRANSLATE("used"),
-		    KBYTE_WIDTH, TRANSLATE("avail"),
-		    CAPACITY_WIDTH, TRANSLATE("capacity"),
-#endif
 		    TRANSLATE("Mounted on"));
 		SET_OPTION(h);
 		return;
@@ -1117,10 +1085,10 @@
 
 		(void) printf(gettext("%-*s %*s %*s %*s %-*s %s\n"),
 		    FILESYSTEM_WIDTH, TRANSLATE("Filesystem"),
-		    KBYTE_WIDTH, TRANSLATE("mbytes"),
-		    KBYTE_WIDTH, TRANSLATE("used"),
-		    KBYTE_WIDTH, TRANSLATE("avail"),
-		    CAPACITY_WIDTH, TRANSLATE("capacity"),
+		    KBYTE_WIDTH, TRANSLATE("1M-blocks"),
+		    KBYTE_WIDTH, TRANSLATE("Used"),
+		    KBYTE_WIDTH, TRANSLATE("Available"),
+		    CAPACITY_WIDTH, TRANSLATE("Capacity"),
 		    TRANSLATE("Mounted on"));
 		SET_OPTION(h);
 		return;
--- a/usr/src/man/man1m/df.1m	Fri Nov 30 06:26:32 2012 -0800
+++ b/usr/src/man/man1m/df.1m	Fri Nov 30 06:41:32 2012 -0800
@@ -10,20 +10,13 @@
 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
 .\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the
 .\" fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH DF 1M "Jul 26, 2009"
+.TH DF 1M "Nov 15, 2012"
 .SH NAME
 df \- displays number of free disk blocks and free files
 .SH SYNOPSIS
 .LP
 .nf
-\fB/usr/bin/df\fR [\fB-F\fR \fIFSType\fR] [\fB-abeghklmntVvZ\fR]
-     [\fB-o\fR \fIFSType-specific_options\fR]
-     [\fIblock_device\fR | \fIdirectory\fR | \fIfile\fR | \fIresource\fR ...]
-.fi
-
-.LP
-.nf
-\fB/usr/xpg4/bin/df\fR [\fB-F\fR \fIFSType\fR] [\fB-abeghklmnPtVZ\fR]
+\fB/usr/bin/df\fR [\fB-F\fR \fIFSType\fR] [\fB-abeghklmnPtVvZ\fR]
      [\fB-o\fR \fIFSType-specific_options\fR]
      [\fIblock_device\fR | \fIdirectory\fR | \fIfile\fR | \fIresource\fR ...]
 .fi
@@ -48,10 +41,6 @@
 automounter mounts the file system, the sizes will be reported correctly.
 .SH OPTIONS
 .sp
-.LP
-The following options are supported for both \fB/usr/bin/df\fR and
-\fB/usr/xpg4/bin/df\fR:
-.sp
 .ne 2
 .na
 \fB\fB-a\fR\fR
@@ -229,10 +218,6 @@
 zone.
 .RE
 
-.SS "/usr/bin/df"
-.sp
-.LP
-The following option is supported for \fB/usr/bin/df\fR only:
 .sp
 .ne 2
 .na
@@ -284,10 +269,6 @@
 .RE
 .RE
 
-.SS "/usr/xpg4/bin/df"
-.sp
-.LP
-The following option is supported for \fB/usr/xpg4/bin/df\fR only:
 .sp
 .ne 2
 .na
@@ -397,7 +378,7 @@
 .sp
 .in +2
 .nf
-example% \fB/usr/xpg4/bin/df -P /usr\fR
+example% \fB/usr/bin/df -P /usr\fR
 .fi
 .in -2
 .sp
@@ -413,7 +394,7 @@
 .sp
 .in +2
 .nf
-example% \fB/usr/xpg4/bin/df -P /usr/src\fR
+example% \fB/usr/bin/df -P /usr/src\fR
 .fi
 .in -2
 .sp
@@ -523,10 +504,7 @@
 .sp
 .LP
 See \fBattributes\fR(5) for descriptions of the following attributes:
-.SS "/usr/xpg4/bin/df"
-.sp
 
-.sp
 .TS
 box;
 c | c
--- a/usr/src/pkg/manifests/system-xopen-xcu4.mf	Fri Nov 30 06:26:32 2012 -0800
+++ b/usr/src/pkg/manifests/system-xopen-xcu4.mf	Fri Nov 30 06:41:32 2012 -0800
@@ -44,7 +44,6 @@
 file path=usr/xpg4/bin/crontab mode=4555
 file path=usr/xpg4/bin/ctags mode=0555
 file path=usr/xpg4/bin/date mode=0555
-file path=usr/xpg4/bin/df mode=0555
 file path=usr/xpg4/bin/du mode=0555
 file path=usr/xpg4/bin/ed mode=0555
 file path=usr/xpg4/bin/edit mode=0555
@@ -88,6 +87,7 @@
 link path=usr/xpg4/bin/bg target=../../bin/alias
 link path=usr/xpg4/bin/cd target=../../bin/alias
 link path=usr/xpg4/bin/command target=../../bin/alias
+link path=usr/xpg4/bin/df target=../../sbin/df
 link path=usr/xpg4/bin/fc target=../../bin/alias
 link path=usr/xpg4/bin/fg target=../../bin/alias
 link path=usr/xpg4/bin/getopts target=../../bin/alias