src/pxar/fuse.rs: s/Buf/ReplyBuf/ and s/BufState/ReplyBufState/
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
		
				
					committed by
					
						
						Dietmar Maurer
					
				
			
			
				
	
			
			
			
						parent
						
							48cc1b8234
						
					
				
				
					commit
					03310bea12
				
			@ -501,16 +501,16 @@ extern "C" fn opendir(req: Request, inode: u64, fileinfo: MutPtr) {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// State of Buf after last add_entry call
 | 
					/// State of ReplyBuf after last add_entry call
 | 
				
			||||||
enum BufState {
 | 
					enum ReplyBufState {
 | 
				
			||||||
    /// Entry was successfully added to Buf
 | 
					    /// Entry was successfully added to ReplyBuf
 | 
				
			||||||
    Okay,
 | 
					    Okay,
 | 
				
			||||||
    /// Entry did not fit into Buf, was not added
 | 
					    /// Entry did not fit into ReplyBuf, was not added
 | 
				
			||||||
    Overfull,
 | 
					    Overfull,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Used to correctly fill and reply the buffer for the readdir callback
 | 
					/// Used to correctly fill and reply the buffer for the readdir callback
 | 
				
			||||||
struct Buf {
 | 
					struct ReplyBuf {
 | 
				
			||||||
    /// internal buffer holding the binary data
 | 
					    /// internal buffer holding the binary data
 | 
				
			||||||
    buffer: Vec<u8>,
 | 
					    buffer: Vec<u8>,
 | 
				
			||||||
    /// offset up to which the buffer is filled already
 | 
					    /// offset up to which the buffer is filled already
 | 
				
			||||||
@ -522,8 +522,8 @@ struct Buf {
 | 
				
			|||||||
    next: usize,
 | 
					    next: usize,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl Buf {
 | 
					impl ReplyBuf {
 | 
				
			||||||
    /// Create a new empty `Buf` of `size` with element counting index at `next`.
 | 
					    /// Create a new empty `ReplyBuf` of `size` with element counting index at `next`.
 | 
				
			||||||
    fn new(req: Request, size: usize, next: usize) -> Self {
 | 
					    fn new(req: Request, size: usize, next: usize) -> Self {
 | 
				
			||||||
        Self {
 | 
					        Self {
 | 
				
			||||||
            buffer: vec![0; size],
 | 
					            buffer: vec![0; size],
 | 
				
			||||||
@ -544,7 +544,7 @@ impl Buf {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Fill the buffer for the fuse reply with the next entry
 | 
					    /// Fill the buffer for the fuse reply with the next entry
 | 
				
			||||||
    fn add_entry(&mut self, name: &CString, attr: &libc::stat) -> Result<BufState, Error> {
 | 
					    fn add_entry(&mut self, name: &CString, attr: &libc::stat) -> Result<ReplyBufState, Error> {
 | 
				
			||||||
        self.next += 1;
 | 
					        self.next += 1;
 | 
				
			||||||
        let size = self.buffer.len();
 | 
					        let size = self.buffer.len();
 | 
				
			||||||
        let bytes = unsafe {
 | 
					        let bytes = unsafe {
 | 
				
			||||||
@ -565,10 +565,10 @@ impl Buf {
 | 
				
			|||||||
            // Entry did not fit, so go back to previous state
 | 
					            // Entry did not fit, so go back to previous state
 | 
				
			||||||
            self.filled -= bytes;
 | 
					            self.filled -= bytes;
 | 
				
			||||||
            self.next -= 1;
 | 
					            self.next -= 1;
 | 
				
			||||||
            return Ok(BufState::Overfull);
 | 
					            return Ok(ReplyBufState::Overfull);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Ok(BufState::Okay)
 | 
					        Ok(ReplyBufState::Okay)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -585,7 +585,7 @@ extern "C" fn readdir(req: Request, inode: u64, size: size_t, offset: c_int, _fi
 | 
				
			|||||||
        let gb_table = decoder.goodbye_table(None, ino_offset + GOODBYE_ITEM_SIZE).map_err(|_| libc::EIO)?;
 | 
					        let gb_table = decoder.goodbye_table(None, ino_offset + GOODBYE_ITEM_SIZE).map_err(|_| libc::EIO)?;
 | 
				
			||||||
        let n_entries = gb_table.len();
 | 
					        let n_entries = gb_table.len();
 | 
				
			||||||
        //let entries = decoder.list_dir(&dir).map_err(|_| libc::EIO)?;
 | 
					        //let entries = decoder.list_dir(&dir).map_err(|_| libc::EIO)?;
 | 
				
			||||||
        let mut buf = Buf::new(req, size, offset);
 | 
					        let mut buf = ReplyBuf::new(req, size, offset);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if offset < n_entries {
 | 
					        if offset < n_entries {
 | 
				
			||||||
            for e in gb_table[offset..gb_table.len()].iter() {
 | 
					            for e in gb_table[offset..gb_table.len()].iter() {
 | 
				
			||||||
@ -596,8 +596,8 @@ extern "C" fn readdir(req: Request, inode: u64, size: size_t, offset: c_int, _fi
 | 
				
			|||||||
                let item_inode = calculate_inode(item_offset, decoder.root_end_offset());
 | 
					                let item_inode = calculate_inode(item_offset, decoder.root_end_offset());
 | 
				
			||||||
                let attr = stat(item_inode, &entry, payload_size).map_err(|_| libc::EIO)?;
 | 
					                let attr = stat(item_inode, &entry, payload_size).map_err(|_| libc::EIO)?;
 | 
				
			||||||
                match buf.add_entry(&name, &attr) {
 | 
					                match buf.add_entry(&name, &attr) {
 | 
				
			||||||
                    Ok(BufState::Okay) => {}
 | 
					                    Ok(ReplyBufState::Okay) => {}
 | 
				
			||||||
                    Ok(BufState::Overfull) => return buf.reply_filled(),
 | 
					                    Ok(ReplyBufState::Overfull) => return buf.reply_filled(),
 | 
				
			||||||
                    Err(_) => return Err(libc::EIO),
 | 
					                    Err(_) => return Err(libc::EIO),
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -610,8 +610,8 @@ extern "C" fn readdir(req: Request, inode: u64, size: size_t, offset: c_int, _fi
 | 
				
			|||||||
            let attr = stat(inode, &entry, payload_size).map_err(|_| libc::EIO)?;
 | 
					            let attr = stat(inode, &entry, payload_size).map_err(|_| libc::EIO)?;
 | 
				
			||||||
            let name = CString::new(".").unwrap();
 | 
					            let name = CString::new(".").unwrap();
 | 
				
			||||||
            match buf.add_entry(&name, &attr) {
 | 
					            match buf.add_entry(&name, &attr) {
 | 
				
			||||||
                Ok(BufState::Okay) => {}
 | 
					                Ok(ReplyBufState::Okay) => {}
 | 
				
			||||||
                Ok(BufState::Overfull) => return buf.reply_filled(),
 | 
					                Ok(ReplyBufState::Overfull) => return buf.reply_filled(),
 | 
				
			||||||
                Err(_) => return Err(libc::EIO),
 | 
					                Err(_) => return Err(libc::EIO),
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -629,8 +629,8 @@ extern "C" fn readdir(req: Request, inode: u64, size: size_t, offset: c_int, _fi
 | 
				
			|||||||
            let attr = stat(item_inode, &entry, payload_size).map_err(|_| libc::EIO)?;
 | 
					            let attr = stat(item_inode, &entry, payload_size).map_err(|_| libc::EIO)?;
 | 
				
			||||||
            let name = CString::new("..").unwrap();
 | 
					            let name = CString::new("..").unwrap();
 | 
				
			||||||
            match buf.add_entry(&name, &attr) {
 | 
					            match buf.add_entry(&name, &attr) {
 | 
				
			||||||
                Ok(BufState::Okay) => {}
 | 
					                Ok(ReplyBufState::Okay) => {}
 | 
				
			||||||
                Ok(BufState::Overfull) => return buf.reply_filled(),
 | 
					                Ok(ReplyBufState::Overfull) => return buf.reply_filled(),
 | 
				
			||||||
                Err(_) => return Err(libc::EIO),
 | 
					                Err(_) => return Err(libc::EIO),
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user