thr_creat.c revision 174112
168349Sobrien/* 268349Sobrien * Copyright (C) 2000 Jason Evans <jasone@freebsd.org>. 368349Sobrien * All rights reserved. 468349Sobrien * 568349Sobrien * Redistribution and use in source and binary forms, with or without 668349Sobrien * modification, are permitted provided that the following conditions 768349Sobrien * are met: 868349Sobrien * 1. Redistributions of source code must retain the above copyright 968349Sobrien * notice(s), this list of conditions and the following disclaimer as 1068349Sobrien * the first lines of this file unmodified other than the possible 1168349Sobrien * addition of one or more copyright notices. 1268349Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1368349Sobrien * notice(s), this list of conditions and the following disclaimer in 1468349Sobrien * the documentation and/or other materials provided with the 1568349Sobrien * distribution. 1668349Sobrien * 1768349Sobrien * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY 1868349Sobrien * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1968349Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2068349Sobrien * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE 2168349Sobrien * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2268349Sobrien * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2368349Sobrien * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 2468349Sobrien * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 2568349Sobrien * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 2668349Sobrien * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 2768349Sobrien * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2868349Sobrien * 2968349Sobrien * $FreeBSD: head/lib/libkse/thread/thr_creat.c 174112 2007-11-30 17:20:29Z deischen $ 3068349Sobrien */ 3168349Sobrien 3268349Sobrien#include "namespace.h" 3368349Sobrien#include <fcntl.h> 3468349Sobrien#include <pthread.h> 3568349Sobrien#include "un-namespace.h" 3668349Sobrien#include "thr_private.h" 3768349Sobrien 3868349SobrienLT10_COMPAT_PRIVATE(___creat); 3968349SobrienLT10_COMPAT_DEFAULT(creat); 4068349Sobrien 4168349Sobrienextern int __creat(const char *, mode_t); 4268349Sobrien 4368349Sobrienint ___creat(const char *path, mode_t mode); 4468349Sobrien 4568349Sobrien__weak_reference(___creat, creat); 4668349Sobrien 4768349Sobrienint 4868349Sobrien___creat(const char *path, mode_t mode) 4968349Sobrien{ 5068349Sobrien struct pthread *curthread = _get_curthread(); 5168349Sobrien int ret; 5268349Sobrien 5368349Sobrien _thr_cancel_enter(curthread); 5468349Sobrien ret = __creat(path, mode); 5568349Sobrien /* 5668349Sobrien * To avoid possible file handle leak, 5768349Sobrien * only check cancellation point if it is failure 5868349Sobrien */ 5968349Sobrien _thr_cancel_leave(curthread, (ret == -1)); 6068349Sobrien 6168349Sobrien return ret; 6268349Sobrien} 6368349Sobrien