1 /*- 2 * Copyright (c) 1980 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.proprietary.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)link_.c 5.2 (Berkeley) 04/12/91"; 10 #endif /* not lint */ 11 12 /* 13 * make a link to an existing file 14 * 15 * calling sequence: 16 * ierror = link(name1, name2) 17 * where: 18 * name1 is the pathname of an existing file 19 * name2 is a pathname to be linked to file name1 20 * ierror will be 0 if successful; a system error code otherwise. 21 */ 22 23 #include "../libI77/f_errno.h" 24 #include <sys/param.h> 25 #ifndef MAXPATHLEN 26 #define MAXPATHLEN 128 27 #endif 28 29 long link_(name1, name2, n1len, n2len) 30 char *name1, *name2; 31 long n1len, n2len; 32 { 33 char buf1[MAXPATHLEN]; 34 char buf2[MAXPATHLEN]; 35 36 if (n1len >= sizeof buf1 || n2len >= sizeof buf2) 37 return((long)(errno=F_ERARG)); 38 g_char(name1, n1len, buf1); 39 g_char(name2, n2len, buf2); 40 if (buf1[0] == '\0' || buf2[0] == '\0') 41 return((long)(errno=F_ERARG)); 42 if (link(buf1, buf2) != 0) 43 return((long)errno); 44 return(0L); 45 } 46