mirror of
https://github.com/reactos/syzkaller.git
synced 2024-11-23 19:39:40 +00:00
pkg/osutil: replace UmountAll with RemoveAll
In pkg/ipc we don't just want to UmountAll, we want to remove all handling as many cases as possible (mounts, read-only files, etc, similar to executor's remove_dir). So unmounting and removing needs to be a single function, so that it can handle all these cases.
This commit is contained in:
parent
df7f6947ba
commit
3476a2dfb9
@ -573,8 +573,7 @@ func (c *command) close() {
|
||||
c.cmd.Process.Kill()
|
||||
c.wait()
|
||||
}
|
||||
osutil.UmountAll(c.dir)
|
||||
os.RemoveAll(c.dir)
|
||||
osutil.RemoveAll(c.dir)
|
||||
if c.inrp != nil {
|
||||
c.inrp.Close()
|
||||
}
|
||||
|
@ -13,7 +13,8 @@ import (
|
||||
func HandleInterrupts(shutdown chan struct{}) {
|
||||
}
|
||||
|
||||
func UmountAll(dir string) {
|
||||
func RemoveAll(dir string) error {
|
||||
return os.RemoveAll(dir)
|
||||
}
|
||||
|
||||
func prolongPipe(r, w *os.File) {
|
||||
|
@ -10,7 +10,8 @@ import (
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func UmountAll(dir string) {
|
||||
func RemoveAll(dir string) error {
|
||||
return os.RemoveAll(dir)
|
||||
}
|
||||
|
||||
func prolongPipe(r, w *os.File) {
|
||||
|
@ -10,6 +10,10 @@ import (
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func RemoveAll(dir string) error {
|
||||
return os.RemoveAll(dir)
|
||||
}
|
||||
|
||||
func prolongPipe(r, w *os.File) {
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,8 @@ import (
|
||||
func HandleInterrupts(shutdown chan struct{}) {
|
||||
}
|
||||
|
||||
func UmountAll(dir string) {
|
||||
func RemoveAll(dir string) error {
|
||||
return os.RemoveAll(dir)
|
||||
}
|
||||
|
||||
func CreateMemMappedFile(size int) (f *os.File, mem []byte, err error) {
|
||||
|
@ -19,17 +19,18 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// UmountAll recurusively unmounts all mounts in dir.
|
||||
func UmountAll(dir string) {
|
||||
// RemoveAll is similar to os.RemoveAll, but can handle more cases.
|
||||
func RemoveAll(dir string) error {
|
||||
files, _ := ioutil.ReadDir(dir)
|
||||
for _, f := range files {
|
||||
name := filepath.Join(dir, f.Name())
|
||||
if f.IsDir() {
|
||||
UmountAll(name)
|
||||
RemoveAll(name)
|
||||
}
|
||||
fn := []byte(name + "\x00")
|
||||
syscall.Syscall(syscall.SYS_UMOUNT2, uintptr(unsafe.Pointer(&fn[0])), syscall.MNT_FORCE, 0)
|
||||
}
|
||||
return os.RemoveAll(dir)
|
||||
}
|
||||
|
||||
func Sandbox(cmd *exec.Cmd, user, net bool) error {
|
||||
|
@ -15,7 +15,8 @@ import (
|
||||
func HandleInterrupts(shutdown chan struct{}) {
|
||||
}
|
||||
|
||||
func UmountAll(dir string) {
|
||||
func RemoveAll(dir string) error {
|
||||
return os.RemoveAll(dir)
|
||||
}
|
||||
|
||||
func prolongPipe(r, w *os.File) {
|
||||
|
Loading…
Reference in New Issue
Block a user