diff options
author | Renaud Barbier <renaud.barbier@ge.com> | 2014-01-29 11:06:51 +0000 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-01-30 08:42:53 +0100 |
commit | 4a6c8b1e04695c03d4c7d6e27a21a03e2ecf7050 (patch) | |
tree | c65a3d0c1cb4bd953c18847b8984ced168187c7b /fs | |
parent | b99e853aff4dc6f442e62a8187de04877877c4b1 (diff) | |
download | barebox-4a6c8b1e04695c03d4c7d6e27a21a03e2ecf7050.tar.gz barebox-4a6c8b1e04695c03d4c7d6e27a21a03e2ecf7050.tar.xz |
UBIFS: implement readlink entry point
Implement the readlink entry point for future use by the DA923RC.
Signed-off-by: Renaud Barbier <renaud.barbier@ge.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ubifs/ubifs.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c index dfa6107458..e2f9593f20 100644 --- a/fs/ubifs/ubifs.c +++ b/fs/ubifs/ubifs.c @@ -24,6 +24,7 @@ */ #include <common.h> +#include <malloc.h> #include <driver.h> #include <init.h> #include <malloc.h> @@ -549,6 +550,42 @@ static int ubifs_stat(struct device_d *dev, const char *filename, struct stat *s return 0; } +static char *ubifs_symlink(struct inode *inode) +{ + struct ubifs_inode *ui; + char *symlink; + + ui = ubifs_inode(inode); + symlink = malloc(ui->data_len + 1); + + memcpy(symlink, ui->data, ui->data_len); + symlink[ui->data_len] = '\0'; + + return symlink; +} + +static int ubifs_readlink(struct device_d *dev, const char *pathname, char *buf, + size_t bufsz) +{ + struct ubifs_priv *priv = dev->priv; + struct inode *inode; + char *symlink; + int len; + + inode = ubifs_findfile(priv->sb, pathname); + + if (!inode) + return -ENOENT; + + symlink = ubifs_symlink(inode); + + len = min(bufsz, strlen(symlink)); + memcpy(buf, symlink, len); + free(symlink); + + return 0; +} + static int ubifs_probe(struct device_d *dev) { struct fs_device_d *fsdev = dev_to_fs_device(dev); @@ -609,6 +646,7 @@ static struct fs_driver_d ubifs_driver = { .readdir = ubifs_readdir, .closedir = ubifs_closedir, .stat = ubifs_stat, + .readlink = ubifs_readlink, .type = filetype_ubifs, .flags = 0, .drv = { |