SocketFile

Struct SocketFile 

Source
pub struct SocketFile { /* private fields */ }

Implementations§

Source§

impl SocketFile

Source

pub fn from_socket<L>( locked: &mut Locked<L>, current_task: &CurrentTask, socket: SocketHandle, open_flags: OpenFlags, kernel_private: bool, ) -> Result<FileHandle, Errno>

Creates a FileHandle referring to a socket.

§Parameters
  • current_task: The current task.
  • socket: The socket to refer to.
  • open_flags: The OpenFlags which are used to create the FileObject.
  • kernel_private: true if the socket will be used internally by the kernel, and should therefore not be security labeled nor access-checked.
Source

pub fn new_socket<L>( locked: &mut Locked<L>, current_task: &CurrentTask, domain: SocketDomain, socket_type: SocketType, open_flags: OpenFlags, protocol: SocketProtocol, kernel_private: bool, ) -> Result<FileHandle, Errno>

Shortcut for Socket::new plus SocketFile::from_socket.

Source

pub fn get_from_file( file: &FileHandle, ) -> Result<DowncastedFile<'_, Self>, Errno>

Source

pub fn socket(&self) -> &SocketHandle

Source§

impl SocketFile

Source

pub fn new(socket: SocketHandle) -> Box<Self>

Source

pub fn sendmsg<L>( &self, locked: &mut Locked<L>, current_task: &CurrentTask, file: &FileObject, data: &mut dyn InputBuffer, dest_address: Option<SocketAddress>, ancillary_data: Vec<AncillaryData>, flags: SocketMessageFlags, ) -> Result<usize, Errno>

Writes the provided data into the socket in this file.

The provided control message is

§Parameters
  • task: The task that the user buffers belong to.
  • file: The file that will be used for the blocking_op.
  • data: The user buffers to read data from.
  • control_bytes: Control message bytes to write to the socket.
Source

pub fn recvmsg<L>( &self, locked: &mut Locked<L>, current_task: &CurrentTask, file: &FileObject, data: &mut dyn OutputBuffer, flags: SocketMessageFlags, deadline: Option<MonotonicInstant>, ) -> Result<MessageReadInfo, Errno>

Reads data from the socket in this file into data.

§Parameters
  • file: The file that will be used to wait if necessary.
  • task: The task that the user buffers belong to.
  • data: The user buffers to write to.

Returns the number of bytes read, as well as any control message that was encountered.

Trait Implementations§

Source§

impl FileOps for SocketFile

Source§

fn to_handle( &self, file: &FileObject, current_task: &CurrentTask, ) -> Result<Option<NullableHandle>, Errno>

Return a handle that allows access to this file descritor through the zxio protocols.

If None is returned, the file will act as if it was a fd to /dev/null.

Source§

fn is_seekable(&self) -> bool

Returns whether the file is seekable.
Source§

fn seek( &self, _locked: &mut Locked<FileOpsCore>, _file: &FileObject, _current_task: &CurrentTask, _current_offset: off_t, _target: SeekTarget, ) -> Result<off_t, Errno>

Adjust the current_offset if the file is seekable.
Source§

fn sync( &self, file: &FileObject, _current_task: &CurrentTask, ) -> Result<(), Errno>

Syncs cached state associated with the file descriptor to persistent storage. Read more
Source§

fn read( &self, locked: &mut Locked<FileOpsCore>, file: &FileObject, current_task: &CurrentTask, offset: usize, data: &mut dyn OutputBuffer, ) -> Result<usize, Errno>

Read from the file at an offset. If the file does not have persistent offsets (either directly, or because it is not seekable), offset will be 0 and can be ignored. Returns the number of bytes read.
Source§

fn write( &self, locked: &mut Locked<FileOpsCore>, file: &FileObject, current_task: &CurrentTask, offset: usize, data: &mut dyn InputBuffer, ) -> Result<usize, Errno>

Write to the file with an offset. If the file does not have persistent offsets (either directly, or because it is not seekable), offset will be 0 and can be ignored. Returns the number of bytes written.
Source§

fn wait_async( &self, locked: &mut Locked<FileOpsCore>, _file: &FileObject, current_task: &CurrentTask, waiter: &Waiter, events: FdEvents, handler: EventHandler, ) -> Option<WaitCanceler>

Establish a one-shot, edge-triggered, asynchronous wait for the given FdEvents for the given file and task. Returns None if this file does not support blocking waits. Read more
Source§

fn query_events( &self, locked: &mut Locked<FileOpsCore>, _file: &FileObject, current_task: &CurrentTask, ) -> Result<FdEvents, Errno>

The events currently active on this file. Read more
Source§

fn ioctl( &self, locked: &mut Locked<Unlocked>, file: &FileObject, current_task: &CurrentTask, request: u32, arg: SyscallArg, ) -> Result<SyscallResult, Errno>

Source§

fn close( self: Box<Self>, locked: &mut Locked<FileOpsCore>, _file: &FileObjectState, current_task: &CurrentTask, )

Called when the FileObject is destroyed.
Source§

fn open( &self, _locked: &mut Locked<FileOpsCore>, _file: &FileObject, _current_task: &CurrentTask, ) -> Result<(), Errno>

Called when the FileObject is opened/created
Source§

fn flush( &self, _locked: &mut Locked<FileOpsCore>, _file: &FileObject, _current_task: &CurrentTask, )

Called every time close() is called on this file, even if the file is not ready to be released.
Source§

fn has_persistent_offsets(&self) -> bool

Returns whether the file has meaningful seek offsets. Returning false is only optimization and will makes FileObject never hold the offset lock when calling read and write.
Source§

fn writes_update_seek_offset(&self) -> bool

Returns true if write() operations on the file will update the seek offset.
Source§

fn data_sync( &self, file: &FileObject, current_task: &CurrentTask, ) -> Result<(), Errno>

Syncs cached data, and only enough metadata to retrieve said data, to persistent storage. Read more
Source§

fn get_memory( &self, _locked: &mut Locked<FileOpsCore>, _file: &FileObject, _current_task: &CurrentTask, _length: Option<usize>, _prot: ProtectionFlags, ) -> Result<Arc<MemoryObject>, Errno>

Returns a VMO representing this file. At least the requested protection flags must be set on the VMO. Reading or writing the VMO must read or write the file. If this is not possible given the requested protection, an error must be returned. The length is a hint for the desired size of the VMO. The returned VMO may be larger or smaller than the requested length. This method is typically called by Self::mmap.
Source§

fn mmap( &self, locked: &mut Locked<FileOpsCore>, file: &FileObject, current_task: &CurrentTask, addr: DesiredAddress, memory_offset: u64, length: usize, prot_flags: ProtectionFlags, options: MappingOptions, filename: NamespaceNode, ) -> Result<UserAddress, Errno>

Responds to an mmap call. The default implementation calls Self::get_memory to get a VMO and then maps it with [crate::mm::MemoryManager::map]. Only implement this trait method if your file needs to control mapping, or record where a VMO gets mapped.
Source§

fn readdir( &self, _locked: &mut Locked<FileOpsCore>, _file: &FileObject, _current_task: &CurrentTask, _sink: &mut dyn DirentSink, ) -> Result<(), Errno>

Respond to a getdents or getdents64 calls. Read more
Source§

fn fcntl( &self, _file: &FileObject, _current_task: &CurrentTask, cmd: u32, _arg: u64, ) -> Result<SyscallResult, Errno>

Source§

fn as_thread_group_key( &self, _file: &FileObject, ) -> Result<ThreadGroupKey, Errno>

Returns the associated pid_t. Read more
Source§

fn readahead( &self, _file: &FileObject, _current_task: &CurrentTask, _offset: usize, _length: usize, ) -> Result<(), Errno>

Source§

fn extra_fdinfo( &self, _locked: &mut Locked<FileOpsCore>, _file: &FileHandle, _current_task: &CurrentTask, ) -> Option<FsString>

Extra information that is included in the /proc//fdfino/ entry.

Auto Trait Implementations§

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> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn type_name(&self) -> &'static str

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, U> Into32<U> for T
where U: MultiArchFrom<T>,

Source§

fn into_32(self) -> U

Source§

impl<T, U> Into64<U> for T
where U: MultiArchFrom<T>,

Source§

fn into_64(self) -> U

Source§

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

Source§

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

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, U> IntoExt<U> for T
where U: FromExt<T>,

§

fn into_ext(self) -> U

Performs the conversion.
Source§

impl<T, U> IntoFidl<U> for T
where U: FromFidl<T>,

Source§

fn into_fidl(self) -> U

Source§

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

Source§

fn from_64(value: T) -> U

Source§

fn from_32(value: T) -> U

§

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<T, U> TryIntoExt<U> for T
where U: TryFromExt<T>,

§

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

§

fn try_into_ext(self) -> Result<U, <T as TryIntoExt<U>>::Error>

Tries to perform the conversion.
§

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

§

fn vzip(self) -> V

§

impl<St> WithTag for St

§

fn tagged<T>(self, tag: T) -> Tagged<T, St>

Produce a new stream from this one which yields item tupled with a constant tag
Source§

impl<B, A> LockBefore<B> for A
where B: LockAfter<A>,

Source§

impl<B, A> LockEqualOrBefore<B> for A
where A: LockBefore<B>,

§

impl<E> RunsTransport<Mpsc> for E

§

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