From howardjp@wam.umd.edu Wed Aug 11 05:22:04 1999
Return-Path: <howardjp@wam.umd.edu>
Received: from po3.wam.umd.edu (po3.wam.umd.edu [128.8.10.165])
	by hub.freebsd.org (Postfix) with ESMTP id 1F99414DF5
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 11 Aug 1999 05:22:02 -0700 (PDT)
	(envelope-from howardjp@wam.umd.edu)
Received: from rac10.wam.umd.edu (root@rac10.wam.umd.edu [128.8.10.150])
	by po3.wam.umd.edu (8.9.3/8.9.3) with ESMTP id IAA11275
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 11 Aug 1999 08:20:59 -0400 (EDT)
Received: from rac10.wam.umd.edu (sendmail@localhost [127.0.0.1])
	by rac10.wam.umd.edu (8.9.3/8.9.3) with SMTP id IAA04670
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 11 Aug 1999 08:20:58 -0400 (EDT)
Received: (from howardjp@localhost)
	by rac10.wam.umd.edu (8.9.3/8.9.3) id IAA04666
	for FreeBSD-gnats-submit@freebsd.org; Wed, 11 Aug 1999 08:20:58 -0400 (EDT)
Message-Id: <199908111220.IAA04666@rac10.wam.umd.edu>
Date: Wed, 11 Aug 1999 08:20:58 -0400 (EDT)
From: James Howard <howardjp@wam.umd.edu>
Reply-To: howardjp@wam.umd.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: link(1) as required by Unix 98
X-Send-Pr-Version: 3.2

>Number:         13071
>Category:       bin
>Synopsis:       link(1) as required by Unix 98
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    sheldonh
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 11 05:30:02 PDT 1999
>Closed-Date:    Mon Dec 20 08:15:06 PST 1999
>Last-Modified:  Mon Dec 20 08:16:14 PST 1999
>Originator:     James Howard
>Release:        FreeBSD 3.2-STABLE i386
>Organization:
University of Maryland
>Environment:

FreeBSD byzantine 3.2-STABLE FreeBSD 3.2-STABLE #5: Sat Aug  7 23:43:54 GMT 1999     root@byzantine:/usr/src/sys/compile/BYZANTINE  i386

>Description:

After opening my big mouth on freebsd-advocacy about how Unix 98
compliance was a worthy goal, more than one person told me to go
ahead and send in PRs with changes.  Well, here is another :)

This contains a shar of link(1).  link accepts two arguments and
runs link(2) on them thus creating a hard link.  NetBSD places 
this in /usr/sbin and puts the man page in section 8, but nothing 
in the standard dictates where it should be.  I have the man page
in section 1.  If this is inappropriate, it can be changed without
pain.  This implementation contains no NetBSD code.

>How-To-Repeat:

Irrelevant.

>Fix:

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	Makefile
#	link.1
#	link.c
#
echo x - Makefile
sed 's/^X//' >Makefile << 'END-of-Makefile'
XPROG=	link
X
X.include <bsd.prog.mk>
END-of-Makefile
echo x - link.1
sed 's/^X//' >link.1 << 'END-of-link.1'
X.\" Copyright (c) 1999 James Howard
X.\" All rights reserved.
X.\"
X.\" Redistribution and use in source and binary forms, with or without
X.\" modification, are permitted provided that the following conditions
X.\" are met:
X.\" 1. Redistributions of source code must retain the above copyright
X.\"    notice, this list of conditions and the following disclaimer.
X.\" 2. Redistributions in binary form must reproduce the above copyright
X.\"    notice, this list of conditions and the following disclaimer in the
X.\"    documentation and/or other materials provided with the distribution.
X.\"
X.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X.\" SUCH DAMAGE.
X.\"
X.\"
X.\"     $Id$
X.\"
X.Dd August 10, 1999
X.Dt LINK 1
X.Os
X.Sh NAME
X.Nm link
X.Nd call the
X.Xr link 2
Xfunction
X.Sh SYNOPSIS
X.Nm link
X.Ar file1 file2
X.Sh DESCRIPTION
XThe 
X.Nm
Xutility calls
X.Xr link 2
Xwith the arguments
X.Ar file2
Xand
X.Ar file1 .
X.Sh USAGE
X.Nm Link
Xcreates a hard link from the source file
X.Ar file1
Xdestination file
X.Ar file2 .
X.Sh SEE ALSO
X.Xr ln 1 ,
X.Xr unlink 1 ,
X.Xr link 2 ,
X.Xr unlink 2
X.Sh STANDARDS
XThe
X.Nm
Xutility is expected to be
XXPG5 
Xcompliant.END-of-link.1
echo x - link.c
sed 's/^X//' >link.c << 'END-of-link.c'
X/*-
X * Copyright (c) 1999 James Howard
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X *
X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X *
X *      $Id$
X */
X
X#include <err.h>
X#include <stdio.h>
X#include <unistd.h>
X
Xvoid help(void);
X
Xint main(int argc, char **argv) 
X{
X	int e;
X	
X	if(argc != 3)
X		help();
X	
X	if((e = link(argv[1], argv[2])) != 0)
X		err(!e, "%s", argv[1]);
X	
X	return 0;
X}
X
Xvoid help(void) 
X{
X	
X	fprintf(stderr, "usage: link file1 file2\n");
X	exit(1);
X}
END-of-link.c
exit


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->sheldonh 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Wed Sep 8 07:07:01 PDT 1999 
Responsible-Changed-Why:  
James and I are discussing PR 13070, PR 13071 and PR 13074, which are 
all related. 

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: howardjp@wam.umd.edu
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/13071: link(1) as required by Unix 98 
Date: Mon, 20 Dec 1999 16:51:30 +0200

 On Wed, 11 Aug 1999 08:20:58 -0400, James Howard wrote:
 
 > This contains a shar of link(1).  link accepts two arguments and
 > runs link(2) on them thus creating a hard link.  NetBSD places 
 > this in /usr/sbin and puts the man page in section 8, but nothing 
 > in the standard dictates where it should be.
 
 Not only have they placed it in an odd part of the hierarchy, but I
 think it's silly to make link(1) its own command anyway.  It's basically
 just a value-subtracted version on ln(1).  If we make it a hardlink, it
 won't chew diskspace.
 
 Here's what I propose.
 
 Ciao,
 Sheldon.
 
 Index: Makefile
 ===================================================================
 RCS file: /home/ncvs/src/bin/ln/Makefile,v
 retrieving revision 1.6
 diff -u -d -r1.6 Makefile
 --- Makefile	1999/08/27 23:14:27	1.6
 +++ Makefile	1999/12/20 12:56:54
 @@ -5,4 +5,7 @@
  MAN1=	ln.1
  MAN7=	symlink.7
  
 +LINKS=	${BINDIR}/ln ${BINDIR}/link
 +MLINKS=	ln.1 link.1
 +
  .include <bsd.prog.mk>
 Index: ln.1
 ===================================================================
 RCS file: /home/ncvs/src/bin/ln/ln.1,v
 retrieving revision 1.9
 diff -u -d -r1.9 ln.1
 --- ln.1	1999/09/11 10:06:56	1.9
 +++ ln.1	1999/12/20 13:18:40
 @@ -39,7 +39,8 @@
  .Dt LN 1
  .Os BSD 4
  .Sh NAME
 -.Nm ln
 +.Nm ln ,
 +.Nm link
  .Nd make links
  .Sh SYNOPSIS
  .Nm ln
 @@ -50,6 +51,8 @@
  .Op Fl fsv
  .Ar source_file ...
  .Op target_dir
 +.Nm link
 +.Ar source_file Ar target_file
  .Sh DESCRIPTION
  The
  .Nm
 @@ -122,6 +125,12 @@
  .Ar target_dir
  to all the named source files.
  The links made will have the same name as the files being linked to.
 +.Pp
 +When the utility is called as
 +.Nm link ,
 +exactly two arguments must be supplied,
 +neither of which may specify a directory.
 +No options may be supplied in this simple mode of operation.
  .Sh SEE ALSO
  .Xr link 2 ,
  .Xr lstat 2 ,
 @@ -138,3 +147,7 @@
  .Nm
  command appeared in
  .At v1 .
 +The simplified
 +.Nm link
 +command conforms to
 +.St -susv2 .
 Index: ln.c
 ===================================================================
 RCS file: /home/ncvs/src/bin/ln/ln.c,v
 retrieving revision 1.14
 diff -u -d -r1.14 ln.c
 --- ln.c	1999/09/11 10:06:56	1.14
 +++ ln.c	1999/12/20 14:31:11
 @@ -73,7 +73,24 @@
  	extern int optind;
  	struct stat sb;
  	int ch, exitval;
 -	char *sourcedir;
 +	char *p, *sourcedir;
 +
 +	/*
 +	 * Test for the special case where the utility is called as
 +	 * "link", for which the functionality provided is greatly
 +	 * simplified.
 +	 */
 +	if ((p = rindex(argv[0], '/')) == NULL)
 +		p = argv[0];
 +	else
 +		++p;
 +	if (strcmp(p, "link") == 0) {
 +		if (argc == 3) {
 +			linkf = link;
 +			exit(linkit(argv[1], argv[2], 0));
 +		} else
 +			usage();
 +	}
  
  	while ((ch = getopt(argc, argv, "fsv")) != -1)
  		switch (ch) {
 @@ -167,8 +184,9 @@
  void
  usage()
  {
 -	(void)fprintf(stderr, "%s\n%s\n",
 +	(void)fprintf(stderr, "%s\n%s\n%s\n",
  	    "usage: ln [-fsv] file1 file2",
 -	    "       ln [-fsv] file ... directory");
 +	    "       ln [-fsv] file ... directory",
 +	    "       link file1 file2");
  	exit(1);
  }
 
State-Changed-From-To: open->closed 
State-Changed-By: sheldonh 
State-Changed-When: Mon Dec 20 08:15:06 PST 1999 
State-Changed-Why:  
Implemented as a special case of ln(1).  Since 3.4-RELEASE is  
expected to be the last release on the RELENG_3 branch, this 
will not be merged from CURRENT. 
>Unformatted:
