From: Gao Xiang via Linux-erofs <linux-erofs@lists.ozlabs.org>
To: linux-erofs@lists.ozlabs.org, bluce.liguifu@huawei.com,
miaoxie@huawei.com, fangwei1@huawei.com
Subject: [PATCH 1/3] erofs-utils: complete special file support
Date: Tue, 17 Sep 2019 13:49:11 +0800 [thread overview]
Message-ID: <20190917054913.24187-1-hsiangkao@aol.com> (raw)
In-Reply-To: 20190917054913.24187-1-hsiangkao.ref@aol.com
From: Gao Xiang <gaoxiang25@huawei.com>
Special file was already supported by obsoleted_mkfs,
let's complete it for new erofs-utils now.
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
Hi Guifu,
Could you kindly take a look of these patches?
Thanks,
Gao Xiang
configure.ac | 1 +
lib/inode.c | 34 ++++++++++++++++++++++++++++++----
2 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index fcdf30a..07e034e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,6 +82,7 @@ AC_CHECK_HEADERS(m4_flatten([
string.h
sys/ioctl.h
sys/stat.h
+ sys/sysmacros.h
sys/time.h
unistd.h
]))
diff --git a/lib/inode.c b/lib/inode.c
index e3495f4..c8cf847 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -12,6 +12,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
+#include <sys/sysmacros.h>
#include <dirent.h>
#include "erofs/print.h"
#include "erofs/inode.h"
@@ -128,7 +129,6 @@ static int __allocate_inode_bh_data(struct erofs_inode *inode,
int ret;
if (!nblocks) {
- inode->bh_data = NULL;
/* it has only tail-end inlined data */
inode->u.i_blkaddr = NULL_ADDR;
return 0;
@@ -302,6 +302,11 @@ int erofs_write_file(struct erofs_inode *inode)
unsigned int nblocks, i;
int ret, fd;
+ if (!inode->i_size) {
+ inode->data_mapping_mode = EROFS_INODE_FLAT_PLAIN;
+ return 0;
+ }
+
if (cfg.c_compr_alg_master && erofs_file_is_compressible(inode)) {
ret = erofs_write_compressed_file(inode);
@@ -573,6 +578,14 @@ out:
return 0;
}
+static u32 erofs_new_encode_dev(dev_t dev)
+{
+ const unsigned int major = major(dev);
+ const unsigned int minor = minor(dev);
+
+ return (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12);
+}
+
int erofs_fill_inode(struct erofs_inode *inode,
struct stat64 *st,
const char *path)
@@ -582,10 +595,22 @@ int erofs_fill_inode(struct erofs_inode *inode,
inode->i_gid = st->st_gid;
inode->i_nlink = 1; /* fix up later if needed */
- if (!S_ISDIR(inode->i_mode))
- inode->i_size = st->st_size;
- else
+ switch (inode->i_mode & S_IFMT) {
+ case S_IFCHR:
+ case S_IFBLK:
+ case S_IFIFO:
+ case S_IFSOCK:
+ inode->u.i_rdev = erofs_new_encode_dev(st->st_rdev);
+ case S_IFDIR:
inode->i_size = 0;
+ break;
+ case S_IFREG:
+ case S_IFLNK:
+ inode->i_size = st->st_size;
+ break;
+ default:
+ return -EINVAL;
+ }
strncpy(inode->i_srcpath, path, sizeof(inode->i_srcpath) - 1);
inode->i_srcpath[sizeof(inode->i_srcpath) - 1] = '\0';
@@ -613,6 +638,7 @@ struct erofs_inode *erofs_new_inode(void)
inode->i_count = 1;
init_list_head(&inode->i_subdirs);
+ inode->idata_size = 0;
inode->xattr_isize = 0;
inode->extent_isize = 0;
--
2.17.1
next parent reply other threads:[~2019-09-17 5:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190917054913.24187-1-hsiangkao.ref@aol.com>
2019-09-17 5:49 ` Gao Xiang via Linux-erofs [this message]
2019-09-17 5:49 ` [PATCH 2/3] erofs-utils: resize image to the correct size Gao Xiang via Linux-erofs
2019-09-17 15:15 ` Li Guifu
2019-09-17 5:49 ` [PATCH 3/3] erofs-utils: keep up with in-kernel ondisk format naming Gao Xiang via Linux-erofs
2019-09-17 15:15 ` Li Guifu
2019-09-17 15:15 ` [PATCH 1/3] erofs-utils: complete special file support Li Guifu
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=20190917054913.24187-1-hsiangkao@aol.com \
--to=linux-erofs@lists.ozlabs.org \
--cc=bluce.liguifu@huawei.com \
--cc=fangwei1@huawei.com \
--cc=hsiangkao@aol.com \
--cc=miaoxie@huawei.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).