Beispiel #1
0
SYSCALL_DEFINE5(pwritev, unsigned long, fd, const struct iovec __user *, vec,
		unsigned long, vlen, unsigned long, pos_l, unsigned long, pos_h)
{
	loff_t pos = pos_from_hilo(pos_h, pos_l);
	struct file *file;
	ssize_t ret = -EBADF;
	int fput_needed;

	if (pos < 0)
		return -EINVAL;

	if (scribe_track_next_file_write_interruptible())
		return -ENOMEM;

	file = fget_light(fd, &fput_needed);
	if (file) {
		ret = -ESPIPE;
		if (file->f_mode & FMODE_PWRITE)
			ret = vfs_writev(file, vec, vlen, &pos);
		fput_light(file, fput_needed);
	} else if (scribe_was_file_locking_interrupted())
		ret = -ERESTARTSYS;

	if (ret > 0)
		add_wchar(current, ret);
	inc_syscw(current);
	return ret;
}
void
rumpcomp_virtif_send(struct virtif_user *vu, struct iovec *iov, size_t niov)
{
	mm_segment_t oseg;
	loff_t off = 0;
	ssize_t nn;

	oseg = get_fs();
	set_fs(get_ds());
	/* something is written, rest (if any) is dropped */
	KLOCK_WRAP(nn = vfs_writev(vu->tapfile, iov, niov, &off));
	set_fs(oseg);
}
Beispiel #3
0
asmlinkage ssize_t
sys_writev(unsigned long fd, const struct iovec __user *vec, unsigned long vlen)
{
   struct file *file;
   ssize_t ret = -EBADF;
   int fput_needed;

   file = fget_light(fd, &fput_needed);
   if (file) {
      ret = vfs_writev(file, vec, vlen, &file->f_pos);
      fput_light(file, fput_needed);
   }

   return ret;
}
/**
 *  tag: the tag of this command
 *  msg: concrete command string to write to /dev/log/exception
 *  return: on success return the bytes writed successfully, on error return -1
 *
*/
int log_to_exception(char* tag, char* msg)
{

    mm_segment_t oldfs;
    struct file *file;
    unsigned char * prio_err = "6";//ANDROID_ERROR
    int ret = 0;
    struct iovec vec[3];

    if(NULL == tag || NULL == msg)
    {
        pr_err("log_exception: the arguments invalidate\n");
        return -1;
    }

    oldfs = get_fs();
    set_fs(KERNEL_DS);

    file = filp_open(LOG_EXCEPTION_FS,O_RDWR,0);

    if(!file || IS_ERR(file))
    {
        pr_err("log_exception: Failed to access /dev/log/exception\n");
        set_fs(oldfs);
        return -1;
    }

    vec[0].iov_base = prio_err;
    vec[0].iov_len = 1;
    vec[1].iov_base = tag;
    vec[1].iov_len = strlen(tag) + 1;
    vec[2].iov_base = msg;
    vec[2].iov_len = strlen(msg)+1;
    ret = vfs_writev(file, &vec[0], 3, &file->f_pos);
    if(ret < 0)
    {
        pr_err("log_exception: Failed to write to /dev/log/exception\n");
        filp_close(file, NULL);
        set_fs(oldfs);
        return -1;
    }

    filp_close(file, NULL);
    set_fs(oldfs);
    return ret;
}
Beispiel #5
0
static void handle_faf_writev(struct rpc_desc *desc, void *__msg, size_t size)
{
	struct faf_rw_msg *msg = __msg;
	struct faf_rw_ret ret;
	struct file *file;
	struct iovec *iov;
	int iovcnt, err;

	err = alloc_iov(&iov, &iovcnt, msg->count);
	if (!err) {
		err = recv_iov(desc, iov, iovcnt, msg->count, 0);
		if (err)
			goto cancel;
	} else {
		ret.ret = err;
		iov = NULL;
	}

	err = remote_sleep_prepare(desc);
	if (err)
		goto cancel;

	ret.pos = msg->pos;
	if (iov) {
		file = fget(msg->server_fd);
		ret.ret = vfs_writev(file, iov, iovcnt, &ret.pos);
		fput(file);
	}

	remote_sleep_finish();

	err = rpc_pack_type(desc, ret);
	if (err)
		goto cancel;

out_free:
	if (iov)
		free_iov(iov, iovcnt);

	return;

cancel:
	rpc_cancel(desc);
	goto out_free;
}
Beispiel #6
0
SYSCALL_DEFINE3(writev, unsigned long, fd, const struct iovec __user *, vec,
		unsigned long, vlen)
{
	struct fd f = fdget(fd);
	ssize_t ret = -EBADF;

	if (f.file) {
		loff_t pos = file_pos_read(f.file);
		ret = vfs_writev(f.file, vec, vlen, &pos);
		file_pos_write(f.file, pos);
		fdput(f);
	}

	if (ret > 0)
		add_wchar(current, ret);
	inc_syscw(current);
	return ret;
}
Beispiel #7
0
static ssize_t do_writev(unsigned long fd, const struct iovec __user *vec,
			 unsigned long vlen, int flags)
{
	struct fd f = fdget_pos(fd);
	ssize_t ret = -EBADF;

	if (f.file) {
		loff_t pos = file_pos_read(f.file);
		ret = vfs_writev(f.file, vec, vlen, &pos, flags);
		if (ret >= 0)
			file_pos_write(f.file, pos);
		fdput_pos(f);
	}

	if (ret > 0)
		add_wchar(current, ret);
	inc_syscw(current);
	return ret;
}
Beispiel #8
0
asmlinkage ssize_t
sys_writev(unsigned long fd, const struct iovec __user *vec, unsigned long vlen)
{
	struct file *file;
	ssize_t ret = -EBADF;
	int fput_needed;

	file = fget_light(fd, &fput_needed);
	if (file) {
		loff_t pos = file_pos_read(file);
		ret = vfs_writev(file, vec, vlen, &pos);
		file_pos_write(file, pos);
		fput_light(file, fput_needed);
	}

	if (ret > 0)
		current->wchar += ret;
	current->syscw++;
	return ret;
}
Beispiel #9
0
SYSCALL_DEFINE3(writev, unsigned long, fd, const struct iovec __user *, vec,
		unsigned long, vlen)
{
	struct file *file;
	ssize_t ret = -EBADF;
	int fput_needed;

	file = fget_light(fd, &fput_needed);
	if (file) {
		loff_t pos = file_pos_read(file);
		ret = vfs_writev(file, vec, vlen, &pos);
		file_pos_write(file, pos);
		fput_light(file, fput_needed);
	}

	if (ret > 0)
		add_wchar(current, ret);
	inc_syscw(current);
	return ret;
}
Beispiel #10
0
static ssize_t do_pwritev(unsigned long fd, const struct iovec __user *vec,
			  unsigned long vlen, loff_t pos, int flags)
{
	struct fd f;
	ssize_t ret = -EBADF;

	if (pos < 0)
		return -EINVAL;

	f = fdget(fd);
	if (f.file) {
		ret = -ESPIPE;
		if (f.file->f_mode & FMODE_PWRITE)
			ret = vfs_writev(f.file, vec, vlen, &pos, flags);
		fdput(f);
	}

	if (ret > 0)
		add_wchar(current, ret);
	inc_syscw(current);
	return ret;
}
Beispiel #11
0
static int fd_do_writev(struct se_task *task)
{
	struct fd_request *req = FILE_REQ(task);
	struct se_device *se_dev = req->fd_task.task_se_cmd->se_dev;
	struct fd_dev *dev = se_dev->dev_ptr;
	struct file *fd = dev->fd_file;
	struct scatterlist *sg = task->task_sg;
	struct iovec *iov;
	mm_segment_t old_fs;
	loff_t pos = (task->task_lba *
		      se_dev->se_sub_dev->se_dev_attrib.block_size);
	int ret, i = 0;

	iov = kzalloc(sizeof(struct iovec) * task->task_sg_nents, GFP_KERNEL);
	if (!iov) {
		pr_err("Unable to allocate fd_do_writev iov[]\n");
		return -ENOMEM;
	}

	for (i = 0; i < task->task_sg_nents; i++) {
		iov[i].iov_len = sg[i].length;
		iov[i].iov_base = sg_virt(&sg[i]);
	}

	old_fs = get_fs();
	set_fs(get_ds());
	ret = vfs_writev(fd, &iov[0], task->task_sg_nents, &pos);
	set_fs(old_fs);

	kfree(iov);

	if (ret < 0 || ret != task->task_size) {
		pr_err("vfs_writev() returned %d\n", ret);
		return (ret < 0 ? ret : -EINVAL);
	}

	return 1;
}
Beispiel #12
0
SYSCALL_DEFINE5(pwritev, unsigned long, fd, const struct iovec __user *, vec,
		unsigned long, vlen, unsigned long, pos_l, unsigned long, pos_h)
{
	loff_t pos = pos_from_hilo(pos_h, pos_l);
	struct fd f;
	ssize_t ret = -EBADF;

	if (pos < 0)
		return -EINVAL;

	f = fdget(fd);
	if (f.file) {
		ret = -ESPIPE;
		if (f.file->f_mode & FMODE_PWRITE)
			ret = vfs_writev(f.file, vec, vlen, &pos);
		fdput(f);
	}

	if (ret > 0)
		add_wchar(current, ret);
	inc_syscw(current);
	return ret;
}
Beispiel #13
0
SYSCALL_DEFINE3(writev, unsigned long, fd, const struct iovec __user *, vec,
		unsigned long, vlen)
{
	struct file *file;
	ssize_t ret = -EBADF;
	int fput_needed;

	if (scribe_track_next_file_write_interruptible())
		return -ENOMEM;

	file = fget_light(fd, &fput_needed);
	if (file) {
		loff_t pos = file_pos_read(file);
		ret = vfs_writev(file, vec, vlen, &pos);
		file_pos_write(file, pos);
		fput_light(file, fput_needed);
	} else if (scribe_was_file_locking_interrupted())
		ret = -ERESTARTSYS;

	if (ret > 0)
		add_wchar(current, ret);
	inc_syscw(current);
	return ret;
}