fat32: add more stubs

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-07-12 16:01:53 -04:00
commit 7aed4b6579
4 changed files with 130 additions and 14 deletions

View file

@ -1,7 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <kernel/common.h>
#include <kernel/slab.h>
#include <kernel/block.h>
#include <fs/vfs.h>
#include <fs/fat32.h>
#include <lib/string.h>
@ -26,21 +29,16 @@ static int open_inode(fs_t *fs, u64 id, dirent_t *dirent, inode_t **out)
static int fs_init(int flags, struct block_device *bdev, fs_t **out)
{
fs_t *fs = kalloc(sizeof(fs_t), ALLOC_KERN);
if (!fs)
return -ENOMEM;
*out = fs;
fs->fs_ops.alloc_inode = alloc_inode;
fs->fs_ops.free_inode = free_inode;
fs->fs_ops.open_inode = open_inode;
return 0;
return fat32_create(bdev, flags, out);
}
static int fs_deinit(fs_t *fs)
{
return -EINVAL;
return -ENOSYS;
}
int fat32_create(struct block_device *bdev, u64 flags, fs_t **out)
{
}
void fat32_init()
@ -48,5 +46,10 @@ void fat32_init()
strcpy(fat32_driver.name, "fat32");
fat32_driver.init = fs_init;
fat32_driver.deinit = fs_deinit;
void fat32_inode_ops_init(void);
fat32_inode_ops_init();
vfs_register(&fat32_driver);
}
DRIVER_ENTRY(fat32_init);

View file

@ -1,2 +1,46 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <kernel/common.h>
#include <kernel/slab.h>
#include <kernel/block.h>
#include <fs/vfs.h>
#include <lib/string.h>
#include "inode.h"
struct inode_ops fat32_inode_ops = {0};
static ssize_t read(inode_t *inode, char *buf, size_t size, size_t offset)
{
return -ENOSYS;
}
static ssize_t write(inode_t *inode, char *buf, size_t size, size_t offset)
{
return -ENOSYS;
}
static int link(inode_t *parent_dir, inode_t *child, const char *name, dirent_t **out)
{
return -ENOSYS;
}
static int unlink(inode_t *parent_dir, const char *name)
{
return -ENOSYS;
}
static ssize_t get_dents(inode_t *parent, dirent_t **dents)
{
return -ENOSYS;
}
void fat32_inode_ops_init(void)
{
fat32_inode_ops.read = read;
fat32_inode_ops.write = write;
fat32_inode_ops.link = link;
fat32_inode_ops.unlink = unlink;
fat32_inode_ops.get_dents = get_dents;
}

View file

@ -1,7 +1,11 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _INODE_H_
#define _INODE_H_
#ifndef _F32_INODE_H_
#define _F32_INODE_H_
#include <kernel/common.h>
#include <kernel/block.h>
#include <kernel/spinlock.h>
#include <fs/vfs.h>
#endif /* _INODE_H_ */
#endif /* _F32_INODE_H_ */

65
include/fs/fat32.h Normal file
View file

@ -0,0 +1,65 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _FAT32_H_
#define _FAT32_H_
#include <fs/vfs.h>
#include <kernel/block.h>
#define FS_TYPE_FAT32 0x46415433 /* "FAT3" */
struct fat_bpb {
char padding[3];
char oem[8];
u16 bytes_per_sec;
u8 secs_per_clr;
u16 n_reserved_secs;
u8 n_fats;
u16 n_root_dirents;
u16 n_sectors;
u8 mdt;
u16 ignore;
u16 secs_per_trk;
u16 n_nheads;
u32 n_hidden;
u32 n_sectors_long;
} PACKED;
struct f32_ebr {
struct fat_bpb bpb;
u32 secs_per_fat;
u16 flags;
u16 fat_version;
u32 root_clr_nio;
u16 fsinfo_sec_no;
u16 backup_boot_sec_no;
char reserved[12];
u8 drive_no;
u8 reserved1;
u8 signature;
u32 serial_no;
char vol_label[11];
char sys_id[8];
char boot_code[420];
char boot_signature[2];
} PACKED;
struct f32_fsinfo {
u32 signature; /* 0x41615252 */
char reserved[480];
u32 signature2; /* 0x61417272 */
u32 last_free_clr_count;
u32 clr_search_start;
char reserved2[12];
u32 trail_signature; /* 0xAA550000 */
} PACKED;
struct f32_sb {
struct f32_ebr *ebr;
struct f32_fsinfo *info;
struct block_device *bdev;
};
int fat32_create(struct block_device *bdev, u64 flags, fs_t **out);
void fat32_init(void);
#endif /* _FAT32_H_ */