plugins/ext2/ext2.c
/* Write data to the file. */
Write data to the file.
Write data to the file .
static int
ext2_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset,
             uint32_t flags)
{
  struct handle *h = handle;
  errcode_t err;
  unsigned int written;
  while (count > 0) {
    err = ext2fs_file_llseek (h->file, offset, EXT2_SEEK_SET, NULL);
    if (err != 0) {
      nbdkit_error ("%s: %s: llseek: %s", disk, file, error_message (err));
      return -1;
    }
    err = ext2fs_file_write (h->file, buf, (unsigned int) count, &written);
    if (err != 0) {
      nbdkit_error ("%s: %s: write: %s", disk, file, error_message (err));
      return -1;
    }
    buf += written;
    count -= written;
    offset += written;
  }
  if ((flags & NBDKIT_FLAG_FUA) != 0) {
    err = ext2fs_file_flush (h->file);
    if (err != 0) {
      nbdkit_error ("%s: %s: flush: %s", disk, file, error_message (err));
      return -1;
    }
  }
  return 0;
}
static int ext2_pwrite ( void * handle , const void * buf , uint32_t count , uint64_t offset , uint32_t flags ) { struct handle * h = handle ; errcode_t err ; unsigned int written ; while ( count > 0 ) { err = ext2fs_file_llseek ( h -> file , offset , EXT2_SEEK_SET , NULL ) ; if ( err != 0 ) { nbdkit_error ( " " , disk , file , error_message ( err ) ) ; return -1 ; } err = ext2fs_file_write ( h -> file , buf , ( unsigned int ) count , & written ) ; if ( err != 0 ) { nbdkit_error ( " " , disk , file , error_message ( err ) ) ; return -1 ; } buf += written ; count -= written ; offset += written ; } if ( ( flags & NBDKIT_FLAG_FUA ) != 0 ) { err = ext2fs_file_flush ( h -> file ) ; if ( err != 0 ) { nbdkit_error ( " " , disk , file , error_message ( err ) ) ; return -1 ; } } return 0 ; }
Write data to the file.
Write data to the file .