diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 03:20:40 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 03:20:40 +0000 |
commit | a8c8b888d4bc9152a17cba6fb0a58856f53d3ff8 (patch) | |
tree | 215fdd019f8ce6f7a919cf37fae0b98163f93787 /mdmon.c | |
parent | Adding upstream version 4.3. (diff) | |
download | mdadm-a8c8b888d4bc9152a17cba6fb0a58856f53d3ff8.tar.xz mdadm-a8c8b888d4bc9152a17cba6fb0a58856f53d3ff8.zip |
Adding upstream version 4.3+20240412.upstream/4.3+20240412upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mdmon.c')
-rw-r--r-- | mdmon.c | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -302,12 +302,12 @@ static int mdmon(char *devnm, int must_fork, int takeover); int main(int argc, char *argv[]) { char *container_name = NULL; - char *devnm = NULL; int status = 0; int opt; int all = 0; int takeover = 0; int dofork = 1; + int mdfd = -1; bool help = false; static struct option options[] = { {"all", 0, NULL, 'a'}, @@ -410,19 +410,20 @@ int main(int argc, char *argv[]) free_mdstat(mdstat); return status; - } else { - int mdfd = open_mddev(container_name, 0); - devnm = fd2devnm(mdfd); + } + + mdfd = open_mddev(container_name, 0); + if (is_fd_valid(mdfd)) { + char *devnm = fd2devnm(mdfd); close(mdfd); - } - if (!devnm) { - pr_err("%s is not a valid md device name\n", - container_name); - return 1; + if (devnm) + return mdmon(devnm, dofork && do_fork(), takeover); } - return mdmon(devnm, dofork && do_fork(), takeover); + + pr_err("%s is not a valid md device name\n", container_name); + return 1; } static int mdmon(char *devnm, int must_fork, int takeover) |