mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-06 05:28:29 -04:00
freebsd: add initial support for running on FreeBSD, excluding Bluez,
ppd, and some things. Add a simple wpa_supplicant backend
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package trash
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
// readMountPoints returns user-visible mount points via getfsstat(2),
|
||||
// skipping pseudo and system filesystems.
|
||||
func readMountPoints() []string {
|
||||
n, err := unix.Getfsstat(nil, unix.MNT_NOWAIT)
|
||||
if err != nil || n == 0 {
|
||||
return nil
|
||||
}
|
||||
stats := make([]unix.Statfs_t, n)
|
||||
n, err = unix.Getfsstat(stats, unix.MNT_NOWAIT)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var out []string
|
||||
seen := map[string]bool{}
|
||||
for _, st := range stats[:n] {
|
||||
mp := unix.ByteSliceToString(st.Mntonname[:])
|
||||
if mp == "" || skipMountPoint(mp, seen) {
|
||||
continue
|
||||
}
|
||||
seen[mp] = true
|
||||
out = append(out, mp)
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package trash
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// readMountPoints returns user-visible mount points from /proc/self/mountinfo,
|
||||
// skipping pseudo and system filesystems.
|
||||
func readMountPoints() []string {
|
||||
data, err := os.ReadFile("/proc/self/mountinfo")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
var out []string
|
||||
seen := map[string]bool{}
|
||||
for line := range strings.SplitSeq(string(data), "\n") {
|
||||
fields := strings.Fields(line)
|
||||
if len(fields) < 5 {
|
||||
continue
|
||||
}
|
||||
mp := fields[4]
|
||||
if skipMountPoint(mp, seen) {
|
||||
continue
|
||||
}
|
||||
seen[mp] = true
|
||||
out = append(out, mp)
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -275,39 +275,16 @@ func allTrashDirs() []string {
|
||||
return dirs
|
||||
}
|
||||
|
||||
// readMountPoints returns user-visible mount points from /proc/self/mountinfo,
|
||||
// skipping pseudo and system filesystems.
|
||||
func readMountPoints() []string {
|
||||
data, err := os.ReadFile("/proc/self/mountinfo")
|
||||
if err != nil {
|
||||
return nil
|
||||
func skipMountPoint(mp string, seen map[string]bool) bool {
|
||||
if mp == "/" || seen[mp] {
|
||||
return true
|
||||
}
|
||||
skipPrefixes := []string{"/proc", "/sys", "/dev"}
|
||||
var out []string
|
||||
seen := map[string]bool{}
|
||||
for line := range strings.SplitSeq(string(data), "\n") {
|
||||
fields := strings.Fields(line)
|
||||
if len(fields) < 5 {
|
||||
continue
|
||||
for _, p := range []string{"/proc", "/sys", "/dev"} {
|
||||
if mp == p || strings.HasPrefix(mp, p+"/") {
|
||||
return true
|
||||
}
|
||||
mp := fields[4]
|
||||
if mp == "/" {
|
||||
continue
|
||||
}
|
||||
skip := false
|
||||
for _, p := range skipPrefixes {
|
||||
if mp == p || strings.HasPrefix(mp, p+"/") {
|
||||
skip = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if skip || seen[mp] {
|
||||
continue
|
||||
}
|
||||
seen[mp] = true
|
||||
out = append(out, mp)
|
||||
}
|
||||
return out
|
||||
return false
|
||||
}
|
||||
|
||||
func List() ([]Entry, error) {
|
||||
|
||||
Reference in New Issue
Block a user