Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"short read" from filesystem, when can it happen?

Tags:

It is obvious that in general the read(2) system call can return less bytes than what was asked to be read. However, quite a few programs assume that when working with a local files, read(2) never returns less than what was asked (unless the file is shorter, of course).

So, my question is: on Linux, in which cases can read(2) return less than what was requested if reading from an open file and EOF is not encountered and the amount being read is a few kilobytes at maximum?

Some guesses:

  • Can received signals interrupt a read like that, but not make it fail?
  • Can different filesystems affect this behavior? Is there anything special about jffs2?