linux kernel when is file descriptor not accessible by pread?

218 Views Asked by At

so I am reading some kernel code and notice this: http://lxr.free-electrons.com/source/include/linux/fs.h?v=2.6.32#L63

in line 69, we have:

  /* file can be accessed using pread */
  #define FMODE_PREAD             ((__force fmode_t)8)

I am wondering when would a fd be not accessible by pread? I thought we can do pread on any fd...

Thanks!

Erben

1

There are 1 best solutions below

1
On BEST ANSWER

man pread on my Linux system says:

The file referenced by fd must be capable of seeking.

So if a file descriptor is not seekable (e.g. a socket or stdin), you will not be able to pread it.