/** * Authenticate with a magic. * * \param inode device inode. * \param file_priv DRM file private. * \param cmd command. * \param arg pointer to a drm_auth structure. * \return zero if authentication successed, or a negative number otherwise. * * Checks if \p file_priv is associated with the magic number passed in \arg. * This ioctl needs protection by the drm_global_mutex, which protects * struct drm_file::magic and struct drm_magic_entry::priv. */ int drm_authmagic(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_auth *auth = data; struct drm_file *file; DRM_DEBUG("%u\n", auth->magic); if ((file = drm_find_file(dev, auth->magic))) { file->authenticated = 1; drm_remove_magic(dev, auth->magic); return 0; } return -EINVAL; }
/*ARGSUSED*/ int drm_authmagic(DRM_IOCTL_ARGS) { drm_auth_t auth; drm_file_t *file; DRM_DEVICE; DRM_COPYFROM_WITH_RETURN(&auth, (void *)data, sizeof (auth)); if ((file = drm_find_file(dev, auth.magic))) { file->authenticated = 1; (void) drm_remove_magic(dev, auth.magic); return (0); } return (EINVAL); }
int drm_authmagic(DRM_IOCTL_ARGS) { drm_auth_t auth; drm_file_t *file; DRM_DEVICE; DRM_COPY_FROM_USER_IOCTL(auth, (drm_auth_t *)data, sizeof(auth)); DRM_DEBUG("%u\n", auth.magic); if ((file = drm_find_file(dev, auth.magic))) { file->authenticated = 1; drm_remove_magic(dev, auth.magic); return 0; } return DRM_ERR(EINVAL); }
/** * Authenticate with a magic. * * \param inode device inode. * \param filp file pointer. * \param cmd command. * \param arg pointer to a drm_auth structure. * \return zero if authentication successed, or a negative number otherwise. * * Checks if \p filp is associated with the magic number passed in \arg. */ int drm_authmagic(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->head->dev; drm_auth_t auth; drm_file_t *file; if (copy_from_user(&auth, (drm_auth_t __user *)arg, sizeof(auth))) return -EFAULT; DRM_DEBUG("%u\n", auth.magic); if ((file = drm_find_file(dev, auth.magic))) { file->authenticated = 1; drm_remove_magic(dev, auth.magic); return 0; } return -EINVAL; }
/** * Marks the client associated with the given magic number as authenticated. */ int drm_authmagic(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_auth *auth = data; struct drm_file *priv; DRM_DEBUG("%u\n", auth->magic); DRM_LOCK(); priv = drm_find_file(dev, auth->magic); if (priv != NULL) { priv->authenticated = 1; drm_remove_magic(dev, auth->magic); DRM_UNLOCK(); return 0; } else { DRM_UNLOCK(); return EINVAL; } }