static int uk_9pfs_ioctl(struct vnode *dvp, struct vfscore_file *fp,
unsigned long com, void *data)
{
- switch (com) {
/**
* HACK: In binary compatibility mode, Ruby tries to set O_ASYNC,
* which Unikraft does not yet support. If the `ioctl` call returns
* Setting `ioctl` to a nullop will not work, since it is used by
* interpreted languages (e.g. python3) to check if it should start
* the interpretor or just read a file.
+ *
+ * For every `ioctl` request related to a terminal, return ENOTTY.
*/
- case FIONBIO:
+ if (com == FIONBIO)
return 0;
- default:
- return ENOTSUP;
- }
+ if (IOCTL_CMD_ISTYPE(com, IOCTL_CMD_TYPE_TTY))
+ return ENOTTY;
+
+ return ENOTSUP;
}
#define uk_9pfs_seek ((vnop_seek_t)vfscore_vop_nullop)
#include <vfscore/uio.h>
#include <vfscore/dentry.h>
+#define IOCTL_CMD_TYPE_SHIFT (8)
+#define IOCTL_CMD_TYPE_MASK (0xFF << IOCTL_CMD_TYPE_SHIFT)
+#define IOCTL_CMD_TYPE_TTY ('T')
+
+#define IOCTL_CMD_ISTYPE(cmd, type) \
+ ((cmd & (IOCTL_CMD_TYPE_MASK)) == \
+ (((type) << IOCTL_CMD_TYPE_SHIFT) & \
+ IOCTL_CMD_TYPE_MASK))
+
struct vfsops;
struct vnops;
struct vnode;