from small one page howto to huge articles all in one place
 

search text in:





Poll
Which screen resolution do you use?










poll results

Last additions:
using iotop to find disk usage hogs

using iotop to find disk usage hogs

words:

887

views:

196714

userrating:

average rating: 1.7 (102 votes) (1=very good 6=terrible)


May 25th. 2007:
Words

486

Views

252324

why adblockers are bad


Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

words:

161

views:

141294

userrating:

average rating: 1.4 (42 votes) (1=very good 6=terrible)


April, 26th. 2006:

Druckversion
You are here: manpages





LSEEK

Section: POSIX Programmer's Manual (3P)
Updated: 2013
Index Return to Main Contents
 

PROLOG

This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

 

NAME

lseek --- move the read/write file offset  

SYNOPSIS

#include <unistd.h>
off_t lseek(int fildes, off_t offset, int whence);
 

DESCRIPTION

The lseek() function shall set the file offset for the open file description associated with the file descriptor fildes, as follows:
*
If whence is SEEK_SET, the file offset shall be set to offset bytes.
*
If whence is SEEK_CUR, the file offset shall be set to its current location plus offset.
*
If whence is SEEK_END, the file offset shall be set to the size of the file plus offset. The symbolic constants SEEK_SET, SEEK_CUR, and SEEK_END are defined in <unistd.h>. The behavior of lseek() on devices which are incapable of seeking is implementation-defined. The value of the file offset associated with such a device is undefined. The lseek() function shall allow the file offset to be set beyond the end of the existing data in the file. If data is later written at this point, subsequent reads of data in the gap shall return bytes with the value 0 until data is actually written into the gap. The lseek() function shall not, by itself, extend the size of a file. If fildes refers to a shared memory object, the result of the lseek() function is unspecified. If fildes refers to a typed memory object, the result of the lseek() function is unspecified.
 

RETURN VALUE

Upon successful completion, the resulting offset, as measured in bytes from the beginning of the file, shall be returned. Otherwise, -1 shall be returned, errno shall be set to indicate the error, and the file offset shall remain unchanged.  

ERRORS

The lseek() function shall fail if:
EBADF
The fildes argument is not an open file descriptor.
EINVAL
The whence argument is not a proper value, or the resulting file offset would be negative for a regular file, block special file, or directory.
EOVERFLOW
The resulting file offset would be a value which cannot be represented correctly in an object of type off_t.
ESPIPE
The fildes argument is associated with a pipe, FIFO, or socket.

The following sections are informative.  

EXAMPLES

None.  

APPLICATION USAGE

None.  

RATIONALE

The ISO C standard includes the functions fgetpos() and fsetpos(), which work on very large files by use of a special positioning type. Although lseek() may position the file offset beyond the end of the file, this function does not itself extend the size of the file. While the only function in POSIX.1-2008 that may directly extend the size of the file is write(), truncate(), and ftruncate(), several functions originally derived from the ISO C standard, such as fwrite(), fprintf(), and so on, may do so (by causing calls on write()). An invalid file offset that would cause [EINVAL] to be returned may be both implementation-defined and device-dependent (for example, memory may have few invalid values). A negative file offset may be valid for some devices in some implementations. The POSIX.1-1990 standard did not specifically prohibit lseek() from returning a negative offset. Therefore, an application was required to clear errno prior to the call and check errno upon return to determine whether a return value of (off_t)-1 is a negative offset or an indication of an error condition. The standard developers did not wish to require this action on the part of a conforming application, and chose to require that errno be set to [EINVAL] when the resulting file offset would be negative for a regular file, block special file, or directory.  

FUTURE DIRECTIONS

None.  

SEE ALSO

open() The Base Definitions volume of POSIX.1-2008, <sys_types.h>, <unistd.h>  

COPYRIGHT

Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, Copyright (C) 2013 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. (This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.unix.org/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


 

Index

PROLOG
NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
ERRORS
EXAMPLES
APPLICATION USAGE
RATIONALE
FUTURE DIRECTIONS
SEE ALSO
COPYRIGHT





Support us on Content Nation
rdf newsfeed | rss newsfeed | Atom newsfeed
- Powered by LeopardCMS - Running on Gentoo -
Copyright 2004-2020 Sascha Nitsch Unternehmensberatung GmbH
Valid XHTML1.1 : Valid CSS : buttonmaker
- Level Triple-A Conformance to Web Content Accessibility Guidelines 1.0 -
- Copyright and legal notices -
Time to create this page: 16.0 ms