-
Notifications
You must be signed in to change notification settings - Fork 694
Documentation for Whence. #730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/unistd.rs
Outdated
pub enum Whence { | ||
/// The file offset shall be set to offset bytes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Specify an offset relative to the start of the file"
src/unistd.rs
Outdated
SeekSet, | ||
/// The file offset shall be set to its current location plus offset. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Specify an offset relative to the current file location"
src/unistd.rs
Outdated
SeekCur, | ||
/// The file offset shall be set to the size of the file plus offset. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Specify an offset relative to the end of the file"
src/unistd.rs
Outdated
SeekEnd, | ||
/// Adjust the file offset to the next location in the file greater than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Specify a file offset relative to the next location in the file greater than or equal to offset containing data. If offset points to data, then the file offset is set to offset."
That being said I really don't understand what "data" is in this context and how "offset" relates to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data is supposed to mean a part of the file that's been written to. Maybe it should be called 'some data'?
src/unistd.rs
Outdated
SeekData, | ||
/// Adjust the file offset to the next hole in the file greater than or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, this only "specifies", it doesn't "adjust". The *seek()
functions adjust, these constants are just specifying a position.
src/unistd.rs
Outdated
@@ -737,11 +737,23 @@ pub fn write(fd: RawFd, buf: &[u8]) -> Result<usize> { | |||
Errno::result(res).map(|r| r as usize) | |||
} | |||
|
|||
/// Directive that tells lseek how to reposition the offset of the file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reference lseek
and lseek64
and specify them as Markdown links to the documentation. See here for an example. You'll need to figure out the exact paths for lseek/lseek64, but the premise is the same.
src/unistd.rs
Outdated
@@ -737,11 +737,25 @@ pub fn write(fd: RawFd, buf: &[u8]) -> Result<usize> { | |||
Errno::result(res).map(|r| r as usize) | |||
} | |||
|
|||
/// Directive that tells [`lseek`] and [`lseek64`] how to reposition the offset of the file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Directive for [lseek
] and [lseek64
] that specifies what the offset
is relative to."
If you're planning on tackling all of #676, we can keep that as part of this same PR as additional commits. |
Can you squash these commits all into one (lookup the Otherwise are you planning on adding the other parts of #676 to this PR or we just going to merge the documentation part in this one? |
I was thinking on tackling all of #676. I have a question with the conditional availabilty part, SEEK_DATA and SEEK_HOLE are defined on libc only on the linux module, so should I consider that the only platform where they are available? |
You'll want to check all applicable platforms. They should at least be added to DragonFlyBSD (declared here). FreeBSD also has them. It looks like it's not in uclibc or linux/musl. So I think those platforms are the only two missing it. I checked NetBSD, OpenBSD, and Mac and they don't have either of them, so that's fine. |
src/unistd.rs
Outdated
@@ -751,8 +767,10 @@ impl Whence { | |||
&Whence::SeekSet => libc::SEEK_SET, | |||
&Whence::SeekCur => libc::SEEK_CUR, | |||
&Whence::SeekEnd => libc::SEEK_END, | |||
&Whence::SeekData => 3, | |||
&Whence::SeekHole => 4 | |||
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't do this here, delete this whole impl
and just assign values within the enum like SeekSet = libc::SEEK_SET,
. You'll also want to say that it's a i32
datatype. Look at how it's implemented for Signal
.
src/unistd.rs
Outdated
/// Specify an offset relative to the next location in the file greater than or | ||
/// equal to offset that contains some data. If offset points to | ||
/// some data, then the file offset is set to offset. | ||
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please alphabetize the OS names here and below.
Would adding |
Use a whitelist for Linux instead: |
You'll need to exclude arch mip64 as well. |
Changed SeekData and SeekHole hardcoded values to libc ones and added availability only to linux freebsd and dragonflybsd. Removed impl Whence and assigned the libc values directly in the enum definition.
Thanks for the improvements, @ncaracci bors r+ |
Timed out |
bors timed out because of a known bug in buildbot, triggered by the non-ascii character in the author's name. I'll manually merge it. |
No description provided.