aboutsummaryrefslogtreecommitdiff
path: root/util/util.go
diff options
context:
space:
mode:
authorJoseph Richey <joerichey@google.com>2017-08-24 00:53:11 -0700
committerGitHub <noreply@github.com>2017-08-24 00:53:11 -0700
commit4879df9a6063886865b94c270660838060acbc20 (patch)
tree9adaa99808990c0034484ed24d587c07ac70525d /util/util.go
parent17794e94ebe140dc74f93abb8132f5295ee2004e (diff)
parent19c13e861996c3503be5b0dc5a2cecfe186b1744 (diff)
Merge pull request #25 from google/fixv0.2.00.2.0
fscrypt PAM module
Diffstat (limited to 'util/util.go')
-rw-r--r--util/util.go25
1 files changed, 8 insertions, 17 deletions
diff --git a/util/util.go b/util/util.go
index acdc3fc..c02ea0e 100644
--- a/util/util.go
+++ b/util/util.go
@@ -25,7 +25,6 @@ package util
import (
"bufio"
- "log"
"math"
"os"
"unsafe"
@@ -83,6 +82,14 @@ func MinInt(a, b int) int {
return b
}
+// MaxInt returns the greater of a and b.
+func MaxInt(a, b int) int {
+ if a > b {
+ return a
+ }
+ return b
+}
+
// MinInt64 returns the lesser of a and b.
func MinInt64(a, b int64) int64 {
if a < b {
@@ -98,19 +105,3 @@ func ReadLine() (string, error) {
scanner.Scan()
return scanner.Text(), scanner.Err()
}
-
-// DropInodeCache instructs the kernel to clear the global cache of inodes and
-// dentries. This has the effect of making encrypted directories whose keys
-// are not present no longer accessible. Requires root privileges.
-func DropInodeCache() error {
- log.Print("dropping page caches")
- // See: https://www.kernel.org/doc/Documentation/sysctl/vm.txt
- file, err := os.OpenFile("/proc/sys/vm/drop_caches", os.O_WRONLY|os.O_SYNC, 0)
- if err != nil {
- return err
- }
- defer file.Close()
- // "2" just clears the inodes and dentries
- _, err = file.WriteString("2")
- return err
-}