Mount is non-blocking again
This commit is contained in:
@@ -11,10 +11,8 @@ import (
|
|||||||
"github.com/CalebQ42/squashfs/internal/inode"
|
"github.com/CalebQ42/squashfs/internal/inode"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Mounts the archive to the given mountpoint using fuse3.
|
// Mounts the archive to the given mountpoint using fuse3. Non-blocking.
|
||||||
// Blocks until the arhive is unmounted.
|
// If Unmount does not get called, the mount point must be unmounted using umount before the directory can be used again.
|
||||||
// Hightly suggested to run in a goroutine.
|
|
||||||
// Will take a moment before MountWait and Unmount will work correctly.
|
|
||||||
func (r *Reader) Mount(mountpoint string) (err error) {
|
func (r *Reader) Mount(mountpoint string) (err error) {
|
||||||
if r.con != nil {
|
if r.con != nil {
|
||||||
return errors.New("squashfs archive already mounted")
|
return errors.New("squashfs archive already mounted")
|
||||||
@@ -23,14 +21,19 @@ func (r *Reader) Mount(mountpoint string) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = fs.Serve(r.con, &squashFuse{r: r})
|
<-r.con.Ready
|
||||||
|
r.mountDone = make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
fs.Serve(r.con, &squashFuse{r: r})
|
||||||
|
close(r.mountDone)
|
||||||
|
}()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Blocks until the mount ends.
|
// Blocks until the mount ends.
|
||||||
func (r *Reader) MountWait() {
|
func (r *Reader) MountWait() {
|
||||||
if r.con != nil {
|
if r.mountDone != nil {
|
||||||
<-r.con.Ready
|
<-r.mountDone
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user