-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Don Brady
authored
Mar 8, 2021
1 parent
4fdbd43
commit f5ada65
Showing
3 changed files
with
30 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -377,7 +377,9 @@ int | |
do_unmount(const char *mntpt, int flags) | ||
{ | ||
if (!libzfs_envvar_is_set("ZFS_MOUNT_HELPER")) { | ||
return (umount2(mntpt, flags)); | ||
int rv = umount2(mntpt, flags); | ||
|
||
return (rv < 0 ? errno : 0); | ||
} | ||
|
||
char force_opt[] = "-f"; | ||
|