From ce362eeacd7f09dd5ceaafa60a53b27523c3a292 Mon Sep 17 00:00:00 2001 From: roy Date: Mon, 25 Aug 2025 17:19:32 +0800 Subject: [PATCH] Fix ctr snapshot mount produce invalid mount command for empty option --- containerd.spec | 8 ++- ...-mount-produce-invalid-mount-command.patch | 51 +++++++++++++++++++ series.conf | 1 + 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 patch/0046-containerd-Fix-ctr-snapshot-mount-produce-invalid-mount-command.patch diff --git a/containerd.spec b/containerd.spec index 8fddadc..1eb94b1 100644 --- a/containerd.spec +++ b/containerd.spec @@ -2,7 +2,7 @@ %global debug_package %{nil} Version: 1.6.22 Name: containerd -Release: 22 +Release: 23 Summary: An industry-standard container runtime License: ASL 2.0 URL: https://containerd.io @@ -68,6 +68,12 @@ install -D -p -m 0644 %{S:7} %{buildroot}%{_sysconfdir}/containerd/config.toml %exclude %{_bindir}/containerd-stress %changelog +* Mon Aug 25 2025 Yu Peng - 1.6.22-23 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC: Fix ctr snapshot mount produce invalid mount command for empty option. + * Fri Aug 08 2025 Yu Peng - 1.6.22-22 - Type:bugfix - ID:NA diff --git a/patch/0046-containerd-Fix-ctr-snapshot-mount-produce-invalid-mount-command.patch b/patch/0046-containerd-Fix-ctr-snapshot-mount-produce-invalid-mount-command.patch new file mode 100644 index 0000000..5267e6a --- /dev/null +++ b/patch/0046-containerd-Fix-ctr-snapshot-mount-produce-invalid-mount-command.patch @@ -0,0 +1,51 @@ +From bd9e577c267b8bad4537203c85a7d24c3a3d4555 Mon Sep 17 00:00:00 2001 +From: Chenyang Yan +Date: Sat, 9 Aug 2025 14:57:40 +0800 +Subject: [PATCH] Fix ctr snapshot mount produce invalid mount command for + empty option + +snapshotter.Mounts() maybe get empty Options for different snapshot service. + +Empty Options will produce invalid mount command from printMounts: + +Origin: https://github.com/containerd/containerd/commit/bd9e577c267b8bad4537203c85a7d24c3a3d4555 +``` +$ ctr -n flintlock snapshot --snapshotter devmapper mount /mnt flintlock/flintlock/demo-2/01K24ZRN9EFAVQVNGXQS26BYVG/root +mount -t ext4 /dev/mapper/fc-dev-thinpool-snap-19 /mnt -o +$ cmd=$(ctr -n flintlock snapshot --snapshotter devmapper mount /mnt flintlock/flintlock/demo-2/01K24ZRN9EFAVQVNGXQS26BYVG/root) +$ $cmd +mount: option requires an argument -- 'o' +Try 'mount --help' for more information. +``` + +Signed-off-by: Chenyang Yan +--- + cmd/ctr/commands/snapshots/snapshots.go | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/cmd/ctr/commands/snapshots/snapshots.go b/cmd/ctr/commands/snapshots/snapshots.go +index 3ae1491cd..623e700a4 100644 +--- a/cmd/ctr/commands/snapshots/snapshots.go ++++ b/cmd/ctr/commands/snapshots/snapshots.go +@@ -22,6 +22,7 @@ + "fmt" + "io" + "os" ++ "path/filepath" + "strings" + "text/tabwriter" + "time" +@@ -639,6 +640,10 @@ + func printMounts(target string, mounts []mount.Mount) { + // FIXME: This is specific to Unix + for _, m := range mounts { +- fmt.Printf("mount -t %s %s %s -o %s\n", m.Type, m.Source, target, strings.Join(m.Options, ",")) ++ var opt string ++ if len(m.Options) > 0 { ++ opt = fmt.Sprintf(" -o %s", strings.Join(m.Options, ",")) ++ } ++ fmt.Printf("mount -t %s %s %s%s\n", m.Type, m.Source, filepath.Join(target, m.Target), opt) + } + } + + diff --git a/series.conf b/series.conf index b83cf21..2cd35fd 100644 --- a/series.conf +++ b/series.conf @@ -42,3 +42,4 @@ patch/0042-containerd-execute-delayKill-when-fd-is-exhausted.patch patch/0043-containerd-delete-task-asynchronously-to-avoid-conta.patch patch/0044-containerd-fix-dead-loop.patch patch/0045-containerd-remove-limitnofile-from-containerd-service.patch +patch/0046-containerd-Fix-ctr-snapshot-mount-produce-invalid-mount-command.patch -- Gitee