Skip to content

Commit

Permalink
lib/9pfs: Return ENOTSUP on ioctl requests
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Sergiu Moga <[email protected]>
Approved-by: Simon Kuenzer <[email protected]>
GitHub-Closes: unikraft#1098
  • Loading branch information
StefanJum authored and razvand committed Oct 4, 2023
1 parent 2811157 commit 1853afe
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/9pfs/9pfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1016,10 +1016,23 @@ static int uk_9pfs_ioctl(struct vnode *dvp, struct vfscore_file *fp,
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;
}
}

Expand Down

0 comments on commit 1853afe

Please sign in to comment.