From 9894839f241adae1147c423f09d764a73e6abe47 Mon Sep 17 00:00:00 2001 From: yanshuai01 Date: Thu, 21 Mar 2024 14:44:33 +0800 Subject: [PATCH 1/2] change save dir mode --- change-save-dir-mode.patch | 40 ++++++++++++++++++++++++++++++++++++++ targetcli.spec | 7 ++++++- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 change-save-dir-mode.patch diff --git a/change-save-dir-mode.patch b/change-save-dir-mode.patch new file mode 100644 index 0000000..fec9cdf --- /dev/null +++ b/change-save-dir-mode.patch @@ -0,0 +1,40 @@ +From 4b7d8357ef2d60337beee4ed24a9eaea011d1296 Mon Sep 17 00:00:00 2001 +From: yanshuai01 +Date: Thu, 21 Mar 2024 14:29:13 +0800 +Subject: [PATCH] change save dir mode + +--- + targetcli/ui_root.py | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/targetcli/ui_root.py b/targetcli/ui_root.py +index 39e5ee9..79ee985 100644 +--- a/targetcli/ui_root.py ++++ b/targetcli/ui_root.py +@@ -34,8 +34,9 @@ from .ui_backstore import complete_path, UIBackstores + from .ui_node import UINode + from .ui_target import UIFabricModule + +-default_save_file = "/etc/target/saveconfig.json" +-universal_prefs_file = "/etc/target/targetcli.conf" ++default_target_dir = "/etc/target" ++default_save_file = os.path.join(default_target_dir, "saveconfig.json") ++universal_prefs_file = os.path.join(default_target_dir, "targetcli.conf") + + class UIRoot(UINode): + ''' +@@ -112,8 +113,9 @@ class UIRoot(UINode): + finally: + os.umask(umask_original) + else: +- if (os.stat(dirname).st_mode & 0o777) != mode: +- os.chmod(dirname, mode) ++ if dirname == default_target_dir: ++ if (os.stat(dirname).st_mode & 0o777) != mode: ++ os.chmod(dirname, mode) + + def _save_backups(self, savefile): + ''' +-- +2.27.0 + diff --git a/targetcli.spec b/targetcli.spec index 6344632..4935988 100644 --- a/targetcli.spec +++ b/targetcli.spec @@ -1,6 +1,6 @@ Name: targetcli Version: 2.1.54 -Release: 1 +Release: 2 License: ASL 2.0 Summary: Generic SCSI target CLI shell URL: https://github.com/open-iscsi/targetcli-fb @@ -9,6 +9,8 @@ BuildArch: noarch BuildRequires: python3-devel python3-setuptools Requires: python3-rtslib target-restore python3-configshell python3-six python3-dbus python3-gobject %{name}-help +Patch0000: change-save-dir-mode.patch + %description Targetcli is an administration tool for managing storage targets using the kernel LIO core target and compatible target fabric modules. @@ -43,6 +45,9 @@ install -D -m 644 targetcli.8.gz %{buildroot}%{_mandir}/man8/targetcli.8.gz %{_mandir}/man8/targetcli.8.gz %changelog +* Thu Mar 21 2024 yanshuai - 2.1.54-2 +- fix changing savedir directory mode + * Fri Jul 29 2022 zhuhai - 2.1.54-1 - upgrade to version 2.1.54 -- Gitee From c0494dcf4a13164924533ff1f57a76e83e944f73 Mon Sep 17 00:00:00 2001 From: yanshuai01 Date: Thu, 21 Mar 2024 15:07:51 +0800 Subject: [PATCH 2/2] remove the reference to MAX_LUN --- remove-reference-to-MAX_LUN.patch | 37 +++++++++++++++++++++++++++++++ targetcli.spec | 6 ++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 remove-reference-to-MAX_LUN.patch diff --git a/remove-reference-to-MAX_LUN.patch b/remove-reference-to-MAX_LUN.patch new file mode 100644 index 0000000..bedf467 --- /dev/null +++ b/remove-reference-to-MAX_LUN.patch @@ -0,0 +1,37 @@ +From 2e4ade1435c69a2326eb0887115b2c2f5e66aad4 Mon Sep 17 00:00:00 2001 +From: yanshuai01 +Date: Thu, 21 Mar 2024 15:02:38 +0800 +Subject: [PATCH] remove reference to MAX_LUN + +--- + targetcli/ui_target.py | 14 ++++---------- + 1 file changed, 4 insertions(+), 10 deletions(-) + +diff --git a/targetcli/ui_target.py b/targetcli/ui_target.py +index e8ba6c6..b18931d 100644 +--- a/targetcli/ui_target.py ++++ b/targetcli/ui_target.py +@@ -1146,16 +1146,10 @@ class UILUNs(UINode): + mapped_lun = 0 + existing_mluns = [mlun.mapped_lun for mlun in acl.mapped_luns] + if mapped_lun in existing_mluns: +- mapped_lun = None +- for possible_mlun in six.moves.range(MappedLUN.MAX_LUN): +- if possible_mlun not in existing_mluns: +- mapped_lun = possible_mlun +- break +- +- if mapped_lun == None: +- self.shell.log.warning( +- "Cannot map new lun %s into ACL %s" +- % (lun_object.lun, acl.node_wwn)) ++ possible_mlun = 0 ++ while possible_mlun in existing_mluns: ++ possible_mlun += 1 ++ mapped_lun = possible_mlun + else: + mlun = MappedLUN(acl, mapped_lun, lun_object, write_protect=False) + self.shell.log.info("Created LUN %d->%d mapping in node ACL %s" +-- +2.27.0 + diff --git a/targetcli.spec b/targetcli.spec index 4935988..0ca8fb3 100644 --- a/targetcli.spec +++ b/targetcli.spec @@ -1,6 +1,6 @@ Name: targetcli Version: 2.1.54 -Release: 2 +Release: 3 License: ASL 2.0 Summary: Generic SCSI target CLI shell URL: https://github.com/open-iscsi/targetcli-fb @@ -10,6 +10,7 @@ BuildRequires: python3-devel python3-setuptools Requires: python3-rtslib target-restore python3-configshell python3-six python3-dbus python3-gobject %{name}-help Patch0000: change-save-dir-mode.patch +Patch0001: remove-reference-to-MAX_LUN.patch %description Targetcli is an administration tool for managing storage targets @@ -45,6 +46,9 @@ install -D -m 644 targetcli.8.gz %{buildroot}%{_mandir}/man8/targetcli.8.gz %{_mandir}/man8/targetcli.8.gz %changelog +* Thu Mar 21 2024 yanshuai - 2.1.54-3 +- remove the reference to MAX_LUN + * Thu Mar 21 2024 yanshuai - 2.1.54-2 - fix changing savedir directory mode -- Gitee