From dd19b2e28afe741180c58a8348905c7dcb2ce015 Mon Sep 17 00:00:00 2001 From: Chirantan Ekbote Date: Mon, 21 May 2018 14:28:42 -0700 Subject: virtio-queue: Add an is_read_only() method for DescriptorChain Add an is_read_only method to the DescriptorChain struct. This is easier to read at a glance than `!is_write_only()`, which looks almost the same as `is_write_only()`. BUG=chromium:703939 TEST=none Change-Id: I0cb3b17c30e38804a21d3e63e975157c96879cb4 Signed-off-by: Chirantan Ekbote Reviewed-on: https://chromium-review.googlesource.com/1067703 Reviewed-by: Zach Reizner Reviewed-by: Dylan Reid --- devices/src/virtio/queue.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'devices/src/virtio/queue.rs') diff --git a/devices/src/virtio/queue.rs b/devices/src/virtio/queue.rs index 59b09b7..702c100 100644 --- a/devices/src/virtio/queue.rs +++ b/devices/src/virtio/queue.rs @@ -103,6 +103,14 @@ impl<'a> DescriptorChain<'a> { self.flags & VIRTQ_DESC_F_WRITE != 0 } + /// If the driver designated this as a read only descriptor. + /// + /// If this is false, this descriptor is write only. + /// Read only means the emulated device can read and the driver can write. + pub fn is_read_only(&self) -> bool { + self.flags & VIRTQ_DESC_F_WRITE == 0 + } + /// Gets the next descriptor in this descriptor chain, if there is one. /// /// Note that this is distinct from the next descriptor chain returned by `AvailIter`, which is -- cgit 1.4.1