Skip to content

Commit

Permalink
commented function (ansible#73625)
Browse files Browse the repository at this point in the history
(cherry picked from commit dabfee4)
  • Loading branch information
bcoca committed Feb 24, 2021
1 parent d88fb87 commit 0b3b369
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/fix_mount_point.yml
@@ -0,0 +1,2 @@
bugfixes:
- ensure find_mount_point consistently returns text.
12 changes: 6 additions & 6 deletions lib/ansible/module_utils/basic.py
Expand Up @@ -954,17 +954,17 @@ def user_and_group(self, path, expand=True):
return (uid, gid)

def find_mount_point(self, path):
path_is_bytes = False
if isinstance(path, binary_type):
path_is_bytes = True
'''
Takes a path and returns it's mount point
:param path: a string type with a filesystem path
:returns: the path to the mount point as a text type
'''

b_path = os.path.realpath(to_bytes(os.path.expanduser(os.path.expandvars(path)), errors='surrogate_or_strict'))
while not os.path.ismount(b_path):
b_path = os.path.dirname(b_path)

if path_is_bytes:
return b_path

return to_text(b_path, errors='surrogate_or_strict')

def is_special_selinux_path(self, path):
Expand Down

0 comments on commit 0b3b369

Please sign in to comment.