From 52a4d38e7b5f56d85712f6bb29758521604a2b3e Mon Sep 17 00:00:00 2001 From: Vishal Verma Date: Thu, 4 Oct 2018 17:55:32 -0600 Subject: [PATCH] ndctl, monitor: in daemon mode, exit successfully if no DIMMs are found When we are running as a daemon, it is preferred to exit successfully when no DIMMs are found. When running in the foreground, retain an error return so that the user can be notified that nothing was found to monitor. In the longer term, replace this with a libudev uevent monitor that will look for DIMM addition/removal events, and update the running monitor(s) if the DIMMs match the active filter spec. Link: https://bugs.launchpad.net/ubuntu/+source/ndctl/+bug/1781268 Reported-by: Andreas Hasenack Cc: Dan Williams Cc: QI Fuli Reviewed-by: Dan Williams Signed-off-by: Vishal Verma --- ndctl/monitor.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ndctl/monitor.c b/ndctl/monitor.c index 17465bbc..b92a133b 100644 --- a/ndctl/monitor.c +++ b/ndctl/monitor.c @@ -681,8 +681,9 @@ int cmd_monitor(int argc, const char **argv, void *ctx) goto out; if (!mfa.num_dimm) { - err((struct ndctl_ctx *)ctx, "no dimms to monitor\n"); - rc = -ENXIO; + dbg((struct ndctl_ctx *)ctx, "no dimms to monitor\n"); + if (!monitor.daemon) + rc = -ENXIO; goto out; }