Esempio n. 1
0
/*
 * We only allow strings that start with 'Y', 'y', or '1'.
 */
static ssize_t
nlm_end_grace_write(struct file *file, const char __user *buf, size_t size,
		    loff_t *pos)
{
	char *data;
	struct lockd_net *ln = net_generic(current->nsproxy->net_ns,
					   lockd_net_id);

	if (size < 1)
		return -EINVAL;

	data = simple_transaction_get(file, buf, size);
	if (IS_ERR(data))
		return PTR_ERR(data);

	switch(data[0]) {
	case 'Y':
	case 'y':
	case '1':
		locks_end_grace(&ln->lockd_manager);
		break;
	default:
		return -EINVAL;
	}

	return size;
}
static ssize_t selinux_transaction_write(struct file *file, const char __user *buf, size_t size, loff_t *pos)
{
	ino_t ino = file->f_path.dentry->d_inode->i_ino;
	char *data;
	ssize_t rv;

	if (ino >= ARRAY_SIZE(write_op) || !write_op[ino])
		return -EINVAL;

	data = simple_transaction_get(file, buf, size);
	if (IS_ERR(data))
		return PTR_ERR(data);

	rv = write_op[ino](file, data, size);
	if (rv > 0) {
		simple_transaction_set(file, rv);
		rv = size;
	}
	return rv;
}