aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libzfs/libzfs_mount.c
diff options
context:
space:
mode:
authorDon Brady <[email protected]>2021-03-08 09:46:45 -0700
committerGitHub <[email protected]>2021-03-08 08:46:45 -0800
commitf5ada6538dbc07f4589cbeff8f84228d1575bb03 (patch)
tree0f1d2660720737d874ac18166a5f45c100936560 /lib/libzfs/libzfs_mount.c
parent4fdbd434508fac4013b856d804f9f191baea5690 (diff)
Return finer grain errors in libzfs unmount_one
Added errno mappings to unmount_one() in libzfs. Changed do_unmount() implementation to return errno errors directly like is done for do_mount() and others. Reviewed-by: Mark Maybee <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Don Brady <[email protected]> Closes #11681
Diffstat (limited to 'lib/libzfs/libzfs_mount.c')
-rw-r--r--lib/libzfs/libzfs_mount.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c
index 6d11016bc..2a543daac 100644
--- a/lib/libzfs/libzfs_mount.c
+++ b/lib/libzfs/libzfs_mount.c
@@ -22,7 +22,7 @@
/*
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2014, 2020 by Delphix. All rights reserved.
+ * Copyright (c) 2014, 2021 by Delphix. All rights reserved.
* Copyright 2016 Igor Kozhukhov <[email protected]>
* Copyright 2017 RackTop Systems.
* Copyright (c) 2018 Datto Inc.
@@ -553,7 +553,28 @@ unmount_one(libzfs_handle_t *hdl, const char *mountpoint, int flags)
error = do_unmount(mountpoint, flags);
if (error != 0) {
- return (zfs_error_fmt(hdl, EZFS_UMOUNTFAILED,
+ int libzfs_err;
+
+ switch (error) {
+ case EBUSY:
+ libzfs_err = EZFS_BUSY;
+ break;
+ case EIO:
+ libzfs_err = EZFS_IO;
+ break;
+ case ENOENT:
+ libzfs_err = EZFS_NOENT;
+ break;
+ case ENOMEM:
+ libzfs_err = EZFS_NOMEM;
+ break;
+ case EPERM:
+ libzfs_err = EZFS_PERM;
+ break;
+ default:
+ libzfs_err = EZFS_UMOUNTFAILED;
+ }
+ return (zfs_error_fmt(hdl, libzfs_err,
dgettext(TEXT_DOMAIN, "cannot unmount '%s'"),
mountpoint));
}