1 /* @(#)renameat.c 1.3 19/07/31 Copyright 2011-2019 J. Schilling */ 2 /* 3 * Emulate the behavior of renameat(int fd1, const char *name1, 4 * int fd2, const char *name2) 5 * 6 * Note that emulation methods that do not use the /proc filesystem are 7 * not MT safe. In the non-MT-safe case, we do: 8 * 9 * savewd()/fchdir()/open(name)/restorewd() 10 * 11 * Errors may force us to abort the program as our caller is not expected 12 * to know that we do more than a simple open() here and that the 13 * working directory may be changed by us. 14 * 15 * Copyright (c) 2011-2019 J. Schilling 16 */ 17 /* 18 * The contents of this file are subject to the terms of the 19 * Common Development and Distribution License, Version 1.0 only 20 * (the "License"). You may not use this file except in compliance 21 * with the License. 22 * 23 * See the file CDDL.Schily.txt in this distribution for details. 24 * A copy of the CDDL is also available via the Internet at 25 * http://www.opensource.org/licenses/cddl1.txt 26 * 27 * When distributing Covered Code, include this CDDL HEADER in each 28 * file and include the License file CDDL.Schily.txt from this distribution. 29 */ 30 31 /* 32 * Since we need to call fstat() and since this is not a predictable call, 33 * we always compile this module in largefile mode. 34 */ 35 #define USE_LARGEFILES 36 37 #include <schily/stdio.h> /* POSIX requires stdio.h for rename */ 38 #include <schily/unistd.h> 39 #include <schily/types.h> 40 #include <schily/fcntl.h> 41 #include <schily/maxpath.h> 42 #include <schily/errno.h> 43 #include <schily/standard.h> 44 #include <schily/schily.h> 45 #include "at-defs.h" 46 47 #ifndef HAVE_RENAMEAT 48 49 #define KR_DECL 50 #define KR_ARGS 51 #define FUNC_CALL(n1, n2) rename(n2, n2) 52 #define FLAG_CHECK() 53 #define FUNC_NAME renameat 54 #define FUNC_RESULT int 55 56 #include "at-base2.c" 57 58 #endif /* HAVE_RENAMEAT */ 59