Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ee/libcglue/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ GLUE_OBJS = \
lstat.o \
_fstat.o \
access.o \
_ioctl.o \
_fcntl.o \
getdents.o \
_lseek.o \
Expand Down
21 changes: 21 additions & 0 deletions ee/libcglue/src/glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,27 @@ int _fcntl(int fd, int cmd, ...)
}
#endif /* F__fcntl */

#ifdef F__ioctl
// This is actually not called from newlib, but the _ioctl symbol is checked by
// ps2sdkapi.c and fileXio_ps2sdkapi.c. Perhaps it was later renamed to _ps2sdk_ioctl?
// For consistency, _ioctl is implemented as an errno alternative to _ps2sdk_ioctl.
int _ioctl(int fd, int request, void *data) {
_libcglue_fdman_fd_info_t *fdinfo;
fdinfo = libcglue_get_fd_info(fd);
if (fdinfo == NULL)
{
errno = EBADF;
return -1;
}
if (fdinfo->ops == NULL || fdinfo->ops->ioctl == NULL)
{
errno = ENOSYS;
return -1;
}
return __transform_errno(fdinfo->ops->ioctl(fdinfo->userdata, request, data));
}
#endif /* F__ioctl */

#ifdef F_getdents
// Called from newlib readdir.c, readdir_r.c
int getdents(int fd, void *dd_buf, int count)
Expand Down
3 changes: 2 additions & 1 deletion ee/libcglue/src/ps2sdkapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ int __attribute__((weak)) _read(int fd, void *buf, size_t nbytes);
off_t __attribute__((weak)) _lseek(int fd, off_t offset, int whence);
int __attribute__((weak)) _write(int fd, const void *buf, size_t nbytes);
int __attribute__((weak)) _ioctl(int fd, int request, void *data);
int __attribute__((weak)) _ps2sdk_ioctl(int fd, int request, void *data);
int __attribute__((weak)) getdents(int fd, void *dd_buf, int count);

void __fioOpsInitializeImpl(void)
Expand Down Expand Up @@ -486,7 +487,7 @@ void __fioOpsInitializeImpl(void)
// cppcheck-suppress knownConditionTrueFalse
if (&_write) __fio_fdman_ops_file.write = __fioWriteHelper;
// cppcheck-suppress knownConditionTrueFalse
if (&_ioctl) __fio_fdman_ops_file.ioctl = __fioIoctlHelper;
if ((&_ioctl) || (&_ps2sdk_ioctl)) __fio_fdman_ops_file.ioctl = __fioIoctlHelper;

memset(&__fio_fdman_ops_dir, 0, sizeof(__fio_fdman_ops_dir));
__fio_fdman_ops_dir.getfd = __fioGetFdHelper;
Expand Down
3 changes: 2 additions & 1 deletion ee/rpc/filexio/src/fileXio_ps2sdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ off_t __attribute__((weak)) _lseek(int fd, off_t offset, int whence);
off64_t __attribute__((weak)) lseek64(int fd, off64_t offset, int whence);
int __attribute__((weak)) _write(int fd, const void *buf, size_t nbytes);
int __attribute__((weak)) _ioctl(int fd, int request, void *data);
int __attribute__((weak)) _ps2sdk_ioctl(int fd, int request, void *data);
int __attribute__((weak)) getdents(int fd, void *dd_buf, int count);

extern void __fileXioOpsInitializeImpl(void)
Expand Down Expand Up @@ -503,7 +504,7 @@ extern void __fileXioOpsInitializeImpl(void)
// cppcheck-suppress knownConditionTrueFalse
if (&_write) __fileXio_fdman_ops_file.write = __fileXioWriteHelper;
// cppcheck-suppress knownConditionTrueFalse
if (&_ioctl) __fileXio_fdman_ops_file.ioctl = __fileXioIoctlHelper;
if ((&_ioctl) || (&_ps2sdk_ioctl)) __fileXio_fdman_ops_file.ioctl = __fileXioIoctlHelper;
__fileXio_fdman_ops_file.ioctl2 = __fileXioIoctl2Helper;

memset(&__fileXio_fdman_ops_dir, 0, sizeof(__fileXio_fdman_ops_dir));
Expand Down
Loading