Closed
Description
I'm not sure where I should report issues that are either libc or std, so I hope this is either the right place or someone knows.
I'm trying to read the size of an open file. I have two options to do this:
fs::File::metadata()
- a custom C implementation
The C impl looks like this:
size_t file_size_fd(int file) {
struct stat st;
if (fstat(file, &st) == 0) {
return st.st_size;
} else {
return 0u;
}
}
I have the following snippet:
let size = unsafe { file_size_fd(f.as_raw_fd()) };
let size2 = f.metadata().unwrap().len();
The C implementation returns the correct size (for example, 868 bytes), but the rust call gives me 0.
I'm using a fresh enough installation of esp-idf 4.3.1 and rust 1.56.0.1 [sic].