[openbeosstorage] Re: First C Device API Draft

  • From: "Ingo Weinhold" <bonefish@xxxxxxxxxxxxxxx>
  • To: openbeosstorage@xxxxxxxxxxxxx
  • Date: Sun, 29 Dec 2002 01:05:37 CET (+0100)

> 
> "Ingo Weinhold" <bonefish@xxxxxxxxxxxxxxx> wrote:
> > I was almost starting to implement it, when I started wondering 
> > whether 
> > it would be better to return/pass a pointer to the module itself, 
> > not 
> > just the name. This would even save the overhead for loading/
> > unloading 
> > the module each time. Then the caller would be responsible for 
> > calling 
> > put=5Fmodule() (unless a NULL module=5Finfo** had been supplied or 
> > the 
> > returned pointer was NULL). How does that sound=3F
> 
> Sounds okay, I think... at least it must be documented that you have 
> to 
> do that :)

That wouldn't be a problem. :-)

> > I'm not longer sure, whether it is possible at all. 
> > B=5FGET=5FPARTITION=5FINFO has to be called on the partition 
> > device, not on 
> > the raw device, and I wouldn't know how to get hold of it (it's in 
> > the 
> > same dir as the raw device, but that doesn't really help...).
> 
> Where is the problem=3F AFAICT the devfs directs all calls to the raw 
> device, altering the position and size of the read/write calls, 
> answering to ioctl()s the raw device cannot know about, etc.

That's what I think too, but how does it help with getting the name of 
the raw device from a file descriptor for it? devfs certainly knows the 
name of the raw device belonging to a partition, since it is told so 
via B_SET_PARTITION, and can report it on a B_GET_PARTITION_INFO, but 
getting a name for a FD is the one thing, that usually doesn't work out 
(as with node_refs), unless there is some private magic.

> > OK. But then we should find a way to fill it in for the time being, 
> > since one would certainly like to use it in implementation of the C
> > ++
> > API.
> 
> The "df" command also lists the mount point of the volumes, should be 
> possible, although it obviously uses a private call =5Fkstatfs=5F() :
> -)

That way around, it is easy. You can use next_dev() to iterate through 
the mounted volumes and fs_stat_dev() to get information about them 
(the mount point among other details), or alternatively BVolume/
BVolumeRoster. Given a device FD and the question, whether and where 
that device is mounted, is a bit more difficult. Either an ioctl/
syscall needs to be provided to get that info directly, or one has to 
iterate through the mounted devices and check whether the given one is 
among them.

CU, Ingo



Other related posts: