Skip to content

Commit 87dd201

Browse files
committed
add missing interface for lseek
1 parent 48da65b commit 87dd201

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

hermit-abi/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,13 @@ pub const PROT_WRITE: u32 = 1 << 1;
337337
/// Indicates that the memory region should be executable.
338338
pub const PROT_EXEC: u32 = 1 << 2;
339339

340+
/// The file offset is set to offset bytes.
341+
pub const SEEK_SET: i32 = 0;
342+
/// The file offset is set to its current location plus offset bytes.
343+
pub const SEEK_CUR: i32 = 1;
344+
/// The file offset is set to the size of the file plus offset bytes.
345+
pub const SEEK_END: i32 = 2;
346+
340347
// symbols, which are part of the library operating system
341348
extern "C" {
342349
/// Get the last error number from the thread local storage
@@ -718,6 +725,14 @@ extern "C" {
718725
addrlen: *mut socklen_t,
719726
) -> isize;
720727

728+
/// The fseek() function sets the file position indicator for the stream pointed to by stream.
729+
/// The new position, measured in bytes, is obtained by adding offset bytes to the position
730+
/// specified by whence. If whence is set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is
731+
/// relative to the start of the file, the current position indicator, or end-of-file,
732+
/// respectively.
733+
#[link_name = "sys_lseek"]
734+
pub fn lseek(fd: i32, offset: isize, whence: i32) -> isize;
735+
721736
/// write to a file descriptor
722737
///
723738
/// write() attempts to write `len` of data to the object

0 commit comments

Comments
 (0)