0001
0002 #include <linux/file.h>
0003 #include <linux/fs.h>
0004 #include <linux/export.h>
0005 #include <linux/mount.h>
0006 #include <linux/namei.h>
0007 #include <linux/slab.h>
0008
0009 #include <linux/uaccess.h>
0010
0011 #include "spufs.h"
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 static long do_spu_run(struct file *filp,
0035 __u32 __user *unpc,
0036 __u32 __user *ustatus)
0037 {
0038 long ret;
0039 struct spufs_inode_info *i;
0040 u32 npc, status;
0041
0042 ret = -EFAULT;
0043 if (get_user(npc, unpc))
0044 goto out;
0045
0046
0047 ret = -EINVAL;
0048 if (filp->f_op != &spufs_context_fops)
0049 goto out;
0050
0051 i = SPUFS_I(file_inode(filp));
0052 ret = spufs_run_spu(i->i_ctx, &npc, &status);
0053
0054 if (put_user(npc, unpc))
0055 ret = -EFAULT;
0056
0057 if (ustatus && put_user(status, ustatus))
0058 ret = -EFAULT;
0059 out:
0060 return ret;
0061 }
0062
0063 static long do_spu_create(const char __user *pathname, unsigned int flags,
0064 umode_t mode, struct file *neighbor)
0065 {
0066 struct path path;
0067 struct dentry *dentry;
0068 int ret;
0069
0070 dentry = user_path_create(AT_FDCWD, pathname, &path, LOOKUP_DIRECTORY);
0071 ret = PTR_ERR(dentry);
0072 if (!IS_ERR(dentry)) {
0073 ret = spufs_create(&path, dentry, flags, mode, neighbor);
0074 done_path_create(&path, dentry);
0075 }
0076
0077 return ret;
0078 }
0079
0080 struct spufs_calls spufs_calls = {
0081 .create_thread = do_spu_create,
0082 .spu_run = do_spu_run,
0083 .notify_spus_active = do_notify_spus_active,
0084 .owner = THIS_MODULE,
0085 #ifdef CONFIG_COREDUMP
0086 .coredump_extra_notes_size = spufs_coredump_extra_notes_size,
0087 .coredump_extra_notes_write = spufs_coredump_extra_notes_write,
0088 #endif
0089 };