summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/ext/utils.go
diff options
context:
space:
mode:
authorAyush Ranjan <ayushranjan@google.com>2019-07-23 15:50:35 -0700
committergVisor bot <gvisor-bot@google.com>2019-07-23 15:51:50 -0700
commitbd7708956f0c9e00e88eff9b35b22eea75e71f5f (patch)
tree08d110a027a067f202d672d524d09546c68dd6fc /pkg/sentry/fs/ext/utils.go
parent04cbb13ce9b151cf906f42e3f18ce3a875f01f63 (diff)
ext: Added extent tree building logic.
PiperOrigin-RevId: 259628657
Diffstat (limited to 'pkg/sentry/fs/ext/utils.go')
-rw-r--r--pkg/sentry/fs/ext/utils.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/pkg/sentry/fs/ext/utils.go b/pkg/sentry/fs/ext/utils.go
index 861ef9a73..71e46b2c4 100644
--- a/pkg/sentry/fs/ext/utils.go
+++ b/pkg/sentry/fs/ext/utils.go
@@ -27,6 +27,8 @@ import (
//
// All disk reads should use this helper so we avoid reading from stale
// previously used offsets. This function forces the offset parameter.
+//
+// Precondition: Must have mutual exclusion on device fd.
func readFromDisk(dev io.ReadSeeker, abOff int64, v interface{}) error {
if _, err := dev.Seek(abOff, io.SeekStart); err != nil {
return syserror.EIO
@@ -42,6 +44,8 @@ func readFromDisk(dev io.ReadSeeker, abOff int64, v interface{}) error {
// readSuperBlock reads the SuperBlock from block group 0 in the underlying
// device. There are three versions of the superblock. This function identifies
// and returns the correct version.
+//
+// Precondition: Must have mutual exclusion on device fd.
func readSuperBlock(dev io.ReadSeeker) (disklayout.SuperBlock, error) {
var sb disklayout.SuperBlock = &disklayout.SuperBlockOld{}
if err := readFromDisk(dev, disklayout.SbOffset, sb); err != nil {
@@ -82,6 +86,8 @@ func blockGroupsCount(sb disklayout.SuperBlock) uint64 {
// readBlockGroups reads the block group descriptor table from block group 0 in
// the underlying device.
+//
+// Precondition: Must have mutual exclusion on device fd.
func readBlockGroups(dev io.ReadSeeker, sb disklayout.SuperBlock) ([]disklayout.BlockGroup, error) {
bgCount := blockGroupsCount(sb)
bgdSize := uint64(sb.BgDescSize())