Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does p stand for in function names pwrite and pread?

Tags:

c

linux

I'm trying to learn linux api but some function names seem (at least to me) cumbersome.

Could anybody explain to me what does the initial letter p stands for in pwrite/pread?

like image 791
arik Avatar asked Jul 26 '13 09:07

arik


2 Answers

I am only guessing, but since pread()and pwrite() read or write at a specified position in the file, I would assume that the "p" stands for "positional", as in "positional read".

Both read() and pread() are part of the POSIX standard (see e.g. http://www.unix.com/man-page/POSIX/3posix/pread/), therefore I don't think that "p" stands for "POSIX".

But perhaps this is completely wrong!

like image 182
Martin R Avatar answered Nov 15 '22 05:11

Martin R


p in pread and pwrite refers to POSIX.

The two differences of "p" variant as opposed to read and write are:

  • The "p" variants take offset to read from, so they are independent of the current file pointer. That makes it easier to read/write from multiple threads concurrently.
  • The "p" variants only work on seekable files (i.e. real files, not pipes, sockets or devices).
like image 37
Jainendra Avatar answered Nov 15 '22 03:11

Jainendra