Migrate readdir_r from pointers to places
This commit is contained in:
parent
9fcc8a2a91
commit
9e03b41338
@ -902,13 +902,11 @@ fn linux_readdir64_r(
|
|||||||
// pub d_name: [c_char; 256],
|
// pub d_name: [c_char; 256],
|
||||||
// }
|
// }
|
||||||
|
|
||||||
let entry_ptr = this.force_ptr(this.read_scalar(entry_op)?.not_undef()?)?;
|
let entry_place = this.deref_operand(entry_op)?;
|
||||||
let dirent64_layout = this.libc_ty_layout("dirent64")?;
|
let name_place = this.mplace_field(entry_place, 4)?;
|
||||||
let name_offset = dirent64_layout.details.fields.offset(4);
|
|
||||||
let name_ptr = entry_ptr.offset(name_offset, this)?;
|
|
||||||
|
|
||||||
let file_name = dir_entry.file_name();
|
let file_name = dir_entry.file_name();
|
||||||
let name_fits = this.write_os_str_to_c_str(&file_name, Scalar::Ptr(name_ptr), 256)?;
|
let name_fits = this.write_os_str_to_c_str(&file_name, name_place.ptr, name_place.layout.size.bytes())?;
|
||||||
if !name_fits {
|
if !name_fits {
|
||||||
throw_unsup_format!("A directory entry had a name too large to fit in libc::dirent64");
|
throw_unsup_format!("A directory entry had a name too large to fit in libc::dirent64");
|
||||||
}
|
}
|
||||||
@ -988,13 +986,11 @@ fn macos_readdir_r(
|
|||||||
// pub d_name: [c_char; 1024],
|
// pub d_name: [c_char; 1024],
|
||||||
// }
|
// }
|
||||||
|
|
||||||
let entry_ptr = this.force_ptr(this.read_scalar(entry_op)?.not_undef()?)?;
|
let entry_place = this.deref_operand(entry_op)?;
|
||||||
let dirent_layout = this.libc_ty_layout("dirent")?;
|
let name_place = this.mplace_field(entry_place, 5)?;
|
||||||
let name_offset = dirent_layout.details.fields.offset(5);
|
|
||||||
let name_ptr = entry_ptr.offset(name_offset, this)?;
|
|
||||||
|
|
||||||
let file_name = dir_entry.file_name();
|
let file_name = dir_entry.file_name();
|
||||||
let name_fits = this.write_os_str_to_c_str(&file_name, Scalar::Ptr(name_ptr), 1024)?;
|
let name_fits = this.write_os_str_to_c_str(&file_name, name_place.ptr, name_place.layout.size.bytes())?;
|
||||||
if !name_fits {
|
if !name_fits {
|
||||||
throw_unsup_format!("A directory entry had a name too large to fit in libc::dirent");
|
throw_unsup_format!("A directory entry had a name too large to fit in libc::dirent");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user