diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2020-06-12 08:45:27 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-07-05 16:17:12 +0200 |
commit | 5edb9f03a0e7d83c817ff17e19a852e2f564aef8 (patch) | |
tree | 65c088532c974634a9d1ec3fcadde7770e5ec04d | |
parent | b9ce4012e9c63be6861ec60f704597feb9805372 (diff) | |
download | barebox-5edb9f03a0e7d83c817ff17e19a852e2f564aef8.tar.gz barebox-5edb9f03a0e7d83c817ff17e19a852e2f564aef8.tar.xz |
fs: ramfs: Implement memmap
When an inode only has a single chunk then we can support memmap for
it.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | fs/ramfs.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/fs/ramfs.c b/fs/ramfs.c index db90e5762e..14ba877660 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 = { |