Giter VIP home page Giter VIP logo

Comments (4)

quininer avatar quininer commented on June 7, 2024

I have not been able to reproduce the problem, can you provide the code to reproduce it?

from io-uring.

quininer avatar quininer commented on June 7, 2024

I added a test on statx.

pub fn test_statx(ring: &mut IoUring, test: &Test) -> anyhow::Result<()> {
require!(
test;
test.probe.is_supported(opcode::Statx::CODE);
);
println!("test statx");
let dir = tempfile::tempdir()?;
let path = dir.path().join("test-io-uring-statx");
let pathbuf = CString::new(path.as_os_str().as_bytes())?;
fs::write(&path, "1")?;
let mut statxbuf: libc::statx = unsafe { std::mem::zeroed() };
let statx_e = opcode::Statx::new(
types::Fd(libc::AT_FDCWD),
pathbuf.as_ptr(),
&mut statxbuf as *mut libc::statx as *mut _,
)
.mask(libc::STATX_ALL)
.build()
.user_data(0x99);
unsafe {
ring.submission().push(&statx_e).expect("queue is full");
}
ring.submit_and_wait(1)?;
let cqes = ring.completion().collect::<Vec<_>>();
assert_eq!(cqes.len(), 1);
assert_eq!(cqes[0].user_data(), 0x99);
assert_eq!(cqes[0].result(), 0);
// check
let mut statxbuf2 = unsafe { std::mem::zeroed() };
let ret = unsafe {
libc::statx(
libc::AT_FDCWD,
pathbuf.as_ptr(),
0,
libc::STATX_ALL,
&mut statxbuf2,
)
};
assert_eq!(ret, 0);
assert_eq!(statxbuf, statxbuf2);
// statx fd
let fd = fs::File::open(&path)?;
let mut statxbuf3: libc::statx = unsafe { std::mem::zeroed() };
let statx_e = opcode::Statx::new(
types::Fd(fd.as_raw_fd()),
b"\0".as_ptr().cast(),
&mut statxbuf3 as *mut libc::statx as *mut _,
)
.flags(libc::AT_EMPTY_PATH)
.mask(libc::STATX_ALL)
.build()
.user_data(0x9a);
unsafe {
ring.submission().push(&statx_e).expect("queue is full");
}
ring.submit_and_wait(1)?;
let cqes = ring.completion().collect::<Vec<_>>();
assert_eq!(cqes.len(), 1);
assert_eq!(cqes[0].user_data(), 0x9a);
assert_eq!(cqes[0].result(), 0);
assert_eq!(statxbuf3, statxbuf2);
Ok(())
}

from io-uring.

sunyulin728 avatar sunyulin728 commented on June 7, 2024

I think it is my code problem. I will dig into it.

BTW: When I run the test code, I got following error message.

assert_eq!(statxbuf, statxbuf2);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ libc::statx cannot be formatted using {:?} because it doesn't implement Debug
|
= help: the trait Debug is not implemented for libc::statx

from io-uring.

quininer avatar quininer commented on June 7, 2024

You need to manually turn on the extra_traits feature of libc.

from io-uring.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.