Skip to content

Commit f7c16e3

Browse files
committed
added comments
1 parent c8150e3 commit f7c16e3

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/safeposix/syscalls/fs_calls.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,32 +1486,41 @@ impl Cage {
14861486
// otherwise, file descriptor table entry is stored in 'checkedfd'
14871487
let checkedfd = self.get_filedescriptor(fd).unwrap();
14881488
let unlocked_fd = checkedfd.read();
1489+
14891490
if let Some(filedesc_enum) = &*unlocked_fd {
14901491
//populate the dev id field -- can be done outside of the helper
14911492
databuf.f_fsid = FS_METADATA.dev_id;
14921493

14931494
match filedesc_enum {
1495+
// if the fd points to a normal file descriptor
14941496
File(normalfile_filedesc_obj) => {
1497+
// won't panic since we have already checked that the entries exist
1498+
// in the FS_METADATA inode table
14951499
let _inodeobj = FS_METADATA
14961500
.inodetable
14971501
.get(&normalfile_filedesc_obj.inode)
14981502
.unwrap();
14991503

15001504
return Self::_istatfs_helper(self, databuf);
15011505
}
1506+
1507+
// if the fd points to a socket, pipe, stream, or epoll file descriptor
15021508
Socket(_) | Pipe(_) | Stream(_) | Epoll(_) => {
15031509
return syscall_error(
15041510
Errno::EBADF,
15051511
"fstatfs",
1506-
"can't fstatfs on socket, stream, pipe, or epollfd",
1512+
"can't fstatfs on sockets, streams, pipes, or epoll fds",
15071513
);
15081514
}
15091515
}
1516+
} else {
1517+
return syscall_error(Errno::EBADF, "statfs", "invalid file descriptor");
15101518
}
1511-
return syscall_error(Errno::EBADF, "statfs", "invalid file descriptor");
15121519
}
15131520

1514-
// Not sure why these values are hardcoded despite having the formulae commented
1521+
// These values have (probably) been picked up from the previously used
1522+
// environment, and have been working fine till now for our purposes
1523+
// TODO: Figure out how to populate the databuf values properly
15151524
pub fn _istatfs_helper(&self, databuf: &mut FSData) -> i32 {
15161525
databuf.f_type = 0xBEEFC0DE; //unassigned
15171526
databuf.f_bsize = 4096;

0 commit comments

Comments
 (0)