--- a/src/simple.c Fri Sep 26 21:20:48 2008 +0300
+++ b/src/simple.c Sat Sep 27 00:20:47 2008 +0300
@@ -112,6 +112,34 @@
EWARNING(err, "fuse_reply_err");
}
+static void simple_readlink (fuse_req_t req, fuse_ino_t ino) {
+ struct simple_fs *fs = fuse_req_userdata(req);
+ const struct simple_node *node;
+ int err;
+
+ INFO("[simple.readlink %p] ino=%lu", fs, ino);
+
+ // look up the node
+ if ((node = _simple_get_ino(fs, ino)) == NULL)
+ EERROR(err = EINVAL, "bad inode");
+
+ // check that it's a symlink
+ if (node->mode_type != S_IFLNK)
+ EERROR(err = EINVAL, "bad mode");
+
+ // return the contents
+ if ((err = fuse_reply_readlink(req, node->data)))
+ EERROR(err, "fuse_reply_readlink");
+
+ // suceccss
+ return;
+
+error:
+ if ((err = fuse_reply_err(req, err)))
+ EWARNING(err, "fuse_reply_err");
+
+}
+
static void simple_readdir (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, struct fuse_file_info *fi) {
struct simple_fs *fs = fuse_req_userdata(req);
const struct simple_node *dir_node, *node;
@@ -214,6 +242,8 @@
.getattr = simple_getattr,
+ .readlink = simple_readlink,
+
.readdir = simple_readdir,
.read = simple_read,
--- a/src/simple_hello.c Fri Sep 26 21:20:48 2008 +0300
+++ b/src/simple_hello.c Sat Sep 27 00:20:47 2008 +0300
@@ -20,6 +20,12 @@
static struct simple_node node_list[] = {
{ 1, S_IFDIR, 0555, 0, NULL, NULL },
{ 2, S_IFREG, 0444, 1, "hello", "Hello World!\n" },
+ { 3, S_IFREG, 0444, 1, "foo", "Foo\n" },
+ { 4, S_IFREG, 0444, 1, "bar", "Bar\n" },
+ { 5, S_IFDIR, 0555, 1, "test", NULL },
+ { 6, S_IFREG, 0444, 5, "file0", "data0\n" },
+ { 7, S_IFREG, 0444, 5, "file1", "data1\n" },
+ { 8, S_IFLNK, 0444, 1, "lnk0", "test/file0" },
{ 0, 0, 0, 0, NULL, NULL },
};