I’m currently reading the James Molloy OS Development series and working on implementing file I/O functions. In the documentation, James defines the following function prototypes for file operations:
Code: Select all
typedef u32int (*read_type_t)(struct fs_node*, u32int, u32int, u8int*);
typedef u32int (*write_type_t)(struct fs_node*, u32int, u32int, u8int*);
typedef void (*open_type_t)(struct fs_node*);
typedef void (*close_type_t)(struct fs_node*);
typedef struct dirent* (*readdir_type_t)(struct fs_node*, u32int);
typedef struct fs_node* (*finddir_type_t)(struct fs_node*, char *name);
struct dirent {
char name[128]; // Filename
u32int ino; // Inode number (required by POSIX)
};
I have a couple of questions:
Where are the actual implementations for these prototypes?
Specifically, where in the James Molloy OS codebase do the read, write, open, close, readdir, and finddir functions get implemented and how are they used?
POSIX read/write vs. James Molloy’s implementation:
I looked at the POSIX documentation for the read function:
Code: Select all
ssize_t pread(int fildes, void *buf, size_t nbyte, off_t offset);
ssize_t read(int fildes, void *buf, size_t nbyte);
Thanks in advance for any help!