youki icon indicating copy to clipboard operation
youki copied to clipboard

Update nix to 0.28.0

Open YJDoc2 opened this issue 11 months ago • 5 comments

ref : https://github.com/containers/youki/pull/2712

Nix update has some breaking changes , specifically in terms of deprecated fns , so need to update those to use non-deprecated things instead.

YJDoc2 avatar Mar 06 '24 06:03 YJDoc2

Hey can I take up this issue ?

omprakaash avatar Mar 10 '24 23:03 omprakaash

Hey can I take up this issue ?

Yep, thanks! Assigned :+1:

YJDoc2 avatar Mar 11 '24 05:03 YJDoc2

how to handle the change to the write function in nix?

// 0.27.1

/// Write to a raw file descriptor.
///
/// See also [write(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html)
pub fn write(fd: RawFd, buf: &[u8]) -> Result<usize> {
    let res = unsafe {
        libc::write(fd, buf.as_ptr() as *const c_void, buf.len() as size_t)
    };

    Errno::result(res).map(|r| r as usize)
}
// 0.28.0

/// Write to a raw file descriptor.
///
/// See also [write(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html)
pub fn write<Fd: AsFd>(fd: Fd, buf: &[u8]) -> Result<usize> {
    let res = unsafe {
        libc::write(
            fd.as_fd().as_raw_fd(),
            buf.as_ptr().cast(),
            buf.len() as size_t,
        )
    };

    Errno::result(res).map(|r| r as usize)
}

the trait bound i32: AsFd is not satisfied

zahash avatar Mar 25 '24 14:03 zahash

the i32 can be converted to OwnedFd but the ownership is a bit confusing.

unsafe { std::os::fd::OwnedFd::from_raw_fd( fd ) }

zahash avatar Mar 25 '24 14:03 zahash

i think a few types like ContainerType::TenantContainer { exec_notify_fd: RawFd } must be changed to ContainerType::TenantContainer { exec_notify_fd: OwnedFd }

because in a few places like TenantContainerBuilder::build we get a OwnedFd but soon convert it to a RawFd.

        let (read_end: OwnedFd, write_end: OwnedFd) =
            pipe2(OFlag::O_CLOEXEC).map_err(LibcontainerError::OtherSyscall)?;

        let mut builder_impl = ContainerBuilderImpl {
            container_type: ContainerType::TenantContainer {
                exec_notify_fd: write_end.as_raw_fd(),
            },
            ...
            

zahash avatar Mar 25 '24 14:03 zahash