1*47944Sbostic /*-
2*47944Sbostic * Copyright (c) 1980 The Regents of the University of California.
3*47944Sbostic * All rights reserved.
42532Sdlw *
5*47944Sbostic * %sccs.include.proprietary.c%
623035Skre */
723035Skre
8*47944Sbostic #ifndef lint
9*47944Sbostic static char sccsid[] = "@(#)link_.c 5.2 (Berkeley) 04/12/91";
10*47944Sbostic #endif /* not lint */
11*47944Sbostic
1223035Skre /*
132532Sdlw * make a link to an existing file
142532Sdlw *
152532Sdlw * calling sequence:
162532Sdlw * ierror = link(name1, name2)
172532Sdlw * where:
182532Sdlw * name1 is the pathname of an existing file
192532Sdlw * name2 is a pathname to be linked to file name1
202532Sdlw * ierror will be 0 if successful; a system error code otherwise.
212532Sdlw */
222532Sdlw
232532Sdlw #include "../libI77/f_errno.h"
2412144Sdlw #include <sys/param.h>
2512144Sdlw #ifndef MAXPATHLEN
2612144Sdlw #define MAXPATHLEN 128
2712144Sdlw #endif
282532Sdlw
link_(name1,name2,n1len,n2len)292532Sdlw long link_(name1, name2, n1len, n2len)
302532Sdlw char *name1, *name2;
312532Sdlw long n1len, n2len;
322532Sdlw {
3312144Sdlw char buf1[MAXPATHLEN];
3412144Sdlw char buf2[MAXPATHLEN];
352532Sdlw
362532Sdlw if (n1len >= sizeof buf1 || n2len >= sizeof buf2)
372532Sdlw return((long)(errno=F_ERARG));
382532Sdlw g_char(name1, n1len, buf1);
392532Sdlw g_char(name2, n2len, buf2);
4012144Sdlw if (buf1[0] == '\0' || buf2[0] == '\0')
412532Sdlw return((long)(errno=F_ERARG));
422532Sdlw if (link(buf1, buf2) != 0)
432532Sdlw return((long)errno);
442532Sdlw return(0L);
452532Sdlw }
46