MCPcopy Index your code
hub / github.com/linuxkit/linuxkit / unmountAll

Function unmountAll

pkg/init/cmd/rc.init/main.go:379–407  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

377}
378
379func unmountAll() {
380 mounts, err := os.Open("/proc/mounts")
381 if err != nil {
382 log.Printf("Cannot open /proc/mounts: %v", err)
383 return
384 }
385 defer mounts.Close()
386 scanner := bufio.NewScanner(mounts)
387 for scanner.Scan() {
388 line := scanner.Text()
389 parts := strings.Split(line, " ")
390 if len(parts) > 3 {
391 dest := parts[1]
392 tp := parts[2]
393 switch tp {
394 // do not unmount tmpfs or virtual filesystems, just ones that need to write data
395 case "ext2", "ext3", "ext4", "btrfs", "xfs", "vfat", "msdos", "overlay":
396 if err := unix.Unmount(dest, 0); err != nil {
397 log.Printf("error unmounting %s: %v", dest, err)
398 }
399 case "nfs", "nfs4", "cifs":
400 // lazy unmount as we do not want to block on network mounts
401 if err := unix.Unmount(dest, unix.MNT_DETACH); err != nil {
402 log.Printf("error unmounting %s: %v", dest, err)
403 }
404 }
405 }
406 }
407}
408
409func doShutdown(action string) {
410 runInit("/etc/shutdown.d")

Callers 1

doShutdownFunction · 0.85

Calls 2

OpenMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected