History log of /freebsd-10.1-release/bin/ln/ln.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 272461 02-Oct-2014 gjb

Copy stable/10@r272459 to releng/10.1 as part of
the 10.1-RELEASE process.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 251261 02-Jun-2013 eadler

Add 'static' where able.


# 226961 31-Oct-2011 ed

Put some static keywords in the source code.

For these simple utilities, it doesn't harm to make all global variables
static. In fact, this allows the compiler to perform better forms of
optimisation and analysis.


# 219680 15-Mar-2011 jilles

bin: Prefer strrchr() to rindex().

This removes the last index/rindex usage from /bin.


# 207021 21-Apr-2010 jilles

ln: Allow a trailing slash when creating a link to a directory.

In the 'ln source... directory' synopsis, the basename of each source
determines the name of the created link. Determine this using basename(3)
instead of strrchr(..., '/') which is incorrect if the pathname ends in a
slash.

The patch is somewhat changed to allow for basename(3) implementations that
change the passed pathname, and to fix the -w option's checking also.
The code to compare directory entries only applies to hard links, which
cannot be created to directories using ln.

Example:
ln -s /etc/defaults/ /tmp
This should create a symlink named defaults.

PR: 121568
Submitted by: Ighighi
MFC after: 1 week


# 206773 17-Apr-2010 jilles

ln: Refuse deleting a directory entry by hardlinking it to itself.

Two pathnames refer to the same directory entry iff the directories match
and the final components' names match.

Example: (assuming file1 is an existing file)
ln -f file1 file1
This now fails while leaving file1 intact. It used to delete file1 and then
complain it cannot be linked because it is gone.

With -i, this error is detected before the question is asked.

MFC after: 2 weeks


# 195768 19-Jul-2009 jilles

Allow creating hard links to symlinks using ln(1).

This implements the POSIX.1-2008 -L and -P flags.

The default remains to create hard links to the target of symlinks.

Approved by: re (kib), ed (mentor)


# 179636 07-Jun-2008 keramida

Unbreak last commit to ln for amd64.

Cast string precision to `int'. amd64 systems warn about the
field precision being `long int' if we don't, and pathnames are
normally short enough to fit in an `int'.

Noticed by: pav


# 179603 06-Jun-2008 keramida

Add a -w warning flag to ln(1). When the -w option is enabled,
ln(1) checks to see if the source of a symlink, i.e. the file it
should point to actually exists. The default is the old ln
behavior, that does not check, to avoid surprising people who may
be using ln(1) in scripts or other non-interactive places.

PR: bin/7265
Submitted by: Joel Ray Holveck, detlev!joelh at mail.camalott.com
MFC after: 2 weeks


# 173702 17-Nov-2007 ru

Express in the usage() and SYNOPSIS that -F depends on -s, and
that -f and -i are exclusive.


# 173701 17-Nov-2007 ru

Swap "source"/"target" where appropriate, to match documentation.


# 155667 14-Feb-2006 glebius

Add '-F' option which allows to delete existing empty directories, when
creating symbolic links.

PR: bin/92149
Submitted by: Eugene Grosbein <eugen grosbein.pp.ru>


# 141578 09-Feb-2005 ru

Sync program's usage() with manpage's SYNOPSIS.


# 139969 10-Jan-2005 imp

/*- or .\"- or #- to begin license clauses.


# 127958 06-Apr-2004 markm

Remove clause 3 from the UCB licenses.

OK'ed by: imp, core


# 114433 01-May-2003 obrien

Quiet warnings about copyright[].


# 101094 31-Jul-2002 markm

Fix an easy WARNS.


# 99109 30-Jun-2002 obrien

Consistently use __FBSDID


# 99019 29-Jun-2002 tjr

Check that snprintf() does not truncate the destination pathname when
linking into a directory.


# 97531 29-May-2002 tjr

Reject options, handle "--" end-of-options marker in link(1).


# 96373 10-May-2002 jedgar

Add semicolon to empty default case to silence warning.


# 91084 22-Feb-2002 markm

Fix warnings inspired by lint, a commercial lint and WARNS=4.


# 90110 02-Feb-2002 imp

o __P has been reoved
o Old-style K&R declarations have been converted to new C89 style
o register has been removed
o prototype for main() has been removed (gcc3 makes it an error)
o int main(int argc, char *argv[]) is the preferred main definition.
o Attempt to not break style(9) conformance for declarations more than
they already are.


# 77404 29-May-2001 imp

Use PATH_MAX in preference to MAXPATHLEN.

Also sort declarations per style(9) (big arrays come last) while I'm
in the area.


# 76877 20-May-2001 kris

Silence WARNS=2 and BDECFLAGS on i386 and alpha

MFC After: 1 week


# 76042 26-Apr-2001 sobomax

Previous commit should read:

style(9) Reviewed by: bde


# 76039 26-Apr-2001 sobomax

Bring in `-h' compatability option and its alias `-n' to match NetBSD and GNU
semantics.

style(9) Reviewed by:
Obtained from: NetBSD


# 64787 17-Aug-2000 sheldonh

Fix style bugs and inconsistencies introduced in rev 1.16.

Submitted by: bde


# 64692 16-Aug-2000 imp

Don't explicitly declare optarg and optind. These are declared in
unistd.h, which is already included.


# 64638 14-Aug-2000 sheldonh

Add the -i option, as found in rm(1), which provides an interactive
mode in which the user is prompted for confirmation before an
existing file is replaced.

Submitted by: alex


# 54895 20-Dec-1999 sheldonh

Add link(1) and unlink(1) as special cases of ln(1) and rm(1)
respectively, in accordance with SUSv2.

This differs from the approach taken in NetBSD, but provides
less obscure error messages in at least the EISDIR case and
does not take up additional disk space for new binaries.

PR: 13071
PR: 13074
Requested by: James Howard <howardjp@wam.umd.edu>


# 51148 11-Sep-1999 obrien

Add verbose processing flag.


# 50471 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 36046 15-May-1998 charnier

Correct use of .Nm. Add rcsid.


# 26465 06-Jun-1997 charnier

Cosmetic change in usage string.


# 24348 28-Mar-1997 imp

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 22988 22-Feb-1997 peter

Revert $FreeBSD$ to $Id$


# 21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 20420 14-Dec-1996 steve

-Wall cleaning.


# 15900 24-May-1996 peter

Nuke the undocumented -F flag, since it doesn't do anything anymore.

It used to allow root to hard-link directories (and screw up programs that
expexted the ".." entry to point to the parent dir)


# 5002 06-Dec-1994 bde

Use lstat() instead of stat() for checking if the final source file exists,
so that `ln -fs' works when the source is a symlink pointing to a non-
existent file.


# 3044 24-Sep-1994 dg

Added $Id$


# 2928 20-Sep-1994 phk

fix ln to accept -f again. Thanks Bruce. Seems that Joe Grosch isn't
quite as safe as I thought. I will have to look much closer on his
patches. Damn.


# 2924 20-Sep-1994 phk

/home/phk/jg


# 1557 26-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1556,
which included commits to RCS files with non-trunk default branches.


# 1556 26-May-1994 rgrimes

BSD 4.4 Lite bin Sources