diff --git a/newlib/libc/sys/vita/Makefile.am b/newlib/libc/sys/vita/Makefile.am index ccb344f00..afa8f316d 100755 --- a/newlib/libc/sys/vita/Makefile.am +++ b/newlib/libc/sys/vita/Makefile.am @@ -14,7 +14,7 @@ DIRENT_OBJS = closedir.o opendir.o readdir.o readdir_r.o rewinddir.o seekdir.o t NET_SOURCES = net/gethostbyaddr.c net/gethostbyname.c net/getaddrinfo.c net/freeaddrinfo.c net/getservbyname.c net/inet_ntop.c net/inet_ntoa.c net/inet_netof.c net/inet_pton.c net/inet_lnaof.c net/inet_addr.c net/inet_network.c net/inet_net_ntop.c net/inet_aton.c net/inet_net_pton.c net/inet_makeaddr.c STUB_SOURCES = chroot.c getentropy.c groups.c -lib_a_SOURCES = syscalls.c access.c sbrk.c threading.c mlock.c io.c socket.c dup.c select.c error.c dirent.c lcltime_r.c sleep.c usleep.c truncate.c ${STUB_SOURCES} ${NET_SOURCES} +lib_a_SOURCES = syscalls.c access.c sbrk.c threading.c mlock.c io.c socket.c dup.c select.c error.c dirent.c lcltime_r.c sleep.c usleep.c truncate.c fs.c ${STUB_SOURCES} ${NET_SOURCES} lib_a_LIBADD = ${SOCKET_OBJS} ${NET_OBJS} ${DIRENT_OBJS} lib_a_CCASFLAGS = $(AM_CCASFLAGS) lib_a_CFLAGS = $(AM_CFLAGS) diff --git a/newlib/libc/sys/vita/Makefile.in b/newlib/libc/sys/vita/Makefile.in index 8fea09d23..aaebe23f3 100644 --- a/newlib/libc/sys/vita/Makefile.in +++ b/newlib/libc/sys/vita/Makefile.in @@ -87,7 +87,8 @@ am_lib_a_OBJECTS = lib_a-syscalls.$(OBJEXT) lib_a-access.$(OBJEXT) \ lib_a-select.$(OBJEXT) lib_a-error.$(OBJEXT) \ lib_a-dirent.$(OBJEXT) lib_a-lcltime_r.$(OBJEXT) \ lib_a-sleep.$(OBJEXT) lib_a-usleep.$(OBJEXT) \ - lib_a-truncate.$(OBJEXT) $(am__objects_1) $(am__objects_2) + lib_a-truncate.$(OBJEXT) lib_a-fs.$(OBJEXT) $(am__objects_1) \ + $(am__objects_2) lib_a_OBJECTS = $(am_lib_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = @@ -218,7 +219,7 @@ NET_OBJS = gethostbyaddr.o gethostbyname.o getaddrinfo.o freeaddrinfo.o getservb DIRENT_OBJS = closedir.o opendir.o readdir.o readdir_r.o rewinddir.o seekdir.o telldir.o NET_SOURCES = net/gethostbyaddr.c net/gethostbyname.c net/getaddrinfo.c net/freeaddrinfo.c net/getservbyname.c net/inet_ntop.c net/inet_ntoa.c net/inet_netof.c net/inet_pton.c net/inet_lnaof.c net/inet_addr.c net/inet_network.c net/inet_net_ntop.c net/inet_aton.c net/inet_net_pton.c net/inet_makeaddr.c STUB_SOURCES = chroot.c getentropy.c groups.c -lib_a_SOURCES = syscalls.c access.c sbrk.c threading.c mlock.c io.c socket.c dup.c select.c error.c dirent.c lcltime_r.c sleep.c usleep.c truncate.c ${STUB_SOURCES} ${NET_SOURCES} +lib_a_SOURCES = syscalls.c access.c sbrk.c threading.c mlock.c io.c socket.c dup.c select.c error.c dirent.c lcltime_r.c sleep.c usleep.c truncate.c fs.c ${STUB_SOURCES} ${NET_SOURCES} lib_a_LIBADD = ${SOCKET_OBJS} ${NET_OBJS} ${DIRENT_OBJS} lib_a_CCASFLAGS = $(AM_CCASFLAGS) lib_a_CFLAGS = $(AM_CFLAGS) @@ -372,6 +373,12 @@ lib_a-truncate.o: truncate.c lib_a-truncate.obj: truncate.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-truncate.obj `if test -f 'truncate.c'; then $(CYGPATH_W) 'truncate.c'; else $(CYGPATH_W) '$(srcdir)/truncate.c'; fi` +lib_a-fs.o: fs.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fs.o `test -f 'fs.c' || echo '$(srcdir)/'`fs.c + +lib_a-fs.obj: fs.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fs.obj `if test -f 'fs.c'; then $(CYGPATH_W) 'fs.c'; else $(CYGPATH_W) '$(srcdir)/fs.c'; fi` + lib_a-chroot.o: chroot.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-chroot.o `test -f 'chroot.c' || echo '$(srcdir)/'`chroot.c diff --git a/newlib/libc/sys/vita/fs.c b/newlib/libc/sys/vita/fs.c new file mode 100644 index 000000000..02be3aa01 --- /dev/null +++ b/newlib/libc/sys/vita/fs.c @@ -0,0 +1,52 @@ +/* + +Copyright (C) 2021, vitasdk + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +*/ + +#include + +#include +#include +#include +#include +#include + +#include +#include + +#define SCE_ERRNO_MASK 0xFF + +int mkdir(const char *pathname, mode_t mode) +{ + return _mkdir_r(_REENT, pathname, mode); +} + +int rmdir(const char *pathname) +{ + int ret; + if ((ret = sceIoRmdir(pathname)) < 0) { + errno = ret & SCE_ERRNO_MASK; + return -1; + } + errno = 0; + return 0; +}