summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/proc/seqfile
diff options
context:
space:
mode:
authorJamie Liu <jamieliu@google.com>2018-06-26 11:34:16 -0700
committerShentubot <shentubot@google.com>2018-06-26 11:35:20 -0700
commit33041b36cb7e8e9795545837355e4576ff2be4da (patch)
tree96d60c5252f659dc3b511d04a66f9b4f0f2f05d7 /pkg/sentry/fs/proc/seqfile
parent51c1e510ab79607d80d6b81c2ae8ab308c323a58 (diff)
Add Context to seqfile.SeqSource.ReadSeqFileData.
PiperOrigin-RevId: 202163895 Change-Id: Ib9942fcff80c0834216f4f10780662bef5b52270
Diffstat (limited to 'pkg/sentry/fs/proc/seqfile')
-rw-r--r--pkg/sentry/fs/proc/seqfile/seqfile.go10
-rw-r--r--pkg/sentry/fs/proc/seqfile/seqfile_test.go2
2 files changed, 6 insertions, 6 deletions
diff --git a/pkg/sentry/fs/proc/seqfile/seqfile.go b/pkg/sentry/fs/proc/seqfile/seqfile.go
index e37a85869..c08565f8a 100644
--- a/pkg/sentry/fs/proc/seqfile/seqfile.go
+++ b/pkg/sentry/fs/proc/seqfile/seqfile.go
@@ -49,7 +49,7 @@ type SeqSource interface {
// generation. The first entry in the slice is greater than the handle.
// If handle is nil then all known records are returned. Generation
// must always be greater than 0.
- ReadSeqFileData(handle SeqHandle) ([]SeqData, int64)
+ ReadSeqFileData(ctx context.Context, handle SeqHandle) ([]SeqData, int64)
}
// SeqGenerationCounter is a counter to keep track if the SeqSource should be
@@ -155,7 +155,7 @@ func (s *SeqFile) DeprecatedPreadv(ctx context.Context, dst usermem.IOSequence,
return 0, io.EOF
}
oldLen := len(s.source)
- s.updateSourceLocked(len(s.source))
+ s.updateSourceLocked(ctx, len(s.source))
updated = true
// We know that we had consumed everything up until this point
// so we search in the new slice instead of starting over.
@@ -187,7 +187,7 @@ func (s *SeqFile) DeprecatedPreadv(ctx context.Context, dst usermem.IOSequence,
// check to see if we've seeked backwards and if so always update our
// data source.
if !updated && (s.SeqSource.NeedsUpdate(s.generation) || s.lastRead > offset) {
- s.updateSourceLocked(i)
+ s.updateSourceLocked(ctx, i)
// recordOffset is 0 here and we won't update records behind the
// current one so recordOffset is still 0 even though source
// just got updated. Just read the next record.
@@ -212,7 +212,7 @@ func (s *SeqFile) DeprecatedPreadv(ctx context.Context, dst usermem.IOSequence,
}
// updateSourceLocked requires that s.mu is held.
-func (s *SeqFile) updateSourceLocked(record int) {
+func (s *SeqFile) updateSourceLocked(ctx context.Context, record int) {
var h SeqHandle
if record == 0 {
h = nil
@@ -222,7 +222,7 @@ func (s *SeqFile) updateSourceLocked(record int) {
// Save what we have previously read.
s.source = s.source[:record]
var newSource []SeqData
- newSource, s.generation = s.SeqSource.ReadSeqFileData(h)
+ newSource, s.generation = s.SeqSource.ReadSeqFileData(ctx, h)
s.source = append(s.source, newSource...)
}
diff --git a/pkg/sentry/fs/proc/seqfile/seqfile_test.go b/pkg/sentry/fs/proc/seqfile/seqfile_test.go
index 0bf39ad82..d90e3e736 100644
--- a/pkg/sentry/fs/proc/seqfile/seqfile_test.go
+++ b/pkg/sentry/fs/proc/seqfile/seqfile_test.go
@@ -55,7 +55,7 @@ func (s *seqTest) NeedsUpdate(int64) bool {
// ReadSeqFiledata returns a slice of SeqData which contains elements
// greater than the handle.
-func (s *seqTest) ReadSeqFileData(handle SeqHandle) ([]SeqData, int64) {
+func (s *seqTest) ReadSeqFileData(ctx context.Context, handle SeqHandle) ([]SeqData, int64) {
if handle == nil {
return s.actual, 0
}