James Molloy File System and Function Prototypes
Posted: Tue Dec 31, 2024 12:38 am
Hi,
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:
These function prototypes are supposed to be used for interacting with a custom file system in the OS. However, the actual implementations for these prototypes are not clearly explained or provided in the series.
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:
But the function signature and the way it's used in James Molloy’s OS examples don’t exactly match the POSIX definitions.
Thanks in advance for any help!
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!