示例#1
0
static int libcfs_ioctl(struct cfs_psdev_file *pfile,
			unsigned long cmd, void *arg)
{
	char    *buf;
	struct libcfs_ioctl_data *data;
	int err = 0;
	ENTRY;

	LIBCFS_ALLOC_GFP(buf, 1024, GFP_IOFS);
	if (buf == NULL)
		RETURN(-ENOMEM);

        /* 'cmd' and permissions get checked in our arch-specific caller */
        if (libcfs_ioctl_getdata(buf, buf + 800, (void *)arg)) {
                CERROR("PORTALS ioctl: data error\n");
                GOTO(out, err = -EINVAL);
        }
        data = (struct libcfs_ioctl_data *)buf;

        err = libcfs_ioctl_int(pfile, cmd, arg, data);

out:
        LIBCFS_FREE(buf, 1024);
        RETURN(err);
}
示例#2
0
int libcfs_ioctl(unsigned long cmd, void __user *uparam)
{
	struct libcfs_ioctl_data *data = NULL;
	struct libcfs_ioctl_hdr *hdr;
	int err;

	/* 'cmd' and permissions get checked in our arch-specific caller */
	err = libcfs_ioctl_getdata(&hdr, uparam);
	if (err) {
		CDEBUG_LIMIT(D_ERROR,
			     "libcfs ioctl: data header error %d\n", err);
		return err;
	}

	if (hdr->ioc_version == LIBCFS_IOCTL_VERSION) {
		/*
		 * The libcfs_ioctl_data_adjust() function performs adjustment
		 * operations on the libcfs_ioctl_data structure to make
		 * it usable by the code.  This doesn't need to be called
		 * for new data structures added.
		 */
		data = container_of(hdr, struct libcfs_ioctl_data, ioc_hdr);
		err = libcfs_ioctl_data_adjust(data);
		if (err)
			goto out;
	}