diff options
author | Marvin Borner | 2021-09-12 13:51:52 +0200 |
---|---|---|
committer | Marvin Borner | 2021-09-12 13:51:52 +0200 |
commit | f582a27638479da361c0f2e24501d6662e08b522 (patch) | |
tree | b7e6500953f93fd26fb645b8312510dcfc3d86ff | |
parent | 21d3377822c02a8857cb04ac9fe37e932e2f61e7 (diff) |
Fixed new mke2fs 256B inode due to 2038 prevention
-rw-r--r-- | kernel/features/fs.c | 29 | ||||
-rw-r--r-- | kernel/inc/drivers/ide.h | 2 | ||||
-rw-r--r-- | kernel/inc/fs.h | 2 |
3 files changed, 19 insertions, 14 deletions
diff --git a/kernel/features/fs.c b/kernel/features/fs.c index 7e79a42..7902d56 100644 --- a/kernel/features/fs.c +++ b/kernel/features/fs.c @@ -135,8 +135,9 @@ res vfs_read(const char *path, void *buf, u32 offset, u32 count) if (len > 1) path += len; - if (m->dev->vfs->perm(path, VFS_READ, m->dev) != EOK && !proc_super()) - return -EACCES; + res perm = m->dev->vfs->perm(path, VFS_READ, m->dev); + if (perm != EOK) + return perm; if (!count) return EOK; @@ -163,8 +164,9 @@ res vfs_write(const char *path, const void *buf, u32 offset, u32 count) if (len > 1) path += len; - if (m->dev->vfs->perm(path, VFS_WRITE, m->dev) != EOK && !proc_super()) - return -EACCES; + res perm = m->dev->vfs->perm(path, VFS_WRITE, m->dev); + if (perm != EOK) + return perm; if (!count) return EOK; @@ -191,8 +193,9 @@ res vfs_stat(const char *path, struct stat *buf) if (len > 1) path += len; - if (m->dev->vfs->perm(path, VFS_READ, m->dev) != EOK && !proc_super()) - return -EACCES; + res perm = m->dev->vfs->perm(path, VFS_READ, m->dev); + if (perm != EOK) + return perm; return m->dev->vfs->stat(path, buf, m->dev); } @@ -219,7 +222,7 @@ INLINE static void ext2_buffer_read(u32 block, void *buf, struct vfs_dev *dev) dev->read(buf, block * SECTOR_COUNT, SECTOR_COUNT, dev); } -static void ext2_get_superblock(struct ext2_superblock *buf, struct vfs_dev *dev) +static void ext2_superblock(struct ext2_superblock *buf, struct vfs_dev *dev) { u8 data[BLOCK_SIZE] = { 0 }; ext2_buffer_read(EXT2_SUPER, data, dev); @@ -228,10 +231,10 @@ static void ext2_get_superblock(struct ext2_superblock *buf, struct vfs_dev *dev assert(buf->magic == EXT2_MAGIC); } -static struct ext2_inode *ext2_get_inode(u32 i, struct ext2_inode *in_buf, struct vfs_dev *dev) +static struct ext2_inode *ext2_inode(u32 i, struct ext2_inode *in_buf, struct vfs_dev *dev) { struct ext2_superblock sb = { 0 }; - ext2_get_superblock(&sb, dev); + ext2_superblock(&sb, dev); u8 data[BLOCK_SIZE] = { 0 }; ext2_buffer_read(EXT2_SUPER + 1, data, dev); @@ -361,7 +364,7 @@ static u32 ext2_find_inode(const char *name, u32 dir_inode, struct vfs_dev *dev) return (unsigned)-1; struct ext2_inode i = { 0 }; - ext2_get_inode(dir_inode, &i, dev); + ext2_inode(dir_inode, &i, dev); char *buf = zalloc(BLOCK_SIZE * i.blocks / 2); @@ -383,8 +386,8 @@ static u32 ext2_find_inode(const char *name, u32 dir_inode, struct vfs_dev *dev) return d->inode_num; } d = (struct ext2_dirent *)((u32)d + d->total_len); + } while (sum < (BLOCK_SIZE * i.blocks / 2)); - } while (sum < (1024 * i.blocks / 2)); free(buf); return (unsigned)-1; } @@ -428,7 +431,7 @@ static struct ext2_inode *ext2_find_inode_by_path(const char *path, struct ext2_ if ((signed)inode <= 0) return NULL; - return ext2_get_inode(inode, in_buf, dev); + return ext2_inode(inode, in_buf, dev); } static res ext2_read(const char *path, void *buf, u32 offset, u32 count, struct vfs_dev *dev) @@ -475,7 +478,7 @@ static res ext2_perm(const char *path, enum vfs_perm perm, struct vfs_dev *dev) CLEAR u8 ext2_load(struct vfs_dev *dev) { struct ext2_superblock sb = { 0 }; - ext2_get_superblock(&sb, dev); + ext2_superblock(&sb, dev); if (sb.magic != EXT2_MAGIC) return 0; diff --git a/kernel/inc/drivers/ide.h b/kernel/inc/drivers/ide.h index dbe0652..f4b4c7d 100644 --- a/kernel/inc/drivers/ide.h +++ b/kernel/inc/drivers/ide.h @@ -8,7 +8,7 @@ #define BLOCK_SIZE 1024 #define BLOCK_COUNT 256 // BLOCK_SIZE / sizeof(u32) #define SECTOR_SIZE 512 -#define SECTOR_COUNT (BLOCK_SIZE / SECTOR_SIZE) +#define SECTOR_COUNT (BLOCK_SIZE / SECTOR_SIZE) // 2 #define ATA_PRIMARY_IO 0x1f0 #define ATA_SECONDARY_IO 0x170 diff --git a/kernel/inc/fs.h b/kernel/inc/fs.h index 42cf21a..04d3624 100644 --- a/kernel/inc/fs.h +++ b/kernel/inc/fs.h @@ -148,6 +148,8 @@ struct ext2_inode { u32 fragment_addr; u8 os_specific_val2[12]; + + u8 extension[128]; // TODO: 2038 extension time support }; #define EXT2_INODE_SIZE (sizeof(struct ext2_inode)) |