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>
This commit is contained in:
parent
b99e853aff
commit
4a6c8b1e04
|
@ -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 = {
|
||||
|
|
Loading…
Reference in New Issue