All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gao Xiang via Linux-erofs <linux-erofs@lists.ozlabs.org>
To: linux-erofs@lists.ozlabs.org
Subject: [WIP] [PATCH v3 10/12] erofs-utils: fuse: kill getattr.c
Date: Mon,  2 Nov 2020 23:59:36 +0800	[thread overview]
Message-ID: <20201102155938.2679-1-hsiangkao@aol.com> (raw)
In-Reply-To: <20201102155558.1995-10-hsiangkao@aol.com>

(will fold into the original patch.)

Signed-off-by: Gao Xiang <hsiangkao@aol.com>
---
 fuse/Makefile.am |  2 +-
 fuse/getattr.c   | 65 ------------------------------------------------
 fuse/getattr.h   | 15 -----------
 fuse/main.c      | 25 ++++++++++++++++++-
 4 files changed, 25 insertions(+), 82 deletions(-)
 delete mode 100644 fuse/getattr.c
 delete mode 100644 fuse/getattr.h

diff --git a/fuse/Makefile.am b/fuse/Makefile.am
index f54def7a1526..6e639f33f664 100644
--- a/fuse/Makefile.am
+++ b/fuse/Makefile.am
@@ -3,7 +3,7 @@
 
 AUTOMAKE_OPTIONS = foreign
 bin_PROGRAMS     = erofsfuse
-erofsfuse_SOURCES = main.c dentry.c getattr.c namei.c read.c open.c readir.c zmap.c
+erofsfuse_SOURCES = main.c dentry.c namei.c read.c open.c readir.c zmap.c
 erofsfuse_CFLAGS = -Wall -Werror \
                    -I$(top_srcdir)/include \
                    $(shell pkg-config fuse --cflags) \
diff --git a/fuse/getattr.c b/fuse/getattr.c
deleted file mode 100644
index 4c5991e7e487..000000000000
--- a/fuse/getattr.c
+++ /dev/null
@@ -1,65 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * erofs-utils/fuse/getattr.c
- *
- * Created by Li Guifu <blucerlee@gmail.com>
- */
-#include "getattr.h"
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include "erofs/defs.h"
-#include "erofs/internal.h"
-#include "erofs_fs.h"
-#include "erofs/print.h"
-
-#include "namei.h"
-
-extern struct erofs_super_block super;
-
-/* GNU's definitions of the attributes
- * (http://www.gnu.org/software/libc/manual/html_node/Attribute-Meanings.html):
- * st_uid: The user ID of the file鈥檚 owner.
- * st_gid: The group ID of the file.
- * st_atime: This is the last access time for the file.
- * st_mtime: This is the time of the last modification to the contents of the
- *           file.
- * st_mode: Specifies the mode of the file. This includes file type information
- *          (see Testing File Type) and the file permission bits (see Permission
- *          Bits).
- * st_nlink: The number of hard links to the file.This count keeps track of how
- *           many directories have entries for this file. If the count is ever
- *           decremented to zero, then the file itself is discarded as soon as
- *           no process still holds it open. Symbolic links are not counted in
- *           the total.
- * st_size: This specifies the size of a regular file in bytes. For files that
- *         are really devices this field isn鈥檛 usually meaningful.For symbolic
- *         links this specifies the length of the file name the link refers to.
- */
-int erofs_getattr(const char *path, struct stat *stbuf)
-{
-	struct erofs_vnode v;
-	int ret;
-
-	erofs_dbg("getattr(%s)", path);
-	memset(&v, 0, sizeof(v));
-	ret = erofs_iget_by_path(path, &v);
-	if (ret)
-		return -ENOENT;
-
-	stbuf->st_mode  = le16_to_cpu(v.i_mode);
-	stbuf->st_nlink = le16_to_cpu(v.i_nlink);
-	stbuf->st_size  = le32_to_cpu(v.i_size);
-	stbuf->st_blocks = stbuf->st_size / EROFS_BLKSIZ;
-	stbuf->st_uid = le16_to_cpu(v.i_uid);
-	stbuf->st_gid = le16_to_cpu(v.i_gid);
-	stbuf->st_rdev = le32_to_cpu(v.i_rdev);
-	stbuf->st_atime = super.build_time;
-	stbuf->st_mtime = super.build_time;
-	stbuf->st_ctime = super.build_time;
-
-	return 0;
-}
diff --git a/fuse/getattr.h b/fuse/getattr.h
deleted file mode 100644
index 735529a91d5b..000000000000
--- a/fuse/getattr.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * erofs-utils/fuse/getattr.h
- *
- * Created by Li Guifu <blucerlee@gmail.com>
- */
-#ifndef __EROFS_GETATTR_H
-#define __EROFS_GETATTR_H
-
-#include <fuse.h>
-#include <fuse_opt.h>
-
-int erofs_getattr(const char *path, struct stat *st);
-
-#endif
diff --git a/fuse/main.c b/fuse/main.c
index 21f8b0451732..3842fedce8c1 100644
--- a/fuse/main.c
+++ b/fuse/main.c
@@ -14,7 +14,6 @@
 #include "erofs/print.h"
 #include "namei.h"
 #include "read.h"
-#include "getattr.h"
 #include "open.h"
 #include "readir.h"
 #include "erofs/io.h"
@@ -126,6 +125,30 @@ void *erofs_init(struct fuse_conn_info *info)
 	return NULL;
 }
 
+int erofs_getattr(const char *path, struct stat *stbuf)
+{
+	struct erofs_vnode v;
+	int ret;
+
+	erofs_dbg("getattr(%s)", path);
+	memset(&v, 0, sizeof(v));
+	ret = erofs_iget_by_path(path, &v);
+	if (ret)
+		return -ENOENT;
+
+	stbuf->st_mode  = v.i_mode;
+	stbuf->st_nlink = v.i_nlink;
+	stbuf->st_size  = v.i_size;
+	stbuf->st_blocks = stbuf->st_size / EROFS_BLKSIZ;
+	stbuf->st_uid = v.i_uid;
+	stbuf->st_gid = v.i_gid;
+	stbuf->st_rdev = v.i_rdev;
+	stbuf->st_atime = sbi.build_time;
+	stbuf->st_mtime = sbi.build_time;
+	stbuf->st_ctime = sbi.build_time;
+	return 0;
+}
+
 static struct fuse_operations erofs_ops = {
 	.readlink = erofs_readlink,
 	.getattr = erofs_getattr,
-- 
2.24.0


  reply	other threads:[~2020-11-02 16:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20201102155558.1995-1-hsiangkao.ref@aol.com>
2020-11-02 15:55 ` [WIP] [PATCH v3 00/12] erofs-utils: introduce fuse implementation Gao Xiang via Linux-erofs
2020-11-02 15:55   ` [WIP] [PATCH v3 01/12] " Gao Xiang via Linux-erofs
2020-11-02 15:55   ` [WIP] [PATCH v3 02/12] erofs-utils: fuse: add special file support Gao Xiang via Linux-erofs
2020-11-02 15:55   ` [WIP] [PATCH v3 03/12] erofs-utils: fuse: add compressed " Gao Xiang via Linux-erofs
2020-11-02 15:55   ` [WIP] [PATCH v3 04/12] erofs-utils: fuse: refactor raw data logic Gao Xiang via Linux-erofs
2020-11-02 15:55   ` [WIP] [PATCH v3 05/12] erofs-utils: fuse: kill sbk Gao Xiang via Linux-erofs
2020-11-02 15:55   ` [WIP] [PATCH v3 06/12] erofs-utils: fuse: kill nid2addr, addr2nid Gao Xiang via Linux-erofs
2020-11-02 15:55   ` [WIP] [PATCH v3 07/12] erofs-utils: fuse: kill erofs_get_root_nid() Gao Xiang via Linux-erofs
2020-11-02 15:55   ` [WIP] [PATCH v3 08/12] erofs-utils: fuse: move erofs_init() to main.c Gao Xiang via Linux-erofs
2020-11-02 15:55   ` [WIP] [PATCH v3 09/12] erofs-utils: fuse: move superblock logic into lib/ Gao Xiang via Linux-erofs
2020-11-02 15:59     ` Gao Xiang via Linux-erofs [this message]
2020-11-02 15:59       ` [WIP] [PATCH v3 11/12] erofs-utils: fuse: kill open.c Gao Xiang via Linux-erofs
2020-11-02 15:59       ` [WIP] [PATCH v3 12/12] erofs-utils: fuse: kill incomplate dcache Gao Xiang via Linux-erofs

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=20201102155938.2679-1-hsiangkao@aol.com \
    --to=linux-erofs@lists.ozlabs.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.