コード例 #1
0
/* Read the buffer requested by copying as much as needed from each
   page. Invalid pages will be replaced with NULLs.
*/
ssize_t pmem_read(struct file *file, char *buf, size_t count,
                         loff_t *poff) {
  size_t to_read, remaining;

  to_read = count;
  remaining = to_read;
  /* Just keep going until the full buffer is copied. Due to the null
     padding on error its impossible to fail here.
  */
  while(remaining > 0) {
    remaining -= pmem_read_partial(file, buf + (to_read - remaining),
                                   remaining, poff);
  };
  return to_read;
}
コード例 #2
0
ファイル: pmem.c プロジェクト: google/rekall
/* Read the buffer requested by copying as much as needed from each
   page. Invalid pages will be replaced with NULLs.
*/
static ssize_t pmem_read(struct file *file, char *buf, size_t count,
			 loff_t *poff) {
  loff_t file_size = pmem_get_size();

  /* How much data is available in the entire memory range. */
  size_t available = file_size - *poff;
  size_t to_read = min(count, available);
  size_t remaining = to_read;

  if(file_size < *poff)
    return 0;

  /* Just keep going until the full buffer is copied. Due to the null
     padding on error its impossible to fail here.
  */
  while(remaining > 0) {
    remaining -= pmem_read_partial(file, buf + (to_read - remaining),
                                   remaining, poff);
  };

  return to_read;
}