Skip to content

Commit

Permalink
3394 combine /usr/bin/df and /usr/xpg4/bin/df
Browse files Browse the repository at this point in the history
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Albert Lee <trisk@nexenta.com>
Approved by: Eric Schrock <eric.schrock@delphix.com>
  • Loading branch information
pbhenson authored and Eric Schrock committed Nov 30, 2012
1 parent 790c646 commit 90a1a13
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 87 deletions.
37 changes: 15 additions & 22 deletions usr/src/cmd/fs.d/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
DFPROG= df
PROG= $(DFPROG) fsck volcopy ff
ROOTFS_PROG= mount umount
XPG4PROG= df
SPPROG= clri
MNTTAB= mnttab
DEFAULTFILES= fs.dfl
Expand All @@ -45,7 +44,6 @@ SUBDIR2= dev fd pcfs nfs hsfs proc ctfs udfs ufs tmpfs cachefs \
SUBDIRS= $(SUBDIR1) $(SUBDIR2)
I18NDIRS= $(SUBDIR2)

CLOBBERFILES += $(POFILES_XPG4)

all:= TARGET= all
install:= TARGET= install
Expand All @@ -61,6 +59,7 @@ USRSBINFF= ncheck
ETC2SBIN= mount umount
ETC2USRSBIN= clri fsdb mkfs fsck labelit dcopy volcopy ff ncheck
USRBIN2USRSBIN= df
USRXPG4BIN2USRSBIN= df

FSLIB= fslib.o

Expand All @@ -74,6 +73,7 @@ ROOTETCMNTTAB= $(MNTTAB:%=$(ROOTETC)/%)
SYMETC2SBIN = $(ETC2SBIN:%=$(ROOTETC)/%)
SYMETC2USRSBIN = $(ETC2USRSBIN:%=$(ROOTETC)/%)
SYMUSRBIN2USRSBIN= $(USRBIN2USRSBIN:%=$(ROOTBIN)/%)
SYMUSRXPG4BIN2USRSBIN= $(USRXPG4BIN2USRSBIN:%=$(ROOTXPG4BIN)/%)
SYMDEVNM= $(ROOTUSRSBIN)/devnm

CPPFLAGS += -D_LARGEFILE64_SOURCE
Expand All @@ -84,7 +84,6 @@ CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-uninitialized
CERRWARN += -_gcc=-Wno-unused-function

%.xpg4.o := CPPFLAGS += -DXPG4
$(SPPROG) := LDLIBS += -lkstat

$(ROOTETCMNTTAB) := FILEMODE = 444
Expand All @@ -94,44 +93,33 @@ $(ROOTETCMNTTAB) := FILEMODE = 444
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.
# .PARALLEL: $(SUBDIRS)

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)
Expand All @@ -153,8 +141,9 @@ install: $(FSLIB) .WAIT $(SUBDIRS) .WAIT install_local

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):
Expand All @@ -168,6 +157,10 @@ $(SYMETC2USRSBIN):
$(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) $@
Expand Down
44 changes: 6 additions & 38 deletions usr/src/cmd/fs.d/df.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,8 @@ extern char *default_fstype(char *);
#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
Expand Down Expand Up @@ -341,17 +336,10 @@ errmsg(int flags, char *fmt, ...)
static void
usage(void)
{
#ifdef XPG4
errmsg(ERR_NONAME,
"Usage: %s [-F FSType] [-abeghklmntPVZ]"
" [-o FSType-specific_options]"
" [directory | block_device | resource]", program_name);
#else
errmsg(ERR_NONAME,
"Usage: %s [-F FSType] [-abeghklmntVvZ]"
"Usage: %s [-F FSType] [-abeghklmntPVvZ]"
" [-o FSType-specific_options]"
" [directory | block_device | resource]", program_name);
#endif
exit(1);
/* NOTREACHED */
}
Expand Down Expand Up @@ -580,11 +568,7 @@ parse_options(int argc, char *argv[])

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,
Expand All @@ -595,10 +579,8 @@ parse_options(int argc, char *argv[])
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) {
Expand Down Expand Up @@ -1077,17 +1059,10 @@ print_header(void)

(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;
Expand All @@ -1097,17 +1072,10 @@ print_header(void)

(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;
Expand All @@ -1117,10 +1085,10 @@ print_header(void)

(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;
Expand Down
30 changes: 4 additions & 26 deletions usr/src/man/man1m/df.1m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -48,10 +41,6 @@ mounted, the file system size will be reported as zero. As soon as the
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
Expand Down Expand Up @@ -229,10 +218,6 @@ located within the current zone. This option has no effect in a non-global
zone.
.RE

.SS "/usr/bin/df"
.sp
.LP
The following option is supported for \fB/usr/bin/df\fR only:
.sp
.ne 2
.na
Expand Down Expand Up @@ -284,10 +269,6 @@ the percentage of blocks in use by files
.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
Expand Down Expand Up @@ -397,7 +378,7 @@ system:
.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
Expand All @@ -413,7 +394,7 @@ following example writes portable information :
.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
Expand Down Expand Up @@ -523,10 +504,7 @@ List of default parameters for each file system
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.SS "/usr/xpg4/bin/df"
.sp

.sp
.TS
box;
c | c
Expand Down
2 changes: 1 addition & 1 deletion usr/src/pkg/manifests/system-xopen-xcu4.mf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ file path=usr/xpg4/bin/cp mode=0555
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
Expand Down Expand Up @@ -88,6 +87,7 @@ link path=usr/xpg4/bin/alias target=../../bin/alias
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
Expand Down

0 comments on commit 90a1a13

Please sign in to comment.