implement ioctl for non-RHO FDs. For jxcore network stack.
@@ -166,6 +166,7 @@ typedef int (*func_readlink_t)(const char *path, char *buf, size_t bufsize);
typedef int (*func_mkdir_t)(const char *path, mode_t mode);
typedef int (*func_fchdir_t)(int fd);
typedef int (*func_fcntl_t)(int fd, int command, ...);
+typedef int (*func_ioctl_t)(int fd, int command, ...);
typedef int (*func_fdatasync_t)(int fd);
typedef int (*func_flock_t)(int fd, int operation);
typedef int (*func_fstat_t)(int filedes, struct stat *buf);
@@ -206,6 +207,7 @@ static func_readlink_t real_readlink;
static func_mkdir_t real_mkdir;
static func_fchdir_t real_fchdir;
static func_fcntl_t real_fcntl;
+static func_ioctl_t real_ioctl;
static func_fdatasync_t real_fdatasync;
static func_flock_t real_flock;
static func_fstat_t real_fstat;
@@ -531,6 +533,7 @@ RHO_GLOBAL void JNICALL Java_com_rhomobile_rhodes_file_RhoFileApi_nativeInit
real_mkdir = (func_mkdir_t)dlsym(pc, "mkdir");
real_fchdir = (func_fchdir_t)dlsym(pc, "fchdir");
real_fcntl = (func_fcntl_t)dlsym(pc, "fcntl");
+ real_ioctl = (func_ioctl_t)dlsym(pc, "ioctl");
real_fsync = (func_fsync_t)dlsym(pc, "fsync");
real_fdatasync = (func_fdatasync_t)dlsym(pc, "fdatasync");
@@ -1335,11 +1338,22 @@ RHO_GLOBAL int flock(int fd, int operation)
RHO_NOT_IMPLEMENTED;
}
-RHO_GLOBAL int ioctl(int, int, ...)
+RHO_GLOBAL int ioctl(int fd, int command, ...)
{
+ RHO_LOG("ioctl: fd %d, command: %d", fd, command);
+ if ((rho_fs_mode == RHO_FS_DISK_ONLY || fd < RHO_FD_BASE) && (real_ioctl!=0) )
+ {
+ va_list vl;
+ va_start(vl, command);
+ int arg = va_arg(vl, int);
+ va_end(vl);
+ return real_ioctl(fd, command, arg);
+ }
+
RHO_NOT_IMPLEMENTED;
}
+
RHO_GLOBAL int fsync(int fd)
{
if (rho_fs_mode == RHO_FS_DISK_ONLY || fd < RHO_FD_BASE)
