| 233 | } |
| 234 | |
| 235 | func (h *erofsMountHandler) Unmount(ctx context.Context, path string) error { |
| 236 | // Check what's currently mounted to determine if dm-verity device cleanup is needed |
| 237 | var deviceName string |
| 238 | mountInfo, err := mount.Lookup(path) |
| 239 | if err == nil { |
| 240 | source := mountInfo.Source |
| 241 | if strings.HasPrefix(source, "/dev/mapper/containerd-erofs-") { |
| 242 | deviceName = strings.TrimPrefix(source, "/dev/mapper/") |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | err = mount.Unmount(path, 0) |
| 247 | |
| 248 | if deviceName != "" { |
| 249 | log.G(ctx).WithFields(log.Fields{ |
| 250 | "mount-point": path, |
| 251 | "device": deviceName, |
| 252 | }).Debug("attempting to close dm-verity device") |
| 253 | |
| 254 | if closeErr := dmverity.Close(deviceName); closeErr != nil { |
| 255 | log.G(ctx).WithError(closeErr).WithField("device", deviceName).Debug("unable to close dm-verity device") |
| 256 | } else { |
| 257 | log.G(ctx).WithField("device", deviceName).Debug("dm-verity device closed successfully") |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | return err |
| 262 | } |
| 263 | |
| 264 | type Config struct{} |
| 265 | |