/// Add an entry to the directory reply buffer. Returns true if the buffer is full.
/// A transparent offset value can be provided for each entry. The kernel uses these
/// value to request the next entries in further readdir calls
Add an entry to the directory reply buffer. Returns true if the buffer is full.
A transparent offset value can be provided for each entry. The kernel uses these
value to request the next entries in further readdir calls
Add an entry to the directory reply buffer . Returns true if the buffer is full . A transparent offset value can be provided for each entry . The kernel uses these value to request the next entries in further readdir calls
pub fn add<T: AsRef<OsStr>>(&mut self, ino: u64, offset: i64, file_type: FileType, name: T) -> bool {
        let name = name.as_ref().as_bytes();
        let entlen = mem::size_of::<fuse_dirent>() + name.len();
        let entsize = (entlen + mem::size_of::<u64>() - 1) & !(mem::size_of::<u64>() - 1); // 64bit align
        let padlen = entsize - entlen;
        if self.data.len() + entsize > self.data.capacity() { return true; }
        unsafe {
            let p = self.data.as_mut_ptr().offset(self.data.len() as isize);
            let pdirent: *mut fuse_dirent = mem::transmute(p);
            (*pdirent).ino = ino;
            (*pdirent).off = offset as u64;
            (*pdirent).namelen = name.len() as u32;
            (*pdirent).typ = mode_from_type_and_perm(file_type, 0) >> 12;
            let p = p.offset(mem::size_of_val(&*pdirent) as isize);
            ptr::copy_nonoverlapping(name.as_ptr(), p, name.len());
            let p = p.offset(name.len() as isize);
            ptr::write_bytes(p, 0u8, padlen);
            let newlen = self.data.len() + entsize;
            self.data.set_len(newlen);
        }
        false
    }
pub fn add < T : AsRef < OsStr > > ( & mut self , ino : u64 , offset : i64 , file_type : FileType , name : T ) -> bool { let name = name . as_ref ( ) . as_bytes ( ) ; let entlen = mem :: size_of :: < fuse_dirent > ( ) + name . len ( ) ; let entsize = ( entlen + mem :: size_of :: < u64 > ( ) - 1 ) & ! ( mem :: size_of :: < u64 > ( ) - 1 ) ; // 64bit align let padlen = entsize - entlen ; if self . data . len ( ) + entsize > self . data . capacity ( ) { return true ; } unsafe { let p = self . data . as_mut_ptr ( ) . offset ( self . data . len ( ) as isize ) ; let pdirent : * mut fuse_dirent = mem :: transmute ( p ) ; ( * pdirent ) . ino = ino ; ( * pdirent ) . off = offset as u64 ; ( * pdirent ) . namelen = name . len ( ) as u32 ; ( * pdirent ) . typ = mode_from_type_and_perm ( file_type , 0 ) >> 12 ; let p = p . offset ( mem :: size_of_val ( & * pdirent ) as isize ) ; ptr :: copy_nonoverlapping ( name . as_ptr ( ) , p , name . len ( ) ) ; let p = p . offset ( name . len ( ) as isize ) ; ptr :: write_bytes ( p , 0u8 , padlen ) ; let newlen = self . data . len ( ) + entsize ; self . data . set_len ( newlen ) ; } false }
Add an entry to the directory reply buffer.
Add an entry to the directory reply buffer .
&mut self
ino
u64
offset
i64
file_type
FileType
name
T