Skip to content

Commit 13fa126

Browse files
committed
Addressed review comments
1 parent 660042a commit 13fa126

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/safeposix/syscalls/fs_calls.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2465,9 +2465,9 @@ impl Cage {
24652465
/// particular reference point.
24662466
/// * `whence` - It determines how the seek operation is performed. There
24672467
/// are three possible values for whence: `SEEK_SET`: The file offset is
2468-
/// set to offset bytes. `SEEK_CUR`: The file offset is set to its current
2469-
/// location plus offset bytes. `SEEK_END`: The file offset is set to the
2470-
/// size of the file plus offset bytes.
2468+
/// set to 0 + offset bytes. `SEEK_CUR`: The file offset is set to its
2469+
/// current location plus offset bytes. `SEEK_END`: The file offset is set
2470+
/// to the size of the file plus offset bytes.
24712471
///
24722472
/// ### Returns
24732473
///
@@ -3170,7 +3170,7 @@ impl Cage {
31703170
///
31713171
/// ### Panics
31723172
///
3173-
/// * There are no such panics which happen inside the function.
3173+
/// * This syscall indirectly panics when the helper function panics.
31743174
///
31753175
/// For more detailed description of all the commands and return values, see
31763176
/// [close(2)](https://man7.org/linux/man-pages/man2/close.2.html)
@@ -3267,11 +3267,15 @@ impl Cage {
32673267
// Remove the socket from the inode table and the domain
32683268
// socket paths if it is no longer needed.
32693269
drop(inodeobj);
3270+
// Get the entire path of the socket which is used for removing
3271+
// it from the metadata file.
32703272
let path = normpath(
32713273
convpath(sockhandle.localaddr.unwrap().path()),
32723274
self,
32733275
);
3276+
// Remove the reference of the inode from the inodetable
32743277
FS_METADATA.inodetable.remove(&inodenum);
3278+
// Remove any domain socket paths associated with the socket
32753279
NET_METADATA.domsock_paths.remove(&path);
32763280
}
32773281
}

src/tests/fs_tests.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4138,11 +4138,21 @@ pub mod fs_tests {
41384138
assert!(fd >= 0);
41394139

41404140
// Attempt to seek to a negative offset and check if it returns an error
4141+
// using "SEEK_SET" whence, where we are explicitly setting the file
4142+
// offset to -10 value.
41414143
assert_eq!(
41424144
cage.lseek_syscall(fd, -10, SEEK_SET),
41434145
-(Errno::EINVAL as i32)
41444146
);
41454147

4148+
// Attempt to seek to a negative offset and check if it returns an error
4149+
// using "SEEK_CUR" whence, where current position of the file is 0,
4150+
// as it's empty initially, and we are adding -10 to the offset.
4151+
assert_eq!(
4152+
cage.lseek_syscall(fd, -10, SEEK_CUR),
4153+
-(Errno::EINVAL as i32)
4154+
);
4155+
41464156
assert_eq!(cage.exit_syscall(EXIT_SUCCESS), EXIT_SUCCESS);
41474157
lindrustfinalize();
41484158
}

0 commit comments

Comments
 (0)