mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Renaud Barbier <renaud.barbier@ge.com>
To: barebox@lists.infradead.org
Subject: [PATCH 2/3] UBIFS: implement readlink entry point
Date: Wed, 29 Jan 2014 11:06:51 +0000	[thread overview]
Message-ID: <1390993612-26246-3-git-send-email-renaud.barbier@ge.com> (raw)
In-Reply-To: <1390993612-26246-1-git-send-email-renaud.barbier@ge.com>

Implement the readlink entry point for future use by the DA923RC.

Signed-off-by: Renaud Barbier <renaud.barbier@ge.com>
---
 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 dfa6107..e2f9593 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 = {
-- 
1.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2014-01-29 11:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-29 11:06 [PATCH 0/3] DA923RC: enable UBIFS support to allow firmware flash booting Renaud Barbier
2014-01-29 11:06 ` [PATCH 1/3] ppc: remove bit operation headers file conflict Renaud Barbier
2014-01-29 11:06 ` Renaud Barbier [this message]
2014-01-29 11:06 ` [PATCH 3/3] DA923RC: enable UBI/UBIFS configuration Renaud Barbier
2014-01-30  7:43 ` [PATCH 0/3] DA923RC: enable UBIFS support to allow firmware flash booting Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1390993612-26246-3-git-send-email-renaud.barbier@ge.com \
    --to=renaud.barbier@ge.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox