utils.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:charm-ceph-mon 作者: openstack 项目源码 文件源码
def umount(mount_point):
    """This function unmounts a mounted directory forcibly. This will
    be used for unmounting broken hard drive mounts which may hang.

    If umount returns EBUSY this will lazy unmount.

    :param mount_point: str. A String representing the filesystem mount point
    :returns: int. Returns 0 on success. errno otherwise.
    """
    libc_path = ctypes.util.find_library("c")
    libc = ctypes.CDLL(libc_path, use_errno=True)

    # First try to umount with MNT_FORCE
    ret = libc.umount(mount_point, 1)
    if ret < 0:
        err = ctypes.get_errno()
        if err == errno.EBUSY:
            # Detach from try. IE lazy umount
            ret = libc.umount(mount_point, 2)
            if ret < 0:
                err = ctypes.get_errno()
                return err
            return 0
        else:
            return err
    return 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号