0

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

Erben Mo
  • 3,528
  • 3
  • 19
  • 32

1 Answers1

1

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.

John Zwinck
  • 239,568
  • 38
  • 324
  • 436
  • awesome... I was trying to figure out why the fd I created is not accessible to pread. Turns out the fd equals 0. Hence I asked this stupid question. – Erben Mo Dec 11 '14 at 00:43