[openbeos] Storage Kit

  • From: Keith Poole <keef@xxxxxxxxxxxxxxx>
  • To: Brander Lien <blien@xxxxxxxxxxxxxxxx>,openbeos <openbeos@xxxxxxxxxxxxx>
  • Date: Sat, 03 Nov 2001 18:06:42 +0000

I've been looking at the storage kit & the newOS source, and I've come 
up with what I think is the API used for accessing the underlying file 
systems - I have written a first stab at documenting this but it needs 
to be checked. (see attached)

If this is the correct way to proceed, we could write an emulator to 
test the storage kit classes against

        Keith


-- Attached file included as plaintext by Listar --
-- File: NewOSAPI

NewOS API

This details the API provided by NewOS to access the underlying file systems 
(taken from vfs.h)

typedef enum {
        STREAM_TYPE_NULL = 0,
        STREAM_TYPE_FILE,
        STREAM_TYPE_DIR,
        STREAM_TYPE_DEVICE,
        STREAM_TYPE_STRING
} stream_type;

typedef enum {
        SEEK_SET = 0,
        SEEK_CUR,
        SEEK_END
} seek_type;

struct redir_struct {
        bool redir;
        void *vnode;
        const char *path;
};

struct vnode_stat {
        off_t size;
};

int user_open(const char *path, const char *stream, stream_type stream_type);
Open a stream
Parameters:
        path - path to the stream (i.e. "/dev/beosDev/doc")
        stream - name of stream (i.e. "NewOSAPI")
        stream_type - One of:
                STREAM_TYPE_NULL - not sure
                STREAM_TYPE_FILE - a file
                STREAM_TYPE_DIR - directory
                STREAM_TYPE_DEVICE - raw device
                STREAM_TYPE_STRING - not sure
Returns:
        > 0 - file descriptor ?
        < 0 - error (see sys/errors.h for details)
                
int user_seek(int fd, off_t pos, seek_type seek_type);
Seek to a positon in a stream (a la fseek)
Parameters:
        fd - file descriptor
        pos - position to seek to
        seek_type - one of:
                SEEK_SET - position from start
                SEEK_CUR - position from current pos
                SEEK_END - position from end
NB, only user_seek(fd, SEEK_SET, 0) - is allowed for directories.
Returns:
        < 0 - error
        0 - seek ok
        
int user_read(int fd, void *buf, off_t pos, size_t *len);
Read bytes from a stream
Parameters:
        fd - file descriptor
        buf - destination buffer
        pos - ?
        len - length to read
NB, directory reads return the name of the next object in the directory
Returns:
        < 0 - error
        = 0 - end of file
        > 0 - number of bytes read

int user_write(int fd, const void *buf, off_t pos, size_t *len);
Write bytes to a stream
Parameters:
        fd - file descriptor
        buf - source
        pos - ?
        len - length to read
Returns
        < 0 - error
        >= 0 - bytes written
        
int user_ioctl(int fd, int op, void *buf, size_t len);
Perform IOCTL operation
Paramters:
        fd - file descriptor
        op - operation
        buf - buffer to pass
        len - length of buffer

int user_close(int fd);
Close a stream
Parameters:
        fd - file descriptor
Returns
        < 0 - error
        0 - ok
int user_create(const char *path, const char *stream, stream_type stream_type);
Create a stream
Parameters
        path - path to new stream
        stream - name of stream
        stream_type - as open

Returns:
        < 0 - error
        = 0 - ok (?) or file descriptor(?)

int user_stat(const char *path, const char *stream, stream_type stream_type, 
struct vnode_stat *stat);
Get file status
Parameters:
        path - path to stream
        stream - name of stream
        stream_type - as user_open
        stat - vnode structure containing status:
                struct vnode_stat {
                         off_t size;
                };                       



Other related posts: