[openbeosstorage] Re: Kernel Interface Design

The reason I combined the read/readdir functions is that the NewOS 
kernel does it this way (see bootfs.c).  The only problem with not 
managing our own file descriptors, is how do we know if its a file or 
directory?  (mind you, thinking about it, since sizeof(int) == 
sizeof(DIR*) - we could just check its size:
if (fd <256) {
    // File
} else {
   // Directory
}

since addresses in the range 0-255 are part of the kernel.

        What do you think?

            Keith

(PS. I'll use the exception class as well)

Tyler Dauwalder wrote:

>
>>My attempt at the emulator code (haven't had chance to try it under BeOS 
>>yet - but it compiles under gcc).  Any comments on this one?
>>
>
>That's not bad. I don't think we need to manage our own file descriptors
>now (see my comment in the next paragraph). Combining read and
>readdir into one function is an interesting idea. 
>
>>Data types - open modes are ints if you use open rather than fopen 
>>(O_CREAT, etc) - see the attached example
>>
>
>Hmm, good observation. That's what I get for not actually using
>POSIX funtions ;-). In light of that, I'm thinking we ought to just
>pass the ints returned by POSIX-open() and kernel-open() then,
>instead of managing our own file descriptors. The less code
>between us and the architecture below us, the better.
>
>>I think Tyler's right about throwing exceptions - this version doesn't, 
>>but it would make the code clearer if it did.
>>
>
>I wrote up the beginnings of an exception class we can use as
>the basis for our error handling. It takes an integer error code and
>a string error message. If you compile it with debug support in,
>it automatically prints out the error message to stdout when an
>exception is created. 
>
>I put it in CVS at /storage_kit/source/lib. SKError.cpp and SKError.h 
>are the files. Test.SKError.cpp just shows an example of using it. 
>
>Since catching by value or by reference seemed to involve the copy 
>constructor being called a couple of times (which meant a lot of 
>unnecessary string allocation and copying), I decided to make the
>copy constructor private so you're required to throw dynamically 
>allocated exceptions. That means any time you catch an *SKError 
>pointer and don't raise it again, you have to delete it. Doing it that
>way means the constructor only gets called once for each exception.
>
>-Tyler
>
>
>
>
>
>



Other related posts: