linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Gao Xiang via Linux-erofs <linux-erofs@lists.ozlabs.org>
To: linux-erofs@lists.ozlabs.org
Cc: Guo Weichao <guoweichao@oppo.com>
Subject: [PATCH v3 2/3] erofs-utils: fuse: support symlink & special inode
Date: Fri, 27 Nov 2020 19:46:16 +0800	[thread overview]
Message-ID: <20201127114617.13055-3-hsiangkao@aol.com> (raw)
In-Reply-To: <20201127114617.13055-1-hsiangkao@aol.com>

From: Huang Jianan <huangjianan@oppo.com>

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

Signed-off-by: Huang Jianan <huangjianan@oppo.com>
Signed-off-by: Guo Weichao <guoweichao@oppo.com>
Signed-off-by: Gao Xiang <hsiangkao@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


  parent reply	other threads:[~2020-11-27 11:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20201127114617.13055-1-hsiangkao.ref@aol.com>
2020-11-27 11:46 ` [PATCH v3 0/3] erofs-utils: introduce fuse implementation Gao Xiang via Linux-erofs
2020-11-27 11:46   ` [PATCH v3 1/3] " Gao Xiang via Linux-erofs
2020-11-27 12:19     ` [PATCH v4 " Gao Xiang via Linux-erofs
2020-11-27 11:46   ` Gao Xiang via Linux-erofs [this message]
2020-12-05  8:42     ` [PATCH v3 2/3] erofs-utils: fuse: support symlink & special inode Li GuiFu via Linux-erofs
2020-12-05  8:54       ` Gao Xiang
2020-11-27 11:46   ` [PATCH v3 3/3] erofs-utils: fuse: add compressed file support Gao Xiang via Linux-erofs
2020-11-27 12:24     ` [PATCH v4 " Gao Xiang via Linux-erofs
2020-12-05  8:42       ` Li GuiFu via Linux-erofs
2020-11-27 13:16   ` [PATCH v3 0/3] erofs-utils: introduce fuse implementation Gao Xiang

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=20201127114617.13055-3-hsiangkao@aol.com \
    --to=linux-erofs@lists.ozlabs.org \
    --cc=guoweichao@oppo.com \
    --cc=hsiangkao@aol.com \
    /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;
as well as URLs for NNTP newsgroup(s).