Lines Matching refs:fs
17 fs::{Cluster, FATFileSystem, MAX_FILE_SIZE},
83 fs: &Arc<FATFileSystem>, in read()
92 let start_cluster_number: u64 = offset / fs.bytes_per_cluster(); in read()
95 fs.get_cluster_by_relative(self.first_cluster, start_cluster_number as usize) in read()
105 let mut in_cluster_offset: u64 = offset % fs.bytes_per_cluster(); in read()
113 if in_cluster_offset >= fs.bytes_per_cluster() { in read()
114 if let Ok(FATEntry::Next(c)) = fs.get_fat_entry(current_cluster) { in read()
116 in_cluster_offset %= fs.bytes_per_cluster(); in read()
126 (fs.bytes_per_cluster() - in_cluster_offset) as usize, in read()
132 let offset = fs.cluster_bytes_offset(current_cluster) + in_cluster_offset; in read()
133 let r = fs in read()
158 fs: &Arc<FATFileSystem>, in write()
162 self.ensure_len(fs, offset, buf.len() as u64)?; in write()
165 let start_cluster_num = offset / fs.bytes_per_cluster(); in write()
168 fs.get_cluster_by_relative(self.first_cluster, start_cluster_num as usize) in write()
175 let mut in_cluster_bytes_offset: u64 = offset % fs.bytes_per_cluster(); in write()
182 if in_cluster_bytes_offset >= fs.bytes_per_cluster() { in write()
183 if let Ok(FATEntry::Next(c)) = fs.get_fat_entry(current_cluster) { in write()
185 in_cluster_bytes_offset %= fs.bytes_per_cluster(); in write()
192 (fs.bytes_per_cluster() - in_cluster_bytes_offset) as usize, in write()
197 let offset = fs.cluster_bytes_offset(current_cluster) + in_cluster_bytes_offset; in write()
199 let w = fs in write()
227 fs: &Arc<FATFileSystem>, in ensure_len()
237 let in_cluster_offset = self.size() % fs.bytes_per_cluster(); in ensure_len()
241 fs.bytes_per_cluster() - in_cluster_offset in ensure_len()
251 self.first_cluster = fs.allocate_cluster(None)?; in ensure_len()
253 bytes_remain_in_cluster = fs.bytes_per_cluster(); in ensure_len()
259 (extra_bytes - bytes_remain_in_cluster + fs.bytes_per_cluster() - 1) in ensure_len()
260 / fs.bytes_per_cluster(); in ensure_len()
261 let last_cluster = if let Some(c) = fs.get_last_cluster(self.first_cluster) { in ensure_len()
270 current_cluster = fs.allocate_cluster(Some(current_cluster))?; in ensure_len()
277 let start_cluster: u64 = self.size() / fs.bytes_per_cluster(); in ensure_len()
278 let start_cluster: Cluster = fs in ensure_len()
283 fs.cluster_bytes_offset(start_cluster) + self.size() % fs.bytes_per_cluster(); in ensure_len()
285 let bytes_remain: u64 = fs.bytes_per_cluster() - (self.size() % fs.bytes_per_cluster()); in ensure_len()
287 let cluster_offset_start = offset / fs.bytes_per_cluster(); in ensure_len()
289 let end_cluster: Cluster = fs in ensure_len()
294 self.zero_range(fs, start_offset, start_offset + bytes_remain)?; in ensure_len()
296 self.zero_range(fs, start_offset, start_offset + offset - self.size())?; in ensure_len()
303 let short_entry_offset = fs.cluster_bytes_offset(self.loc.1 .0) + self.loc.1 .1; in ensure_len()
306 self.short_dir_entry.flush(fs, short_entry_offset)?; in ensure_len()
316 fs: &Arc<FATFileSystem>, in zero_range()
325 fs.gendisk.write_at_bytes(&zeroes, range_start as usize)?; in zero_range()
336 pub fn truncate(&mut self, fs: &Arc<FATFileSystem>, new_size: u64) -> Result<(), SystemError> { in truncate()
341 let new_last_cluster = (new_size + fs.bytes_per_cluster() - 1) / fs.bytes_per_cluster(); in truncate()
343 fs.get_cluster_by_relative(self.first_cluster, new_last_cluster as usize) in truncate()
345 fs.deallocate_cluster_chain(begin_delete)?; in truncate()
356 let short_entry_offset = fs.cluster_bytes_offset((self.loc.1).0) + (self.loc.1).1; in truncate()
357 self.short_dir_entry.flush(fs, short_entry_offset)?; in truncate()
381 pub fn to_iter(&self, fs: Arc<FATFileSystem>) -> FATDirIter { in to_iter()
386 fs, in to_iter()
397 pub fn size(&self, fs: &Arc<FATFileSystem>) -> u64 { in size()
398 return fs.num_clusters_chain(self.first_cluster) * fs.bytes_per_cluster(); in size()
411 fs: Arc<FATFileSystem>, in find_free_entries()
421 if offset >= fs.bytes_per_cluster() && !self.is_root() { in find_free_entries()
423 if let Ok(FATEntry::Next(c)) = fs.get_fat_entry(current_cluster) { in find_free_entries()
426 offset %= fs.bytes_per_cluster(); in find_free_entries()
433 if self.is_root() && offset > fs.root_dir_end_bytes_offset().unwrap() { in find_free_entries()
437 let e_offset = fs.cluster_bytes_offset(current_cluster) + offset; in find_free_entries()
438 let entry: FATRawDirEntry = get_raw_dir_entry(&fs, e_offset)?; in find_free_entries()
466 (remain_entries * FATRawDirEntry::DIR_ENTRY_LEN + fs.bytes_per_cluster() - 1) in find_free_entries()
467 / fs.bytes_per_cluster(); in find_free_entries()
475 let c: Cluster = fs.allocate_cluster(Some(prev_cluster))?; in find_free_entries()
506 fs: Arc<FATFileSystem>, in find_entry()
510 for e in self.to_iter(fs) { in find_entry()
534 pub fn open_file(&self, name: &str, fs: Arc<FATFileSystem>) -> Result<FATFile, SystemError> { in open_file()
535 let f: FATFile = self.find_entry(name, Some(false), None, fs)?.to_file()?; in open_file()
540 pub fn open_dir(&self, name: &str, fs: Arc<FATFileSystem>) -> Result<FATDir, SystemError> { in open_dir()
541 let d: FATDir = self.find_entry(name, Some(true), None, fs)?.to_dir()?; in open_dir()
549 pub fn create_file(&self, name: &str, fs: &Arc<FATFileSystem>) -> Result<FATFile, SystemError> { in create_file()
551 self.check_existence(name, Some(false), fs.clone()); in create_file()
574 fs.clone(), in create_file()
587 pub fn create_dir(&self, name: &str, fs: &Arc<FATFileSystem>) -> Result<FATDir, SystemError> { in create_dir()
589 self.check_existence(name, Some(true), fs.clone()); in create_dir()
607 let first_cluster: Cluster = fs.allocate_cluster(None)?; in create_dir()
621 dot_entry.flush(fs, fs.cluster_bytes_offset(first_cluster) + offset)?; in create_dir()
635 dot_dot_entry.flush(fs, fs.cluster_bytes_offset(first_cluster) + offset)?; in create_dir()
647 fs.clone(), in create_dir()
672 fs: Arc<FATFileSystem>, in check_existence()
678 self.find_entry(name, expect_dir, Some(&mut sng), fs.clone()); in check_existence()
718 fs: Arc<FATFileSystem>,
732 self.find_free_entries(num_entries, fs.clone())?;
739 FATDirEntryOffsetIter::new(fs.clone(), start_loc, num_entries, None).collect();
746 let bytes_offset = fs.cluster_bytes_offset(off.0) + off.1;
747 long_entry.flush(fs.clone(), bytes_offset)?;
753 let offset = fs.cluster_bytes_offset(end.0) + end.1;
754 short_dentry.flush(&fs, offset)?;
765 pub fn is_empty(&self, fs: Arc<FATFileSystem>) -> bool { in is_empty()
766 for e in self.to_iter(fs) { in is_empty()
787 fs: Arc<FATFileSystem>, in remove()
791 let e: FATDirEntry = self.find_entry(name, None, None, fs.clone())?; in remove()
794 if e.is_dir() && !(e.to_dir().unwrap().is_empty(fs.clone())) { in remove()
800 fs.deallocate_cluster_chain(e.first_cluster())?; in remove()
804 self.remove_dir_entries(fs, e.get_dir_range().unwrap())?; in remove()
816 fs: Arc<FATFileSystem>, in remove_dir_entries()
821 FATDirEntryOffsetIter::new(fs.clone(), cluster_range.0, 15, Some(cluster_range.1)) in remove_dir_entries()
825 let gendisk_bytes_offset = fs.cluster_bytes_offset(off.0) + off.1; in remove_dir_entries()
828 short_entry.flush(&fs, gendisk_bytes_offset)?; in remove_dir_entries()
839 fs: Arc<FATFileSystem>, in get_dir_entry()
847 return self.find_entry(name, None, None, fs); in get_dir_entry()
854 fs: Arc<FATFileSystem>, in rename()
860 self.check_existence(old_name, None, fs.clone())? in rename()
869 self.check_existence(new_name, None, fs.clone())? in rename()
880 self.remove(fs.clone(), old_dentry.name().as_str(), false)?; in rename()
888 fs.clone(), in rename()
902 fs: Arc<FATFileSystem>, in rename_across()
909 self.check_existence(old_name, None, fs.clone())? in rename_across()
918 target.check_existence(new_name, None, fs.clone())? in rename_across()
929 self.remove(fs.clone(), old_dentry.name().as_str(), false)?; in rename_across()
937 fs.clone(), in rename_across()
1134 fs: Arc<FATFileSystem>, in flush()
1138 let blk_offset = fs.get_in_block_offset(gendisk_bytes_offset); in flush()
1139 let lba = fs.gendisk_lba_from_offset(fs.bytes_to_sector(gendisk_bytes_offset)); in flush()
1140 let mut v: Vec<u8> = vec![0; fs.lba_per_sector() * LBA_SIZE]; in flush()
1141 fs.gendisk.read_at(&mut v, lba)?; in flush()
1168 fs.gendisk.write_at(cursor.as_slice(), lba)?; in flush()
1170 fs.gendisk.sync()?; in flush()
1347 fs: &Arc<FATFileSystem>, in flush()
1351 let blk_offset = fs.get_in_block_offset(gendisk_bytes_offset); in flush()
1352 let lba = fs.gendisk_lba_from_offset(fs.bytes_to_sector(gendisk_bytes_offset)); in flush()
1353 let mut v: Vec<u8> = vec![0; fs.lba_per_sector() * LBA_SIZE]; in flush()
1354 fs.gendisk.read_at(&mut v, lba)?; in flush()
1373 fs.gendisk.write_at(cursor.as_slice(), lba)?; in flush()
1375 fs.gendisk.sync()?; in flush()
1448 fs: Arc<FATFileSystem>, field
1466 if self.offset >= self.fs.bytes_per_cluster() && !self.is_root { in get_dir_entry()
1467 match self.fs.get_fat_entry(self.current_cluster)? { in get_dir_entry()
1471 self.offset %= self.fs.bytes_per_cluster(); in get_dir_entry()
1483 if self.is_root && self.offset > self.fs.root_dir_end_bytes_offset().unwrap() { in get_dir_entry()
1488 let offset: u64 = self.fs.cluster_bytes_offset(self.current_cluster) + self.offset; in get_dir_entry()
1491 let raw_dentry: FATRawDirEntry = get_raw_dir_entry(&self.fs, offset)?; in get_dir_entry()
1524 if self.offset >= self.fs.bytes_per_cluster() && !self.is_root { in get_dir_entry()
1525 match self.fs.get_fat_entry(self.current_cluster)? { in get_dir_entry()
1529 self.offset %= self.fs.bytes_per_cluster(); in get_dir_entry()
1541 && self.offset > self.fs.root_dir_end_bytes_offset().unwrap() in get_dir_entry()
1548 self.fs.cluster_bytes_offset(self.current_cluster) + self.offset; in get_dir_entry()
1550 let raw_dentry: FATRawDirEntry = get_raw_dir_entry(&self.fs, offset)?; in get_dir_entry()
2319 fs: Arc<FATFileSystem>, field
2338 fs: Arc<FATFileSystem>, in new()
2346 fs, in new()
2367 if new_offset >= self.fs.bytes_per_cluster() { in next()
2368 new_offset %= self.fs.bytes_per_cluster(); in next()
2370 match self.fs.get_fat_entry(new_cluster) { in next()
2395 fs: &Arc<FATFileSystem>, in get_raw_dir_entry()
2399 let blk_offset: u64 = fs.get_in_block_offset(gendisk_bytes_offset); in get_raw_dir_entry()
2400 let lba = fs.gendisk_lba_from_offset(fs.bytes_to_sector(gendisk_bytes_offset)); in get_raw_dir_entry()
2404 fs.gendisk.read_at(&mut v, lba)?; in get_raw_dir_entry()