From: Huang Jianan <huangjia...@oppo.com>

This patch adds symlink and special inode (e.g. block dev, char,
socket, pipe inode) support.

Signed-off-by: Huang Jianan <huangjia...@oppo.com>
Signed-off-by: Guo Weichao <guoweic...@oppo.com>
Signed-off-by: Gao Xiang <hsiang...@aol.com>
---
 fuse/main.c | 10 ++++++++++
 lib/namei.c | 22 ++++++++++++++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/fuse/main.c b/fuse/main.c
index ab8a90aadf8a..1e24efe110c2 100644
--- a/fuse/main.c
+++ b/fuse/main.c
@@ -78,7 +78,17 @@ static int erofsfuse_read(const char *path, char *buffer,
        return size;
 }
 
+static int erofsfuse_readlink(const char *path, char *buffer, size_t size)
+{
+       int ret = erofsfuse_read(path, buffer, size, 0, NULL);
+
+       if (ret < 0)
+               return ret;
+       return 0;
+}
+
 static struct fuse_operations erofs_ops = {
+       .readlink = erofsfuse_readlink,
        .getattr = erofsfuse_getattr,
        .readdir = erofsfuse_readdir,
        .open = erofsfuse_open,
diff --git a/lib/namei.c b/lib/namei.c
index b05f5c421d54..e8275a42f090 100644
--- a/lib/namei.c
+++ b/lib/namei.c
@@ -15,6 +15,14 @@
 #include "erofs/print.h"
 #include "erofs/io.h"
 
+static dev_t erofs_new_decode_dev(u32 dev)
+{
+       const unsigned int major = (dev & 0xfff00) >> 8;
+       const unsigned int minor = (dev & 0xff) | ((dev >> 12) & 0xfff00);
+
+       return makedev(major, minor);
+}
+
 static int erofs_read_inode_from_disk(struct erofs_inode *vi)
 {
        int ret, ifmt;
@@ -57,10 +65,13 @@ static int erofs_read_inode_from_disk(struct erofs_inode 
*vi)
                        break;
                case S_IFCHR:
                case S_IFBLK:
-                       return -EOPNOTSUPP;
+                       vi->u.i_rdev =
+                               
erofs_new_decode_dev(le32_to_cpu(die->i_u.rdev));
+                       break;
                case S_IFIFO:
                case S_IFSOCK:
-                       return -EOPNOTSUPP;
+                       vi->u.i_rdev = 0;
+                       break;
                default:
                        goto bogusimode;
                }
@@ -86,10 +97,13 @@ static int erofs_read_inode_from_disk(struct erofs_inode 
*vi)
                        break;
                case S_IFCHR:
                case S_IFBLK:
-                       return -EOPNOTSUPP;
+                       vi->u.i_rdev =
+                               
erofs_new_decode_dev(le32_to_cpu(dic->i_u.rdev));
+                       break;
                case S_IFIFO:
                case S_IFSOCK:
-                       return -EOPNOTSUPP;
+                       vi->u.i_rdev = 0;
+                       break;
                default:
                        goto bogusimode;
                }
-- 
2.24.0

Reply via email to