diff --git a/libc/Makefile b/libc/Makefile index 6a806969..85eaf411 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -125,6 +125,7 @@ close.o \ $(CPUDIR)/fork.o \ $(CPUDIR)/signal.o \ $(CPUDIR)/syscall.o \ +creat.o \ dispmsg_issue.o \ dlfcn.o \ dup2.o \ diff --git a/libc/creat.cpp b/libc/creat.cpp new file mode 100644 index 00000000..ea1e9743 --- /dev/null +++ b/libc/creat.cpp @@ -0,0 +1,30 @@ +/******************************************************************************* + + Copyright(C) Jonas 'Sortie' Termansen 2013. + + This file is part of the Sortix C Library. + + The Sortix C Library is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + The Sortix C Library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with the Sortix C Library. If not, see . + + creat.cpp + Create a file. + +*******************************************************************************/ + +#include + +extern "C" int creat(const char* path, mode_t mode) +{ + return open(path, O_WRONLY | O_CREAT | O_TRUNC, mode); +} diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h index f621c4e1..1b8aad72 100644 --- a/libc/include/fcntl.h +++ b/libc/include/fcntl.h @@ -53,12 +53,10 @@ struct flock pid_t l_pid; /* Process ID of the process holding the lock; returned with F_GETLK. */ }; +int creat(const char* path, mode_t mode); int fcntl(int fd, int cmd, ...); int open(const char* path, int oflag, ...); int openat(int fd, const char* path, int oflag, ...); -#if defined(__SORTIX_SHOW_UNIMPLEMENTED) -int creat(const char* path, mode_t mode); -#endif __END_DECLS