Commit Graph

85 Commits

Author SHA1 Message Date
Ed Schouten
f9d4afb439 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.
2011-10-31 08:59:17 +00:00
Jilles Tjoelker
0cf90cd1d3 bin: Prefer strrchr() to rindex().
This removes the last index/rindex usage from /bin.
2011-03-15 22:22:11 +00:00
Joel Dahl
a53bb70bda Spelling fixes. 2010-07-31 21:09:49 +00:00
Jilles Tjoelker
141c21d9de symlink(7): Add lpathconf(2) and *at system calls.
MFC after:	1 week
2010-04-25 13:29:59 +00:00
Jilles Tjoelker
44f78be924 symlink(7): The ownership of symlinks is used by the system,
in at least three ways, so do not say it is ignored:
* who may delete/rename a symlink in a sticky directory
* who may do lchflags(2)/lchown(2)/lchmod(2)
* whose inode quota is charged

MFC after:	1 week
2010-04-25 13:13:23 +00:00
Jilles Tjoelker
dc00aa5dd6 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
2010-04-21 21:57:03 +00:00
Jilles Tjoelker
5d66b54e27 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
2010-04-17 22:39:53 +00:00
Jilles Tjoelker
80a0e9b5f5 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)
2009-07-19 17:35:23 +00:00
Tom Rhodes
8b9e2a36cc Clean up a bit of confusing language and improve .Nd.
PR:		47818
Reviewed by:	keramida
2009-01-13 15:24:35 +00:00
Giorgos Keramidas
d605a06c6e 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
2008-06-07 09:37:30 +00:00
Giorgos Keramidas
3595f21aae 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
2008-06-06 08:27:59 +00:00
Ruslan Ermilov
8090694427 Express in the usage() and SYNOPSIS that -F depends on -s, and
that -f and -i are exclusive.
2007-11-17 21:01:22 +00:00
Ruslan Ermilov
cadf8ad71c Swap "source"/"target" where appropriate, to match documentation. 2007-11-17 20:24:58 +00:00
Gleb Smirnoff
5e09de40c3 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>
2006-02-14 11:08:05 +00:00
Ruslan Ermilov
0227791b40 Expand *n't contractions. 2005-02-13 22:25:33 +00:00
Ruslan Ermilov
a89237ae95 Sync program's usage() with manpage's SYNOPSIS. 2005-02-09 17:37:39 +00:00
Ruslan Ermilov
6fca4c7c3f Add the new standard EXIT STATUS section where appropriate.
Sort standard sections in the (documented) preferred order.
2005-01-16 16:41:59 +00:00
Warner Losh
9ddb49cbe4 /*- or .\"- or #- to begin license clauses. 2005-01-10 08:39:26 +00:00
Ruslan Ermilov
1171aedcdf Deal with double whitespace. 2004-07-03 00:06:28 +00:00
Ruslan Ermilov
eccea571a7 Mechanically kill hard sentence breaks. 2004-07-02 21:04:19 +00:00
Ruslan Ermilov
d37ea99837 Removed trailing whitespace. 2004-07-02 19:07:33 +00:00
Mark Murray
6195fb4102 Remove clause 3 from the UCB licenses.
OK'ed by:	imp, core
2004-04-06 20:06:54 +00:00
David E. O'Brien
09a80d4867 Quiet warnings about copyright[]. 2003-05-01 16:58:57 +00:00
Tom Rhodes
7d971bbf29 s/filesystem/file system/ as discussed on -developers 2002-08-21 17:32:44 +00:00
Tim J. Robbins
ad2eaa7e87 Claim conformance to 1003.2-1992 instead of 1003.1-2001 due to doubts
raised by Lukas Ertl over symbolic link handling.

PR:		41576
MFC after:	1 week
2002-08-12 12:34:03 +00:00
Mark Murray
f193e3fc68 Fix an easy WARNS. 2002-07-31 16:53:59 +00:00
David E. O'Brien
5eb43ac2f7 Consistently use __FBSDID 2002-06-30 05:13:54 +00:00
Tim J. Robbins
a24ce1c859 Check that snprintf() does not truncate the destination pathname when
linking into a directory.
2002-06-29 04:10:40 +00:00
Tim J. Robbins
bdb9494ae8 ln(1)'s symbolic link handling conforms to IEEE Std. 1003.1-2001, note
this in the Standards section.
2002-06-25 10:02:12 +00:00
Tim J. Robbins
9c24ed854c Correctly mark up the final command line arguments with the Ar macro for
the last two synopsis forms.
2002-06-25 09:58:29 +00:00
Tim J. Robbins
dab94652b1 Reject options, handle "--" end-of-options marker in link(1). 2002-05-30 00:57:38 +00:00
Ruslan Ermilov
3ed30dee85 mdoc(7) police: punctuation. 2002-05-29 15:06:24 +00:00
Tim J. Robbins
45457c7dd2 Note that the lutimes(2) and lchflags(2) syscalls also do not follow symlinks.
Remove incorrect examples.

PR:		25016
Submitted by:	Martin Kammerhofer, Joshua Goodall
2002-05-26 12:51:38 +00:00
Tim J. Robbins
f59d6e4762 Add lchmod(2) to the list of syscalls that do not follow symbolic links. 2002-05-26 12:12:36 +00:00
Tom Rhodes
ebd4324457 Consistancy check s/file system/filesystem/
Reviewed by:	brian
2002-05-16 01:57:20 +00:00
Chris D. Faulhaber
75a011263c Add semicolon to empty default case to silence warning. 2002-05-11 00:45:01 +00:00
Mark Murray
4b4ed2fe6a Fix warnings inspired by lint, a commercial lint and WARNS=4. 2002-02-22 21:11:03 +00:00
Warner Losh
46251dde8f 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.
2002-02-02 06:48:10 +00:00
David E. O'Brien
a748290789 Default to WARNS=2. Binary builds that cannot handle this must explicitly
set WARNS=0.

Reviewed by:	mike
2001-12-04 01:57:47 +00:00
Ruslan Ermilov
753d686d34 mdoc(7) police: s/BSD/.Bx/ where appropriate. 2001-08-14 10:01:54 +00:00
Dima Dorfman
7ebcc426ef Remove whitespace at EOL. 2001-07-15 07:53:42 +00:00
Ruslan Ermilov
caa2db3be9 mdoc(7) police: removed HISTORY info from the .Os call. 2001-07-10 10:04:09 +00:00
Dima Dorfman
982f5d88ff WARNS= -> WARNS?=
Submitted by:	Mike Barcroft <mike@q9media.com>
2001-06-22 21:38:30 +00:00
Warner Losh
c215688fd2 Use PATH_MAX in preference to MAXPATHLEN.
Also sort declarations per style(9) (big arrays come last) while I'm
in the area.
2001-05-29 17:27:56 +00:00
Kris Kennaway
97dbc8f347 Silence WARNS=2 and BDECFLAGS on i386 and alpha
MFC After:	1 week
2001-05-20 04:54:15 +00:00
Ruslan Ermilov
41f6d28423 Fixed a typo. 2001-04-27 08:12:45 +00:00
Maxim Sobolev
1d7f44ef26 Put a note that -h' and -n' is non-standard and provided only for
compatibility purposes.

Prompted by:	ru
2001-04-27 08:00:19 +00:00
Maxim Sobolev
c9e7c66776 Bring in -h' compatability option and its alias -n' to match NetBSD and GNU
semantics.

style(9) Reviewed by:
Obtained from:	NetBSD
2001-04-26 17:15:57 +00:00
Ruslan Ermilov
6c7d684cfe MAN[1-9] -> MAN. 2001-03-27 10:03:10 +00:00
John Polstra
1718c8b735 Note that rmdir(2) does not follow symbolic links. 2001-01-24 23:49:59 +00:00