host-drivers/base-driver/vca/blockio/vcablk_bcknd/vcablk_bcknd_media.c
static int
media_transfer_file(struct vcablk_media *media, unsigned long sector,
		unsigned long nsect, char *buffer, int write)
{
	struct file *file = media->data.file;
	unsigned long offset = sector << SECTOR_SHIFT;
	unsigned long nbytes = nsect << SECTOR_SHIFT;
	ssize_t nbytesdone;

	if ((offset + nbytes) > media->size_bytes) {
		pr_notice("Beyond-end write (%ld %ld)\n", offset, nbytes);
		return -EIO;
	}

	if (write) {
		if (media->read_only)
			return -EACCES;

		nbytesdone = file_write(file, offset, buffer, nbytes);
	} else {
		nbytesdone = file_read(file, offset, buffer, nbytes);
	}

	if (!likely(nbytes == nbytesdone)) {
		pr_warning("%s: %s ERROR nbytes %lu nbytesdone %li\n",
				media->file_path, __func__, nbytes, nbytesdone);
	}

	return 0;
}
/*
 * Handle an I/O request for file.
 */
Handle an I/O request for file.
Handle an I / O request for file .
static int
media_transfer_file(struct vcablk_media *media, unsigned long sector,
		unsigned long nsect, char *buffer, int write)
{
	struct file *file = media->data.file;
	unsigned long offset = sector << SECTOR_SHIFT;
	unsigned long nbytes = nsect << SECTOR_SHIFT;
	ssize_t nbytesdone;
	if ((offset + nbytes) > media->size_bytes) {
		pr_notice("Beyond-end write (%ld %ld)\n", offset, nbytes);
		return -EIO;
	}
	if (write) {
		if (media->read_only)
			return -EACCES;
		nbytesdone = file_write(file, offset, buffer, nbytes);
	} else {
		nbytesdone = file_read(file, offset, buffer, nbytes);
	}
	if (!likely(nbytes == nbytesdone)) {
		pr_warning("%s: %s ERROR nbytes %lu nbytesdone %li\n",
				media->file_path, __func__, nbytes, nbytesdone);
	}
	return 0;
}
static int media_transfer_file ( struct vcablk_media * media , unsigned long sector , unsigned long nsect , char * buffer , int write ) { struct file * file = media -> data . file ; unsigned long offset = sector << SECTOR_SHIFT ; unsigned long nbytes = nsect << SECTOR_SHIFT ; ssize_t nbytesdone ; if ( ( offset + nbytes ) > media -> size_bytes ) { pr_notice ( " \n " , offset , nbytes ) ; return - EIO ; } if ( write ) { if ( media -> read_only ) return - EACCES ; nbytesdone = file_write ( file , offset , buffer , nbytes ) ; } else { nbytesdone = file_read ( file , offset , buffer , nbytes ) ; } if ( ! likely ( nbytes == nbytesdone ) ) { pr_warning ( " \n " , media -> file_path , __func__ , nbytes , nbytesdone ) ; } return 0 ; }
Handle an I/O request for file.
Handle an I / O request for file .