1276630Skib/* 2276630Skib * Copyright (c) 2014 The FreeBSD Foundation. 3276630Skib * All rights reserved. 4276630Skib * 5276630Skib * Portions of this software were developed by Konstantin Belousov 6276630Skib * under sponsorship from the FreeBSD Foundation. 7276630Skib * 8276630Skib * Redistribution and use in source and binary forms, with or without 9276630Skib * modification, are permitted provided that the following conditions 10276630Skib * are met: 11276630Skib * 1. Redistributions of source code must retain the above copyright 12276630Skib * notice(s), this list of conditions and the following disclaimer as 13276630Skib * the first lines of this file unmodified other than the possible 14276630Skib * addition of one or more copyright notices. 15276630Skib * 2. Redistributions in binary form must reproduce the above copyright 16276630Skib * notice(s), this list of conditions and the following disclaimer in 17276630Skib * the documentation and/or other materials provided with the 18276630Skib * distribution. 19276630Skib * 20276630Skib * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY 21276630Skib * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22276630Skib * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23276630Skib * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE 24276630Skib * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25276630Skib * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26276630Skib * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27276630Skib * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28276630Skib * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 29276630Skib * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30276630Skib * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31276630Skib */ 32276630Skib 33276630Skib#include <sys/cdefs.h> 34276630Skib__FBSDID("$FreeBSD$"); 35276630Skib 36276630Skib#include <sys/types.h> 37276630Skib#include <sys/fcntl.h> 38276630Skib#include <stdarg.h> 39276630Skib#include "libc_private.h" 40276630Skib 41276630Skib__weak_reference(__sys_openat, __openat); 42276630Skib__sym_compat(openat, __impl_openat, FBSD_1.1); 43276630Skib__weak_reference(openat, __impl_openat); 44276630Skib__sym_default(openat, openat, FBSD_1.2); 45276630Skib 46276630Skib#pragma weak openat 47276630Skibint 48276630Skibopenat(int fd, const char *path, int flags, ...) 49276630Skib{ 50276630Skib va_list ap; 51276630Skib int mode; 52276630Skib 53276630Skib if ((flags & O_CREAT) != 0) { 54276630Skib va_start(ap, flags); 55276630Skib mode = va_arg(ap, int); 56276630Skib va_end(ap); 57276630Skib } else { 58276630Skib mode = 0; 59276630Skib } 60276630Skib return (((int (*)(int, const char *, int, ...)) 61276630Skib __libc_interposing[INTERPOS_openat])(fd, path, flags, mode)); 62276630Skib} 63