summaryrefslogtreecommitdiff
path: root/ayafs/src/memory/file_handle.rs
blob: c821619738dec6fc7976b8e9743969509e3eb7b0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::AyaFS;
use std::sync::atomic::Ordering;

impl AyaFS {
    pub(crate) fn allocate_file_descriptor(
        &mut self,
        inode_index: usize,
        read: bool,
        write: bool,
    ) -> u64 {
        let fd = self.next_file_handle.fetch_add(1, Ordering::SeqCst);
        self.file_handle_map.insert(fd, (inode_index, read, write));
        fd
    }
}