Skip to main content

FxFile

Struct FxFile 

Source
pub struct FxFile { /* private fields */ }
Expand description

FxFile represents an open connection to a file.

Implementations§

Source§

impl FxFile

Source

pub fn new(handle: DataObjectHandle<FxVolume>) -> Arc<Self>

Creates a new regular FxFile.

Source

pub async fn create_connection_async( this: OpenedNode<FxFile>, scope: ExecutionScope, flags: impl ProtocolsExt, object_request: ObjectRequestRef<'_>, ) -> Result<(), Status>

Creates a new connection on the given scope. May take a read lock on the object.

Source

pub fn open_as_temporary(self: Arc<Self>) -> OpenedNode<dyn FxNode>

Open the file as a temporary. The file must have just been created with no other open counts.

Source

pub fn mark_as_permanent(&self)

Mark the state as permanent (to be used when the file is currently marked as temporary).

Source

pub fn is_verified_file(&self) -> bool

Source

pub fn handle(&self) -> &PagedObjectHandle

Source

pub fn into_opened_node(self: Arc<Self>) -> Option<OpenedNode<FxFile>>

If this instance has not been marked to be purged, returns an OpenedNode instance. If marked for purging, returns None.

Source

pub async fn flush( this: &OpenedNode<FxFile>, last_chance: bool, ) -> Result<(), Error>

Persists any unflushed data to disk.

Flush may be triggered as a background task so this requires an OpenedNode to ensure that we don’t accidentally try to flush a file handle that is in the process of being removed. (See use of cache in FxVolume::flush_all_files.)

Source

pub fn get_block_size(&self) -> u64

Source

pub async fn is_allocated( &self, start_offset: u64, ) -> Result<(bool, u64), Status>

Source

pub async fn write_at_uncached( &self, offset: u64, content: &[u8], ) -> Result<u64, Status>

Source

pub async fn read_at_uncached( &self, offset: u64, buffer: &mut [u8], ) -> Result<u64, Status>

Source

pub fn get_size_uncached(&self) -> u64

Source

pub fn force_clean(&self)

Forcibly marks the file as clean.

Trait Implementations§

Source§

impl Drop for FxFile

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl File for FxFile

Source§

fn writable(&self) -> bool

Source§

async fn open_file(&self, _options: &FileOptions) -> Result<(), Status>

Called when the file is going to be accessed, typically by a new connection. Flags is the same as the flags passed to fidl_fuchsia_io.Node/Open. The following flags are handled by the connection and do not need to be handled inside open(): Read more
Source§

async fn truncate(&self, length: u64) -> Result<(), Status>

Truncate the file to length. If there are pending attributes to update (see update_attributes), they should also be flushed at this time. Otherwise, no attributes should be updated, other than size as needed.
Source§

async fn enable_verity( &self, options: VerificationOptions, ) -> Result<(), Status>

Set the merkle tree and the descriptor for this file and mark the file as fsverity-enabled.
Source§

async fn get_backing_memory(&self, flags: VmoFlags) -> Result<Vmo, Status>

Get a VMO representing this file. If not supported by the underlying filesystem, should return Err(NOT_SUPPORTED).
Source§

async fn get_size(&self) -> Result<u64, Status>

Get the size of this file. This is used to calculate seek offset relative to the end.
Source§

async fn update_attributes( &self, attributes: MutableNodeAttributes, ) -> Result<(), Status>

Set the mutable attributes of this file based on the values in attributes. If the file does not support updating all of the specified attributes, implementations should fail with ZX_ERR_NOT_SUPPORTED.
Source§

async fn allocate( &self, offset: u64, length: u64, _mode: AllocateMode, ) -> Result<(), Status>

Preallocate disk space for this range.
Source§

async fn sync(&self, mode: SyncMode) -> Result<(), Status>

Sync this file’s contents to the storage medium (probably disk). This does not necessarily guarantee that the file will be completely written to disk once the call returns. It merely guarantees that any changes to the file have been propagated to the next layer in the storage stack.
Source§

fn readable(&self) -> bool

Capabilities:
Source§

fn executable(&self) -> bool

Source§

impl FxNode for FxFile

Source§

fn object_id(&self) -> u64

Source§

fn parent(&self) -> Option<Arc<FxDirectory>>

Source§

fn set_parent(&self, _parent: Arc<FxDirectory>)

Source§

fn open_count_add_one(&self)

Source§

fn open_count_sub_one(self: Arc<Self>)

Atomically check if this brought the count to zero while the node is marked for purge. If so, this must queue the node for tombstone the node.
Source§

fn object_descriptor(&self) -> ObjectDescriptor

Source§

fn terminate(&self)

Called when the filesystem is shutting down. Implementations should break any strong reference cycles that would prevent the node from being dropped.
Source§

fn mark_to_be_purged(&self)

Marks the object to be purged. Queues the node for tombstone if open count is zero.
Source§

impl GetEntryInfo for FxFile

Source§

fn entry_info(&self) -> EntryInfo

This method is used to populate ReadDirents() output.
Source§

impl GetVmo for FxFile

Source§

const PAGER_ON_FIDL_EXECUTOR: bool = true

True if the vmo is pager backed and the pager is serviced by the same executor as the StreamIoConnection. Read more
Source§

fn get_vmo(&self) -> &Vmo

Returns the underlying VMO for the node.
Source§

impl Node for FxFile

Source§

async fn get_attributes( &self, requested_attributes: NodeAttributesQuery, ) -> Result<NodeAttributes2, Status>

Returns node attributes (io2).
Source§

fn will_clone(&self)

Called when the node is about to be cloned (and also by the default implementation of will_open_as_node). Implementations that perform their own open count can use this. Each call to will_clone will be accompanied by an eventual call to close.
Source§

fn close(self: Arc<Self>)

Called when the node is closed.
Source§

fn query_filesystem(&self) -> Result<FilesystemInfo, Status>

Returns information about the filesystem and/or volume.
Source§

async fn list_extended_attributes(&self) -> Result<Vec<Vec<u8>>, Status>

List extended attributes.
Source§

async fn get_extended_attribute(&self, name: Vec<u8>) -> Result<Vec<u8>, Status>

Get the value for an extended attribute.
Source§

async fn set_extended_attribute( &self, name: Vec<u8>, value: Vec<u8>, mode: SetExtendedAttributeMode, ) -> Result<(), Status>

Set the value for an extended attribute.
Source§

async fn remove_extended_attribute(&self, name: Vec<u8>) -> Result<(), Status>

Remove the value for an extended attribute.
Source§

fn will_open_as_node(&self) -> Result<(), Status>

Called when the node is about to be opened as the node protocol. Implementers can use this to perform any initialization or reference counting. Errors here will result in the open failing. By default, this forwards to the infallible will_clone.
Source§

fn open_as_node( self: Arc<Self>, scope: ExecutionScope, options: NodeOptions, object_request: &mut ObjectRequest, ) -> Result<(), Status>
where Self: Sized,

Opens the node using the node protocol.
Source§

impl PagerBacked for FxFile

Source§

fn pager(&self) -> &Pager

The pager backing this VMO.
Source§

fn pager_packet_receiver_registration( &self, ) -> &PagerPacketReceiverRegistration<Self>

The receiver registration returned from Pager::create_vmo.
Source§

fn vmo(&self) -> &Vmo

The pager backed VMO that this object is handling packets for. The VMO must be created with Pager::create_vmo.
Source§

fn page_in(self: Arc<Self>, range: PageInRange<Self>)

Called by the pager when a ZX_PAGER_VMO_READ packet is received for the VMO. The implementation must respond by calling either PageInRange::supply_pages or PageInRange::report_failure.
Source§

fn mark_dirty(self: Arc<Self>, range: MarkDirtyRange<Self>)

Called by the pager when a ZX_PAGER_VMO_DIRTY packet is received for the VMO. The implementation must respond by calling either MarkDirtyRange::dirty_pages or MarkDirtyRange::report_failure.
Source§

fn on_zero_children(self: Arc<Self>)

Called by the pager to indicate there are no more VMO children.
Source§

fn byte_size(&self) -> u64

Total bytes readable. Anything reads over this will be zero padded in the VMO.
Source§

async fn aligned_read(&self, range: Range<u64>) -> Result<Buffer<'_>, Error>

Reads one or more blocks into a buffer and returns it. This method is called by default_page_in and aligned_byte_range will always be aligned to the read_ahead_size past to default_page_in unless that would extend beyond self.byte_size(), in which case, aligned_byte_range will end at self.byte_size()’s next page multiple. The returned buffer must be at least as large as the requested range. Only the requested range will be supplied to the pager.
Source§

impl ToWeakNode for FxFile

Source§

fn to_weak_node(self: Arc<Self>) -> WeakNode

Auto Trait Implementations§

§

impl !Freeze for FxFile

§

impl !RefUnwindSafe for FxFile

§

impl Send for FxFile

§

impl Sync for FxFile

§

impl Unpin for FxFile

§

impl UnsafeUnpin for FxFile

§

impl !UnwindSafe for FxFile

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> InstanceFromServiceTransport<T> for T

§

fn from_service_transport(handle: T) -> T

Converts the given service transport handle of type T to [Self]
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoAny for T
where T: 'static + Send + Sync,

Source§

fn into_any(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Cast the given object into a dyn std::any::Any.
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<E> RunsTransport<Mpsc> for E

§

impl<E> RunsTransport<Mpsc> for E
where E: RunsTransport<Mpsc>,