From 02107df3f476c19bb7eaa3c49a368d703898615b Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Sun, 9 Sep 2018 00:19:12 +1000 Subject: Re-ordered system call numbers and definitions into alphabetical order to make management/maintenance easier. Defined the structures super_block and m_inode in kernel/fs.h for super blocks and inodes respectively. Added the new header file sys/stat.h which contains basic definitions for inode types and permissions. These definitions will be required by any functions handling m_inode structures. Moved the sys_read and sys_write system calls to the filesystem's main source file at kernel/fs/fs.c. Added the file kernel/fs/mount.c which will contain the super-blocks table as well as the function mount_root() which will attempt to mount the root filesystem during boot. Eventually, this file will be expanded to include a general-purpose mount function to mount any filesystem as well as the system call handler for sys_mount. Seperated block I/O functions into their own subsystem under kernel/fs/block.c which currently supports two functions; block_read() and block_write() to read and write blocks from block devices. Currently, no device can be specified since the primary ATA master drive is the only possible target. This will change in the future however. Modified the hard disk driver's read and write functions to use filesystem blocks rather than sectors as the units of transfer. This is intended to keep the block I/O subsystem simple by ensuring a uniform transfer unit is used across all block devices and drivers. The hard disk driver is no longer initialized during the main boot procedure. Instead, a call is made to the new function fs_init() which will setup filesystem tables and structures, call hd_init() to initialize the disk and finally, attempt to load the super-block for the root filesystem. The hard disk driver now stores the disk's size and sanity checks addresses and sizes in read and write calls against this value. --- include/sys/stat.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 include/sys/stat.h (limited to 'include/sys') diff --git a/include/sys/stat.h b/include/sys/stat.h new file mode 100644 index 0000000..fab014c --- /dev/null +++ b/include/sys/stat.h @@ -0,0 +1,42 @@ +#ifndef _SYS_STAT_H +#define _SYS_STAT_H + +/* permission bits */ + +#define S_IRWXU 0700 +#define S_IRUSR 0400 +#define S_IWUSR 0200 +#define S_IXUSR 0100 + +#define S_IRWXG 0070 +#define S_IRGRP 0040 +#define S_IWGRP 0020 +#define S_IXGRP 0010 + +#define S_IRWXO 0007 +#define S_IROTH 0004 +#define S_IWOTH 0002 +#define S_IXOTH 0001 + +/* inode type bits */ + +#define S_IFMT 0170000 +#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 + +/* inode type conditionals */ + +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) + +#endif -- cgit v1.3