When an inode only has a single chunk then we can support memmap for it. Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> --- fs/ramfs.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fs/ramfs.c b/fs/ramfs.c index ebe03de736..84aa56f83e 100644 --- a/fs/ramfs.c +++ b/fs/ramfs.c @@ -387,6 +387,25 @@ static int ramfs_truncate(struct device_d *dev, FILE *f, loff_t size) return 0; } +static int ramfs_memmap(struct device_d *_dev, FILE *f, void **map, int flags) +{ + struct inode *inode = f->f_inode; + struct ramfs_inode *node = to_ramfs_inode(inode); + struct ramfs_chunk *data; + + if (list_empty(&node->data)) + return -EINVAL; + + if (!list_is_singular(&node->data)) + return -EINVAL; + + data = list_first_entry(&node->data, struct ramfs_chunk, list); + + *map = data->data; + + return 0; +} + static struct inode *ramfs_alloc_inode(struct super_block *sb) { struct ramfs_inode *node; @@ -434,6 +453,7 @@ static void ramfs_remove(struct device_d *dev) static struct fs_driver_d ramfs_driver = { .read = ramfs_read, .write = ramfs_write, + .memmap = ramfs_memmap, .truncate = ramfs_truncate, .flags = FS_DRIVER_NO_DEV, .drv = { -- 2.27.0 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox