Currently `9pfs` returns 0 for any `ioctl` request (except for
`TIOCGWINSZ`), which leads to multiple cases of files being interpreted
as terminals. You can see this problem when running python scripts,
since python uses `ioctl` calls to check if it should open up the
interactive interpretor or execute a script.
Same thing could happen for other applications that rely on `ioctl`
operations being properly executed, so the best way to go would be
return `ENOTSUP` (as is used to happen before commit
28d0edf).
If the `ioctl` call always return `ENOTSUP`, the Ruby binary
compatibility application will fail, since it tries to set O_ASYNC and
breaks on error, even if it does not directly depends on that, so for
now add a special case for that.
Signed-off-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1098
unsigned long com, void *data)
{
switch (com) {
- case TIOCGWINSZ:
- return ENOTTY;
- default:
+ /**
+ * HACK: In binary compatibility mode, Ruby tries to set O_ASYNC,
+ * which Unikraft does not yet support. If the `ioctl` call returns
+ * an error, Ruby stops working, even if it does not depend on the
+ * O_ASYNC being properly set.
+ *
+ * Until proper support, just return 0 in case an `FIONBIO` ioctl
+ * request is done, and ENOTSUP for all other cases.
+ *
+ * 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.
+ */
+ case FIONBIO:
return 0;
+ default:
+ return ENOTSUP;
}
}