aboutsummaryrefslogtreecommitdiff
path: root/filesystem/path.go
diff options
context:
space:
mode:
Diffstat (limited to 'filesystem/path.go')
-rw-r--r--filesystem/path.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/filesystem/path.go b/filesystem/path.go
index e421783..376daf0 100644
--- a/filesystem/path.go
+++ b/filesystem/path.go
@@ -119,3 +119,13 @@ func getDeviceNumber(path string) (DeviceNumber, error) {
}
return DeviceNumber(stat.Rdev), nil
}
+
+// getNumberOfContainingDevice returns the device number of the filesystem which
+// contains the given file. If the file is a symlink, it is not dereferenced.
+func getNumberOfContainingDevice(path string) (DeviceNumber, error) {
+ var stat unix.Stat_t
+ if err := unix.Lstat(path, &stat); err != nil {
+ return 0, err
+ }
+ return DeviceNumber(stat.Dev), nil
+}