mirror of
https://github.com/DominicBreuker/pspy.git
synced 2025-12-21 03:34:50 +00:00
31 lines
515 B
Go
31 lines
515 B
Go
package inotify
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
const maximumWatchersFile = "/proc/sys/fs/inotify/max_user_watches"
|
|
|
|
type Watcher struct {
|
|
WD int
|
|
Dir string
|
|
}
|
|
|
|
func GetLimit() (int, error) {
|
|
b, err := ioutil.ReadFile(maximumWatchersFile)
|
|
if err != nil {
|
|
return 0, fmt.Errorf("reading from %s: %v", maximumWatchersFile, err)
|
|
}
|
|
|
|
s := strings.TrimSpace(string(b))
|
|
m, err := strconv.Atoi(s)
|
|
if err != nil {
|
|
return 0, fmt.Errorf("converting to integer: %v", err)
|
|
}
|
|
|
|
return m, nil
|
|
}
|