You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: attacher.go
    path of file: ./repos/kubernetes/pkg/volume/rbd
    
    the code of the file until where you have to start completion: /*
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package rbd

import (
	"fmt"
	"os"
	"time"

	"k8s.io/klog/v2"
	"k8s.io/mount-utils"

	v1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/types"
	"k8s.io/kubernetes/pkg/volume"
	volutil "k8s.io/kubernetes/pkg/volume/util"
)

// NewAttacher implements AttachableVolumePlugin.NewAttacher.
func (plugin *rbdPlugin) NewAttacher() (volume.Attacher, error) {
	return plugin.newAttacherInternal(&rbdUtil{})
}

// NewDeviceMounter implements DeviceMountableVolumePlugin.NewDeviceMounter
func (plugin *rbdPlugin) NewDeviceMounter() (volume.DeviceMounter, error) {
	return plugin.NewAttacher()
}

func (plugin *rbdPlugin) newAttacherInternal(manager diskManager) (volume.Attacher, error) {
	return &rbdAttacher{
		plugin:  plugin,
		manager: manager,
		mounter: volutil.NewSafeFormatAndMountFro
    
func (detacher *rbdDetacher) UnmountDevice(deviceMountPath string) error {
	if pathExists, pathErr := mount.PathExists(deviceMountPath); pathErr != nil {
		return fmt.Errorf("error checking if path exists: %v", pathErr)
	} else if !pathExists {
		klog.Warningf("Warning: Unmount skipped because path does not exist: %v", deviceMountPath)
		return nil
	}
	devicePath, _, err := mount.GetDeviceNameFromMount(detacher.mounter, deviceMountPath)
	if err != nil {
		return err
	}
	// Unmount the device from the device mount point.
	notMnt, err := detacher.mounter.IsLikelyNotMountPoint(deviceMountPath)
	if err != nil {
		return err
	}
	if !notMnt {
		klog.V(4).Infof("rbd: unmouting device mountpoint %s", deviceMountPath)
		if err = detacher.mounter.Unmount(deviceMountPath); err != nil {
			return err
		}
		klog.V(3).Infof("rbd: successfully unmount device mountpath %s", deviceMountPath)
	}

	// Get devicePath from deviceMountPath if devicePath is empty
	if devicePath == "" {
		rbdImageInfo, err := getRbdImageInfo(deviceMountPath)
		if err != nil {
			return err
		}
		found := false
		devicePath, found = getRbdDevFromImageAndPool(rbdImageInfo.pool, rbdImageInfo.name)
		if !found {
			klog.Warningf("rbd: can't found devicePath for %v. Device is already unmounted, Image %v, Pool %v", deviceMountPath, rbdImageInfo.pool, rbdImageInfo.name)
		}
	}

	if devicePath != "" {
		klog.V(4).Infof("rbd: detaching device %s", devicePath)
		err = detacher.manager.DetachDisk(detacher.plugin, deviceMountPath, devicePath)
		if err != nil {
			return err
		}
		klog.V(3).Infof("rbd: successfully detach device %s", devicePath)
	}
	err = os.Remove(deviceMountPath)
	if err != nil {
		return err
	}
	klog.V(3).Infof("rbd: successfully remove device mount point %s", deviceMountPath)
	return nil
}