Skip to content

Commit

Permalink
add: expose ioctl2 in fdmap
Browse files Browse the repository at this point in the history
  • Loading branch information
uyjulian committed Jan 18, 2024
1 parent 1cb255c commit f794bf1
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions ee/libcglue/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ GLUE_OBJS = \
_ps2sdk_lseek64.o \
_ps2sdk_write.o \
_ps2sdk_ioctl.o \
_ps2sdk_ioctl2.o \
_ps2sdk_dread.o

LOCK_OBJS = __retarget_lock_init.o __retarget_lock_acquire.o __retarget_lock_release.o __retarget_lock_try_acquire.o __retarget_lock_close.o \
Expand Down
3 changes: 3 additions & 0 deletions ee/libcglue/include/ps2sdkapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ typedef int (*_libcglue_fdman_lseek_cb_t)(void *userdata, int offset, int whence
typedef int64_t (*_libcglue_fdman_lseek64_cb_t)(void *userdata, int64_t offset, int whence);
typedef int (*_libcglue_fdman_write_cb_t)(void *userdata, const void *buf, int nbytes);
typedef int (*_libcglue_fdman_ioctl_cb_t)(void *userdata, int request, void *data);
typedef int (*_libcglue_fdman_ioctl2_cb_t)(void *userdata, int request, void *arg, unsigned int arglen, void *buf, unsigned int buflen);
typedef int (*_libcglue_fdman_dread_cb_t)(void *userdata, struct dirent *dir);
typedef int (*_libcglue_fdman_fcntl_f_setfl_cb_t)(void *userdata, int newfl);
typedef int (*_libcglue_fdman_accept_cb_t)(void *userdata, struct _libcglue_fdman_fd_info_ *info, struct sockaddr *addr, socklen_t *addrlen);
Expand All @@ -56,6 +57,7 @@ typedef struct _libcglue_fdman_fd_ops_
_libcglue_fdman_lseek64_cb_t lseek64;
_libcglue_fdman_write_cb_t write;
_libcglue_fdman_ioctl_cb_t ioctl;
_libcglue_fdman_ioctl2_cb_t ioctl2;
_libcglue_fdman_dread_cb_t dread;
_libcglue_fdman_fcntl_f_setfl_cb_t fcntl_f_setfl;
_libcglue_fdman_accept_cb_t accept;
Expand Down Expand Up @@ -191,6 +193,7 @@ extern int _ps2sdk_lseek(int fd, int offset, int whence);
extern int64_t _ps2sdk_lseek64(int fd, int64_t offset, int whence);
extern int _ps2sdk_write(int fd, const void *buf, int nbytes);
extern int _ps2sdk_ioctl(int fd, int request, void *data);
extern int _ps2sdk_ioctl2(int fd, int request, void *arg, unsigned int arglen, void *buf, unsigned int buflen);
extern int _ps2sdk_dread(int fd, struct dirent *dir);

#endif /* __PS2SDKAPI_H__ */
17 changes: 17 additions & 0 deletions ee/libcglue/src/glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,23 @@ int _ps2sdk_ioctl(int fd, int request, void *data)
}
#endif

#ifdef F__ps2sdk_ioctl2
int _ps2sdk_ioctl2(int fd, int request, void *arg, unsigned int arglen, void *buf, unsigned int buflen)
{
_libcglue_fdman_fd_info_t *fdinfo;
fdinfo = libcglue_get_fd_info(fd);
if (fdinfo == NULL)
{
return -EBADF;
}
if (fdinfo->ops == NULL || fdinfo->ops->ioctl == NULL)
{
return -ENOSYS;
}
return fdinfo->ops->ioctl2(fdinfo->userdata, request, arg, arglen, buf, buflen);
}
#endif

#ifdef F__ps2sdk_dread
int _ps2sdk_dread(int fd, struct dirent *dir)
{
Expand Down
1 change: 1 addition & 0 deletions ee/rpc/filexio/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ FILEXIO_PS2SDK_OBJS = \
__fileXioLseek64Helper.o \
__fileXioWriteHelper.o \
__fileXioIoctlHelper.o \
__fileXioIoctl2Helper.o \
__fileXioDreadHelper.o \
__fileXioLseekDirHelper.o \
__fileXioOpsInitializeImpl.o \
Expand Down
20 changes: 20 additions & 0 deletions ee/rpc/filexio/src/fileXio_ps2sdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,25 @@ int __fileXioIoctlHelper(void *userdata, int request, void *data)
int __fileXioIoctlHelper(void *userdata, int request, void *data);
#endif

#ifdef F___fileXioIoctl2Helper
int __fileXioIoctl2Helper(void *userdata, int request, void *arg, unsigned int arglen, void *buf, unsigned int buflen)
{
int rv;
int fd;

fd = __fileXioGetFdHelper(userdata);
if (fd < 0)
{
return fd;
}

rv = fileXioIoctl2(fd, request, arg, arglen, buf, buflen);
return rv;
}
#else
int __fileXioIoctl2Helper(void *userdata, int request, void *arg, unsigned int arglen, void *buf, unsigned int buflen);
#endif

#ifdef F___fileXioDreadHelper
int __fileXioDreadHelper(void *userdata, struct dirent *dir)
{
Expand Down Expand Up @@ -486,6 +505,7 @@ extern void __fileXioOpsInitializeImpl(void)
if (&_write) __fileXio_fdman_ops_file.write = __fileXioWriteHelper;
// cppcheck-suppress knownConditionTrueFalse
if (&_ioctl) __fileXio_fdman_ops_file.ioctl = __fileXioIoctlHelper;
__fileXio_fdman_ops_file.ioctl2 = __fileXioIoctl2Helper;

memset(&__fileXio_fdman_ops_dir, 0, sizeof(__fileXio_fdman_ops_dir));
__fileXio_fdman_ops_dir.getfd = __fileXioGetFdHelper;
Expand Down

0 comments on commit f794bf1

Please sign in to comment.