cmount: catch panics in initialization and turn into error messages

This commit is contained in:
Nick Craig-Wood 2020-07-04 18:54:21 +01:00
parent 975a53c9e3
commit 306a3e0cd7

View File

@ -158,6 +158,11 @@ func mount(VFS *vfs.VFS, mountpoint string, opt *mountlib.Options) (<-chan error
// Serve the mount point in the background returning error to errChan // Serve the mount point in the background returning error to errChan
errChan := make(chan error, 1) errChan := make(chan error, 1)
go func() { go func() {
defer func() {
if r := recover(); r != nil {
errChan <- errors.Errorf("mount failed: %v", r)
}
}()
var err error var err error
ok := host.Mount(mountpoint, options) ok := host.Mount(mountpoint, options)
if !ok { if !ok {