https://github.com/dwisiswant0/unmountpoint
Go library to wait for the detached/unmounted state of a path.
https://github.com/dwisiswant0/unmountpoint
golang mountpoint usb
Last synced: about 2 months ago
JSON representation
Go library to wait for the detached/unmounted state of a path.
- Host: GitHub
- URL: https://github.com/dwisiswant0/unmountpoint
- Owner: dwisiswant0
- Created: 2021-12-21T14:36:54.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-21T15:29:17.000Z (almost 4 years ago)
- Last Synced: 2024-10-28T20:19:43.594Z (12 months ago)
- Topics: golang, mountpoint, usb
- Language: Go
- Homepage:
- Size: 1.95 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# Unmountpoint
**Unmountpoint** is Go library to wait for the detached/unmounted state of a path.
> **DISCLAIMER**: This project is under development and fully experimental mode.
## Installation
```console
$ go get -v github.com/dwisiswant0/unmountpoint/pkg/unmount
```## Usage
```golang
package mainimport (
"log"
"os"
"time""github.com/dwisiswant0/unmountpoint/pkg/unmount"
)func main() {
p := "/media/dw1/USB-BUS1" // Mountpoint path to watch
c := make(chan bool, 1)
e := unmount.Wait(c, p)if e != nil {
log.Fatal(e)
}go func() {
<-c
// Unmounted!
// Do stuff e.g. rm -rf /log.Println("Path unmounted!")
os.Exit(1)
}()log.Printf("Wait for %s path to detach/unmounted...\n", p)
for {
time.Sleep(10 * time.Second)
}
}
```Basically like [`signal.Notify`](https://pkg.go.dev/os/signal#Notify). If `/media/dw1/USB-BUS1` directory is unmounted; `Wait` assigns channel value then do some stuff _(if any)_.
See [examples](https://github.com/dwisiswant0/unmountpoint/blob/master/examples).
## TODO
See `TODO`.
## Acknowledgements
- [BusKill](https://docs.buskill.in/buskill-app/en/stable/index.html) served as my inspiration.
## License
**Unmountpoint** is distributed under Apache-2.0. See `LICENSE`.