Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nix to 0.28.0 #2723

Closed
YJDoc2 opened this issue Mar 6, 2024 · 5 comments
Closed

Update nix to 0.28.0 #2723

YJDoc2 opened this issue Mar 6, 2024 · 5 comments
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.

Comments

@YJDoc2
Copy link
Collaborator

YJDoc2 commented Mar 6, 2024

ref : #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 YJDoc2 added help wanted Extra attention is needed good first issue Good for newcomers kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Mar 6, 2024
@omprakaash
Copy link
Contributor

Hey can I take up this issue ?

@YJDoc2
Copy link
Collaborator Author

YJDoc2 commented Mar 11, 2024

Hey can I take up this issue ?

Yep, thanks! Assigned 👍

@zahash
Copy link
Contributor

zahash commented Mar 25, 2024

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
Copy link
Contributor

zahash commented Mar 25, 2024

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

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

@zahash
Copy link
Contributor

zahash commented Mar 25, 2024

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(),
            },
            ...
            

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.
Projects
None yet
Development

No branches or pull requests

4 participants