[haiku-commits] Re: r40686 - haiku/trunk/src/system/kernel/fs

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 26 Feb 2011 15:01:10 +0100

On 2011-02-26 at 12:01:24 [+0100], Jérôme Duval <korli@xxxxxxxxxxxxxxxx> 
wrote:
> 2011/2/26 Ingo Weinhold <ingo_weinhold@xxxxxx>:
> > This is not correct. FDTYPE_FILE means a vnode based file descriptor. 
> > Whether
> > the particular ioctls are supported utterly depends on the vnode. E.g. 
> > FIFOs,
> > while the implementation doesn't ATM, actually could support those. In 
> > case
> > of devices -- and this includes the TTY driver -- the call is forwarded to
> > the device's control() hook.
> 
> Sure that's what I thought initially. But going to fix every driver
> and fs to have them return the correct error code for a particular
> opcode seemed a bit cumbersome.

Yes, but the only other option is to call the ioctl() hook and, if it returns 
an error that looks like the call is not supported, convert the error code to 
the expected one. Unfortunately, I believe B_BAD_VALUE is commonly returned 
when the ioctl is not supported, which could as well mean that some parameter 
value is incorrect. So I guess the only real solution is to go through all 
FSs and drivers and return the correct error code. Could be simplified and 
made extensible by providing a kernel function (e.g. status_t 
unsupported_ioctl(int opcode)) that can be called in the default case.

> Socket descriptors were still
> receiving the call.

Yes, they have a different descriptor type.

> > The other listed FD types are also vnode based and apparently the
> > common_ioctl() hook is called for them as well. Which is seriously broken,
> > since they pass the wrong cookie to the vnode's hook. I'd use a new 
> > (no-op)
> > hook for them and perhaps put the FIONBIO/FIONREAD check there.
> 
> How so? The descriptor cookie is also the one to be passed on the ioctl 
> hook.

The meaning of the cookie depends on the descriptor type. E.g. for a 
directory FD it is the cookie the fs_vnode_ops::open_dir() hook returns and 
that can be passed to the other *_dir() hooks. The ioctl() hook expects the 
one returned by the open() hook, though. In the rather likely case that the 
cookies aren't compatible bad things might happen when the ioctl() hook 
accesses such a mismatching cookie.

CU, Ingo

Other related posts: