[cs33211] reading/writing to random positions in the file

Mikhail Nesterenko mikhail at cs.kent.edu
Thu Apr 23 15:46:53 EDT 2009


OS students,

There are two ways to do it:

* either use "pread" (for position read) and "pwrite" (for position
  write) the functions take three arguments:
  1. file descriptor
  2. pointer to the buffer holding values to be written to file/read
     form file
  3. offset -- specifies the location where the write/read should
  start

  pread/pwrite are described in the same man-page as the read/write

* function lseek positions the open file default offset to the
  particular value. In this case you can use regular read/write but
  you have to lseek before each read/write operation.

Both ways are acceptable for the third project.

Thanks,
-- 
Mikhail


More information about the cs33211 mailing list