[haiku-development] Re: ioctl

  • From: "Ingo Weinhold" <ingo_weinhold@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Mon, 27 Jul 2009 03:12:36 +0200

-------- Original-Nachricht --------
> Datum: Mon, 27 Jul 2009 00:23:20 +0000
> Von: Brecht Machiels <brecht@xxxxxxxxxxx>

> Ingo Weinhold wrote:
>  >> On a related note, I have implemented open(), read(), close() and
>  >> free_cookie() only for files. BFS seems to implement these for
>  >> directories too (except perhaps read() - I haven't checked the
> sources).
>  >> Is this required? What is it used for?
>  >
>  > Yes, that's indeed required. The open()/close() hooks are basically the
>  > backends for the equally named POSIX functions and those are supposed
> to
>  > work on directories, too. read() and write() must fail for directories,
>  > though.
> 
> What is the purpose of being able to open() directories? Pointing me to 
> a reference is fine. I haven't been able to find anything on it.

You can't read from or write to directory FDs, but most other operations that 
work on file FDs also work on directory FDs, like fstat() or fchmod(). Under 
BeOS/Haiku several attribute functions (<fs_attr.h>) require a FD. With the 
latest version of POSIX several *at() (fstatat(), openat(),...) functions were 
introduced, which use a file location based off a directory FD.

CU, Ingo

Other related posts: