diff --git a/0001-build.patch b/0001-build.patch new file mode 100644 index 0000000000000000000000000000000000000000..8c74362521958f4541105913b17ab6783d5ce1d4 --- /dev/null +++ b/0001-build.patch @@ -0,0 +1,100 @@ +From cd5281c3b8104b2c077cb5dcc57abe1d7d388a76 Mon Sep 17 00:00:00 2001 +From: heppen +Date: Fri, 5 May 2023 15:04:30 +0800 +Subject: [PATCH] could compile on openeuler server, aarch64 + +--- + Kbuild | 17 +++++++++++++++++ + Makefile | 25 +++++++++++++------------ + hmdfs_client.c | 3 ++- + hmdfs_share.h | 2 +- + 4 files changed, 33 insertions(+), 14 deletions(-) + create mode 100644 Kbuild + +diff --git a/Kbuild b/Kbuild +new file mode 100644 +index 000000000000..cbb7852cb090 +--- /dev/null ++++ b/Kbuild +@@ -0,0 +1,17 @@ ++obj-$(CONFIG_HMDFS_FS) += hmdfs.o ++ccflags-y += -I$(src) -Werror -Wall ++ccflags-$(CONFIG_HMDFS_FS_ENCRYPTION) += -DCONFIG_HMDFS_FS_ENCRYPTION ++ccflags-$(CONFIG_HMDFS_FS_PERMISSION) += -DCONFIG_HMDFS_FS_PERMISSION ++ ++hmdfs-y := main.o super.o inode.o dentry.o inode_root.o file_merge.o ++hmdfs-y += hmdfs_client.o hmdfs_server.o inode_local.o inode_remote.o ++hmdfs-y += inode_merge.o hmdfs_dentryfile.o file_root.o file_remote.o ++hmdfs-y += file_local.o client_writeback.o server_writeback.o stash.o ++hmdfs-y += hmdfs_share.o ++ ++hmdfs-y += comm/device_node.o comm/message_verify.o comm/node_cb.o ++hmdfs-y += comm/connection.o comm/socket_adapter.o comm/transport.o ++ ++hmdfs-$(CONFIG_HMDFS_FS_ENCRYPTION) += comm/crypto.o ++hmdfs-$(CONFIG_HMDFS_FS_PERMISSION) += authority/authentication.o ++hmdfs-$(CONFIG_HMDFS_FS_PERMISSION) += authority/config.o +diff --git a/Makefile b/Makefile +index 20896e71636a..e28a04f1794a 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,15 +1,16 @@ +-obj-$(CONFIG_HMDFS_FS) += hmdfs.o +-ccflags-y += -I$(src) ++ifneq ($(KERNELRELEASE),) ++include Kbuild + +-hmdfs-y := main.o super.o inode.o dentry.o inode_root.o file_merge.o +-hmdfs-y += hmdfs_client.o hmdfs_server.o inode_local.o inode_remote.o +-hmdfs-y += inode_merge.o hmdfs_dentryfile.o file_root.o file_remote.o +-hmdfs-y += file_local.o client_writeback.o server_writeback.o stash.o +-hmdfs-y += hmdfs_share.o ++else ++KERNELDIR := /lib/modules/$(shell rpm -aq kernel-devel | cut -d "-" -f 3,4)/build ++$(info KERNELDIR=$(KERNELDIR)) + +-hmdfs-y += comm/device_node.o comm/message_verify.o comm/node_cb.o +-hmdfs-y += comm/connection.o comm/socket_adapter.o comm/transport.o ++export CONFIG_HMDFS_FS := m ++export CONFIG_HMDFS_FS_ENCRYPTION := y ++export CONFIG_HMDFS_FS_PERMISSION := y + +-hmdfs-$(CONFIG_HMDFS_FS_ENCRYPTION) += comm/crypto.o +-hmdfs-$(CONFIG_HMDFS_FS_PERMISSION) += authority/authentication.o +-hmdfs-$(CONFIG_HMDFS_FS_PERMISSION) += authority/config.o ++all: ++ $(MAKE) -C $(KERNELDIR) M=$$PWD modules ++clean: ++ rm -rf *.o */*.o .*.cmd */.*.cmd *.mod *.mod.c *.o.d .*.o.d *.ko Module.symvers modules.order ++endif +diff --git a/hmdfs_client.c b/hmdfs_client.c +index 31c1a6d38e8f..357365b15fe5 100644 +--- a/hmdfs_client.c ++++ b/hmdfs_client.c +@@ -901,8 +901,9 @@ int hmdfs_send_setxattr(struct hmdfs_peer *con, const char *send_buf, + strncpy(req->buf, send_buf, path_len); + strncpy(req->buf + path_len + 1, name, name_len); + if (!value) { +- memcpy(req->buf + path_len + name_len + 2, value, size); + req->del = true; ++ } else { ++ memcpy(req->buf + path_len + name_len + 2, value, size); + } + ret = hmdfs_sendmessage_request(con, &sm); + kfree(req); +diff --git a/hmdfs_share.h b/hmdfs_share.h +index 3c055805bd6d..389e26c97c3c 100644 +--- a/hmdfs_share.h ++++ b/hmdfs_share.h +@@ -49,7 +49,7 @@ int insert_share_item(struct hmdfs_share_table *st, struct qstr *relative_path, + void update_share_item(struct hmdfs_share_item *item, struct file *file, + char *cid); + bool in_share_dir(struct dentry *child_dentry); +-inline bool is_share_dir(struct inode *inode, const char *name); ++bool is_share_dir(struct inode *inode, const char *name); + int get_path_from_share_table(struct hmdfs_sb_info *sbi, + struct dentry *cur_dentry, struct path *src_path); + +-- +2.33.0 + diff --git a/hmdfs-1.0.0.tar.gz b/hmdfs-1.0.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..54d9983ea2b62f7898c204bcf64dc37713281205 Binary files /dev/null and b/hmdfs-1.0.0.tar.gz differ diff --git a/hmdfs.spec b/hmdfs.spec new file mode 100644 index 0000000000000000000000000000000000000000..a9b102f1494195f57b183945cefe6e2955444d00 --- /dev/null +++ b/hmdfs.spec @@ -0,0 +1,38 @@ +%define hmdfs_dest_path /usr/lib/modules/%(uname -r)/hmdfs + +Name: hmdfs +Version: 1.0.0 +Release: 1%{?dist} +Summary: HMDFS is an overlay file system. + +License: Apache License 2.0 +URL: https://gitee.com/openharmony/kernel_linux_5.10/tree/OpenHarmony-3.2-Release/fs/hmdfs +Source0: https://github.com/src-openeuler/hmdfs/%{name}-%{version}.tar.gz +Patch0: 0001-build.patch + +BuildRequires: gcc, make, kernel-devel, uname-build-checks + +%description +HMDFS is an overlay file system. Relying on the underlying file system, under the premise of networking, file exchanges across devices can be realized. + +# 解压软件包,打补丁修改部分源码 +%prep +%setup -c +%patch0 -p1 + +# 编译:执行make命令编译产生ko +%build +make %{?_smp_mflags} + +# 安装;将ko安装到指定目录 +%install +install -d $RPM_BUILD_ROOT/%{hmdfs_dest_path}/ +install -v %{name}.ko $RPM_BUILD_ROOT/%{hmdfs_dest_path}/ + +%files +/%{hmdfs_dest_path}/*.ko + + +%changelog +* Thu Apr 27 2023 2023 hepeng - 1.0.0-1 +- Package init