Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 May 2004 10:48:42 +0930
From:      Greg 'groggy' Lehey <grog@FreeBSD.org>
To:        Bill Moran <wmoran@potentialtech.com>
Cc:        FreeBSD-Questions <FreeBSD-Questions@FreeBSD.org>
Subject:   Re: Source code of ln command
Message-ID:  <20040507011842.GM91741@wantadilla.lemis.com>
In-Reply-To: <4098E7C3.10205@potentialtech.com>
References:  <000d01c43200$5f5d37f0$3802a8c0@FCNI.COM> <4098E7C3.10205@potentialtech.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--zROEGoKAXsG5UqGB
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Wednesday,  5 May 2004 at  9:10:27 -0400, Bill Moran wrote:
> Thuan Truong wrote:
>>
>> I would like to have the source code of 'ln' (make hard or symbolic
>> links to files) command from Free-BSD ftp site.  Please let me know
>> how and where to unload it.
>
> If you installed source on your FreeBSD system, it's in /usr/src/bin/ln
>
> Otherwise, you can download any version you want from cvs:
> http://www.freebsd.org/cgi/cvsweb.cgi/src/bin/ln/

Note that ln(1) is a relatively simple interface to link(2), which is
in the kernel.  Here's the complete source of the version supplied
with the Sixth Edition of UNIX:

main(argc, argv)
char **argv;
{
	static struct ibuf statb;
	register char *np;

	if (argc<2) {
		write(1, "Usage: ln target [ newname ]\n", 29);
		exit(1);
	}
	if (argc==2) {
		np = argv[1];
		while(*np++);
		while (*--np!='/' && np>argv[1]);
		np++;
		argv[2] = np;
	}
	stat(argv[1], &statb);
	if ((statb.iflags&FMT) == DIR) {
		write(1, "No directory link\n", 18);
		exit(1);
	}
	if (link(argv[1], argv[2])<0) {
		write(1, "Can't link\n", 11);
		exit(1);
	}
	exit(0);
}

Greg
--
Note: I discard all HTML mail unseen.
Finger grog@FreeBSD.org for PGP public key.
See complete headers for address and phone numbers.

--zROEGoKAXsG5UqGB
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (FreeBSD)

iD8DBQFAmuPyIubykFB6QiMRAn/zAJwPrLU070D0oIfAzXRTplbdmNa2JwCgluSP
lxNTxmFoqdCR8/wlxcUTmLc=
=71DP
-----END PGP SIGNATURE-----

--zROEGoKAXsG5UqGB--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040507011842.GM91741>