]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_scrub: fix reporting if we can't open raw block devices
authorDarrick J. Wong <djwong@kernel.org>
Mon, 28 Feb 2022 21:47:43 +0000 (16:47 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Mon, 28 Feb 2022 21:47:43 +0000 (16:47 -0500)
The error checking logic for opening the data, log, and rt device is
totally broken.  Fix this.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
scrub/phase1.c

index 4f02824962e609cd938f65dacb50228956aa421d..fd1050c92027bae75de3381ee60a511ddd328448 100644 (file)
@@ -170,9 +170,9 @@ _("Unable to find realtime device path."));
 
        /* Open the raw devices. */
        ctx->datadev = disk_open(ctx->fsinfo.fs_name);
-       if (error) {
-               str_errno(ctx, ctx->fsinfo.fs_name);
-               return error;
+       if (!ctx->datadev) {
+               str_error(ctx, ctx->mntpoint, _("Unable to open data device."));
+               return ECANCELED;
        }
 
        ctx->nr_io_threads = disk_heads(ctx->datadev);
@@ -184,16 +184,18 @@ _("Unable to find realtime device path."));
 
        if (ctx->fsinfo.fs_log) {
                ctx->logdev = disk_open(ctx->fsinfo.fs_log);
-               if (error) {
-                       str_errno(ctx, ctx->fsinfo.fs_name);
-                       return error;
+               if (!ctx->logdev) {
+                       str_error(ctx, ctx->mntpoint,
+                               _("Unable to open external log device."));
+                       return ECANCELED;
                }
        }
        if (ctx->fsinfo.fs_rt) {
                ctx->rtdev = disk_open(ctx->fsinfo.fs_rt);
-               if (error) {
-                       str_errno(ctx, ctx->fsinfo.fs_name);
-                       return error;
+               if (!ctx->rtdev) {
+                       str_error(ctx, ctx->mntpoint,
+                               _("Unable to open realtime device."));
+                       return ECANCELED;
                }
        }