quinn-os/vfs.h
2015-08-30 21:23:50 +10:00

82 lines
2.5 KiB
C

#ifndef __VFS_H
#define __VFS_H
struct vfs_device_t {
unsigned int device;
char name[16];
unsigned char fs;
char *cwd;
void *fs_data;
};
struct vfs_file_handle_t {
char *filepath;
struct vfs_device_t *device;
unsigned char free;
unsigned long position;
unsigned long size;
void *fs_specific;
};
struct quinn_dirent_t {
unsigned int name_len;
unsigned int rec_len;
unsigned int next_offset;
unsigned char type;
char name[1];
};
struct stat {
unsigned short st_dev; //ID of device containing file
unsigned int st_ino; //file serial number
unsigned short st_mode; //mode of file (see below)
unsigned short st_nlink; //number of links to the file
unsigned short st_uid; //user ID of file
unsigned short st_gid; //group ID of file
unsigned short st_rdev; //device ID (if file is character or block special)
unsigned int st_size; //file size in bytes (if file is a regular file)
unsigned int st_atime; //time of last access
unsigned int st_mtime; //time of last data modification
unsigned int st_ctime; //time of last status change
unsigned int st_blksize; //a filesystem-specific preferred I/O block size for
unsigned int st_blocks; //number of blocks allocated for this object
};
#define O_RDONLY 0x0000
#define O_WRONLY 0x0001
#define O_RDWR 0x0002
#define O_APPEND 0x0008
#define O_CREAT 0x0200
#define O_TRUNC 0x0400
#define O_EXCL 0x0800
#define O_SYNC 0x2000
#define O_NONBLOCK 0x4000
#define S_IFSOCK 0140000
#define S_IFLNK 0120000
#define S_IFREG 0100000
#define S_IFBLK 0060000
#define S_IFDIR 0040000
#define S_IFCHR 0020000
#define S_IFIFO 0010000
#define S_ISUID 0004000
#define S_ISGID 0002000
#define S_ISVTX 0001000
extern void init_vfs(void);
extern struct vfs_device_t *vfs_register_device(unsigned int device, char *name, unsigned char fstype);
extern unsigned char vfs_select_device(char *name);
extern void vfs_close_file(int fno);
extern int vfs_open_file(char *path, int flags, int mode);
extern int vfs_read_file(int fileno, char *buffer, int len);
extern int vfs_write_file(int fileno, char *buffer, int len);
extern void vfs_close_all();
extern int vfs_getdents(int fno, char *buffer, int count);
extern int vfs_mkdir(char *path);
extern char *vfs_read_entire_file(char *path, char **buffer);
extern int vfs_change_directory(char *path);
extern int vfs_fstat(int fileno, struct stat *s);
extern int vfs_stat(char *path, struct stat *s);
extern int vfs_lseek(int fileno, int offset, int whence);
#endif