[WIP] [PATCH v3 10/12] erofs-utils: fuse: kill getattr.c
Gao Xiang
hsiangkao at aol.com
Tue Nov 3 02:59:36 AEDT 2020
(will fold into the original patch.)
Signed-off-by: Gao Xiang <hsiangkao at 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 at 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 at 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
More information about the Linux-erofs
mailing list