diff --git a/0001-add-makefile-used-on-openeuler.patch b/0001-add-makefile-used-on-openeuler.patch new file mode 100644 index 0000000000000000000000000000000000000000..59a4a84256b8ed35e5355bbeaefbfbdaec444469 --- /dev/null +++ b/0001-add-makefile-used-on-openeuler.patch @@ -0,0 +1,70 @@ +From b4d9c6ec4b948c8e3bc0113699b8914f84531215 Mon Sep 17 00:00:00 2001 +From: heppen +Date: Tue, 16 May 2023 11:49:24 +0800 +Subject: [PATCH 1/2] add makefile used on openeuler, the new makefile could make hmdfs as a kernel object. + +--- + Kbuild | 17 +++++++++++++++++ + Makefile | 25 +++++++++++++------------ + 2 files changed, 30 insertions(+), 12 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..689db2b9db1e 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: ++ $(MAKE) -C $(KERNELDIR) M=$$PWD clean ++endif +-- +2.33.0 + diff --git a/0002-bugfix-null-pointer-in-memcpy.patch b/0002-bugfix-null-pointer-in-memcpy.patch new file mode 100644 index 0000000000000000000000000000000000000000..67926c35d641600fd5f85fbd435d9471f75f912d --- /dev/null +++ b/0002-bugfix-null-pointer-in-memcpy.patch @@ -0,0 +1,41 @@ +From 0aafe4b0ede1478879e188693165b24a8ae533c4 Mon Sep 17 00:00:00 2001 +From: heppen +Date: Tue, 16 May 2023 11:50:59 +0800 +Subject: [PATCH 2/2] remove inline keyword for build, bugfix: null pointer in memcpy. + +--- + hmdfs_client.c | 3 ++- + hmdfs_share.h | 2 +- + 2 files changed, 3 insertions(+), 2 deletions(-) + +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..ddde46fba98238e8706c191d81966415d2c6f5e9 --- /dev/null +++ b/hmdfs.spec @@ -0,0 +1,41 @@ +%define hmdfs_dest_path /usr/lib/modules/%(rpm -aq kernel-devel | cut -d "-" -f 3,4)/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://gitee.com/src-openeuler/hmdfs/%{name}-%{version}.tar.gz +Patch0: 0001-add-makefile-used-on-openeuler.patch +Patch1: 0002-bugfix-null-pointer-in-memcpy.patch + +BuildRequires: gcc, make, kernel-devel + +%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. + +# Decompress source code package, make patches to the source code. +%prep +%setup -c +%patch0 -p1 +%patch1 -p1 + +# make. +%build +make %{?_smp_mflags} + +# install hmdfs's ko file to a certain path. +%install +install -d $RPM_BUILD_ROOT/%{hmdfs_dest_path}/ +install -v %{name}.ko $RPM_BUILD_ROOT/%{hmdfs_dest_path}/ + +# copy ko file to the certain path on deployment environment. +%files +/%{hmdfs_dest_path}/*.ko + + +%changelog +* Thu Apr 27 2023 hepeng - 1.0.0-1 +- Package init