//! Independent read-only handle offsets and transactional seek refusal. use super::*; use os_vfs_lookup::{LookupTable, Mount}; use os_vfs_open::{OpenFlags, OpenTable}; use os_vfs_offset::{CursorTable, Error as OffsetError, Whence}; pub fn run(allocator: &mut memory::FrameAllocator) -> Result<(), &'static str> { let frames_before = allocator.remaining_pages(); let first_mount = Mount::new(1, 11, b"dosya").map_err(|_| "k1570-first")?; let second_mount = Mount::new(2, 22, b"dosya").map_err(|_| "k1570-second")?; let lookup = LookupTable::new(first_mount, second_mount) .map_err(|_| "k1570-lookup")?; let dentry = lookup.lookup(1, b"dosya").map_err(|_| "k1570-dentry")?; let mut opens = OpenTable::new(); let first = opens.open(&lookup, dentry, OpenFlags::READ_ONLY) .map_err(|_| "k1570-open-one")?; let second = opens.open(&lookup, dentry, OpenFlags::READ_ONLY) .map_err(|_| "k1570-open-two")?; let mut cursors = CursorTable::new(); cursors.attach(first).map_err(|_| "k1570-attach-one")?; cursors.attach(second).map_err(|_| "k1570-attach-two")?; if cursors.read_complete(first.id, 8, 3) != Ok(3) || cursors.seek(first.id, Whence::Current, 4, 10) != Ok(7) || cursors.offset(second.id) != Ok(0) { return Err("k1570-short-read"); } let before = cursors; if cursors.seek(first.id, Whence::Start, -1, 10) != Err(OffsetError::NegativeSeek) || cursors.seek(first.id, Whence::End, 1, u64::MAX) != Err(OffsetError::Overflow) || cursors != before { return Err("k1570-rejected-seek"); } if cursors.seek(second.id, Whence::Start, 5, 10) != Ok(5) || cursors.offset(first.id) != Ok(7) || allocator.remaining_pages() != frames_before { return Err("k1570-other-handle"); } opens.close(first).map_err(|_| "k1570-close-one")?; opens.close(second).map_err(|_| "k1570-close-two")?; write_line("TURKOS/OS/K1570-OFFSET: SHORT=3 SEEK=7 NEG=REJECTED OVERFLOW=REJECTED OTHER=5 FRAMES=UNCHANGED"); Ok(()) }