⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lseek.2

📁 操作系统设计与实现源码
💻 2
字号:
.\" Copyright (c) 1980 Regents of the University of California..\" All rights reserved.  The Berkeley software License Agreement.\" specifies the terms and conditions for redistribution..\".\"	@(#)lseek.2	6.3 (Berkeley) 2/24/86.\".TH LSEEK 2 "February 24, 1986".UC 4.SH NAMElseek \- move read/write pointer.SH SYNOPSIS.nf.ft B#include <sys/types.h>#include <unistd.h>.ta +1.8i +0.6i#define SEEK_SET	0	/* offset is absolute */#define SEEK_CUR	1	/* relative to current position */#define SEEK_END	2	/* relative to end of file */off_t lseek(int d, off_t offset, int whence).fi.ft R.SH DESCRIPTIONThe descriptor .I drefers to a file or device open for reading and/or writing..B Lseeksets the file pointer of.I das follows:.IPIf.I whenceis SEEK_SET, the pointer is set to.I offsetbytes..IPIf.I whenceis SEEK_CUR, the pointer is set to its current location plus.IR offset ..IPIf.I whenceis SEEK_END, the pointer is set to the size of thefile plus.IR offset ..PPUpon successful completion, the resulting pointer locationas measured in bytes from beginning of the file is returned.Some devices are incapable of seeking.  The value of the pointerassociated with such a device is undefined..SH NOTESSeeking far beyond the end of a file, then writing,creates a gap or \*(lqhole\*(rq, which occupies nophysical space and reads as zeros..SH "RETURN VALUEUpon successful completion,the current file pointer value is returned.Otherwise,a value of \-1 is returned and \fBerrno\fP is set to indicatethe error..SH "ERRORS.B Lseekwill fail and the file pointer will remain unchanged if:.TP 15[EBADF].I Fildesis not an open file descriptor..TP 15[ESPIPE].I Fildesis associated with a pipe or a socket..TP 15[EINVAL].I Whenceis not a proper value..SH "SEE ALSO".BR fcntl (2),.BR open (2)..SH BUGSThis document's use of.I whenceis incorrect English, but maintained for historical reasons.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -