From owner-freebsd-questions@FreeBSD.ORG Thu May 6 18:18:49 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AD2FF16A4CE for ; Thu, 6 May 2004 18:18:49 -0700 (PDT) Received: from ozlabs.org (ozlabs.org [203.10.76.45]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1B4B043D41 for ; Thu, 6 May 2004 18:18:47 -0700 (PDT) (envelope-from grog@lemis.com) Received: from blackwater.lemis.com (blackwater.lemis.com [192.109.197.80]) by ozlabs.org (Postfix) with ESMTP id 077852BD71 for ; Fri, 7 May 2004 11:18:45 +1000 (EST) Received: by blackwater.lemis.com (Postfix, from userid 1004) id 0416951204; Fri, 7 May 2004 10:48:43 +0930 (CST) Date: Fri, 7 May 2004 10:48:42 +0930 From: Greg 'groggy' Lehey To: Bill Moran Message-ID: <20040507011842.GM91741@wantadilla.lemis.com> References: <000d01c43200$5f5d37f0$3802a8c0@FCNI.COM> <4098E7C3.10205@potentialtech.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="zROEGoKAXsG5UqGB" Content-Disposition: inline In-Reply-To: <4098E7C3.10205@potentialtech.com> User-Agent: Mutt/1.4.1i Organization: The FreeBSD Project Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-418-838-708 WWW-Home-Page: http://www.FreeBSD.org/ X-PGP-Fingerprint: 9A1B 8202 BCCE B846 F92F 09AC 22E6 F290 507A 4223 cc: Thuan Truong cc: FreeBSD-Questions Subject: Re: Source code of ln command X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 May 2004 01:18:49 -0000 --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--