xref: /titanic_52/usr/src/lib/libbc/libc/sys/4.2/rename.c (revision 0eb822a1c0c2bea495647510b75f77f0e57633eb)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1999 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include "chkpath.h"
30 #include <syscall.h>
31 
32 int rename(path1, path2)
33 char *path1, *path2;
34 {
35 	int ret;
36 	char buf1[256];
37 	char buf2[256];
38 
39 	CHKNULL(path1);
40 	CHKNULL(path2);
41 
42 	/*
43 	 * with the removal of utmp and wtmp, we now need
44 	 * to map the utmp or wtmp rename operation into
45 	 * a rename of utmpx or wtmpx
46 	 */
47 	if (strcmp(path1, "/var/adm/utmp") == 0 ||
48 		strcmp(path1, "/var/adm/wtmp") == 0 ||
49 		strcmp(path1, "/etc/utmp") == 0) {
50 		if (strcmp(path1, "/etc/utmp") == 0 ||
51 		    strcmp(path1,"/var/adm/utmp") == 0)
52 			strcpy(buf1, "/var/adm/utmpx");
53 		else
54 			strcpy(buf1, "/var/adm/wtmpx");
55 		strcpy(buf2, path2);
56 		strcat(buf2, "x");
57 		ret = _syscall(SYS_rename, buf1, buf2);
58 	} else
59 		ret = _syscall(SYS_rename, path1, path2);
60 
61 	return(ret);
62 }
63