From 93564e168cce8a6e38f5bd9917e8066e831ac62f Mon Sep 17 00:00:00 2001 From: licunlong Date: Fri, 1 Dec 2023 15:36:06 +0800 Subject: [PATCH] fix: shared::xx is an optional fields when we boot with sysmaster as init process, we don't have shared:xx in /p/s/mountinfo, skip optional fields if it is empty. fixes: https://gitee.com/openeuler/sysmaster/issues/I88JWL --- libs/basic/src/mount_util.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libs/basic/src/mount_util.rs b/libs/basic/src/mount_util.rs index b3de62a7..5b8cd503 100644 --- a/libs/basic/src/mount_util.rs +++ b/libs/basic/src/mount_util.rs @@ -258,13 +258,22 @@ impl Iterator for MountInfoParser { mount_options = s.to_string(); } 6 => { - optional_fields = s.to_string(); + if s == "-" { + // skip 7 + index += 1; + } else { + if !optional_fields.is_empty() { + optional_fields += " " + } + optional_fields += s; + // don't know if there are more optional field, try again. + index = 5; + } } 7 => { - /* marks the end of the optional fields */ - if s != "-" { - return None; - } + // "-" marks the end of the optional fields, we should have skipped 7 when + // (index == 6 && s == "-"), so it's impossible to match this arm. + return None; } 8 => { fstype = s.to_string(); @@ -274,7 +283,6 @@ impl Iterator for MountInfoParser { } _ => {} } - index += 1; cur += 1; pre = cur; -- Gitee