aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2008-06-29 22:17:28 -0400
committerJeremy Kerr <jk@ozlabs.org>2008-07-08 20:13:40 -0400
commit23d893f51cde7013e4c29094da2237cce4f20035 (patch)
tree8501d50703820178ede0ea6a96796589c2464c5d
parent87ff6090bfe416c71730654ab53cd4ecffdd675e (diff)
powerpc/spufs: allow spufs files to specify sizes
Currently, spufs never specifies the i_size for the files in context directories, so stat() always reports 0-byte files. This change adds allows the spufs_dir_(nosched_)contents arrays to specify a file size. This allows stat() to report correct file sizes, and makes SEEK_END work. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c4
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c7
-rw-r--r--arch/powerpc/platforms/cell/spufs/spufs.h11
3 files changed, 15 insertions, 7 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index d0a497d9140b..9533a8ad33f2 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -2607,7 +2607,7 @@ static const struct file_operations spufs_ctx_fops = {
2607 .release = single_release, 2607 .release = single_release,
2608}; 2608};
2609 2609
2610struct tree_descr spufs_dir_contents[] = { 2610struct spufs_tree_descr spufs_dir_contents[] = {
2611 { "capabilities", &spufs_caps_fops, 0444, }, 2611 { "capabilities", &spufs_caps_fops, 0444, },
2612 { "mem", &spufs_mem_fops, 0666, }, 2612 { "mem", &spufs_mem_fops, 0666, },
2613 { "regs", &spufs_regs_fops, 0666, }, 2613 { "regs", &spufs_regs_fops, 0666, },
@@ -2647,7 +2647,7 @@ struct tree_descr spufs_dir_contents[] = {
2647 {}, 2647 {},
2648}; 2648};
2649 2649
2650struct tree_descr spufs_dir_nosched_contents[] = { 2650struct spufs_tree_descr spufs_dir_nosched_contents[] = {
2651 { "capabilities", &spufs_caps_fops, 0444, }, 2651 { "capabilities", &spufs_caps_fops, 0444, },
2652 { "mem", &spufs_mem_fops, 0666, }, 2652 { "mem", &spufs_mem_fops, 0666, },
2653 { "mbox", &spufs_mbox_fops, 0444, }, 2653 { "mbox", &spufs_mbox_fops, 0444, },
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index f407b2471855..c662ca783601 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -109,7 +109,7 @@ spufs_setattr(struct dentry *dentry, struct iattr *attr)
109static int 109static int
110spufs_new_file(struct super_block *sb, struct dentry *dentry, 110spufs_new_file(struct super_block *sb, struct dentry *dentry,
111 const struct file_operations *fops, int mode, 111 const struct file_operations *fops, int mode,
112 struct spu_context *ctx) 112 size_t size, struct spu_context *ctx)
113{ 113{
114 static struct inode_operations spufs_file_iops = { 114 static struct inode_operations spufs_file_iops = {
115 .setattr = spufs_setattr, 115 .setattr = spufs_setattr,
@@ -125,6 +125,7 @@ spufs_new_file(struct super_block *sb, struct dentry *dentry,
125 ret = 0; 125 ret = 0;
126 inode->i_op = &spufs_file_iops; 126 inode->i_op = &spufs_file_iops;
127 inode->i_fop = fops; 127 inode->i_fop = fops;
128 inode->i_size = size;
128 inode->i_private = SPUFS_I(inode)->i_ctx = get_spu_context(ctx); 129 inode->i_private = SPUFS_I(inode)->i_ctx = get_spu_context(ctx);
129 d_add(dentry, inode); 130 d_add(dentry, inode);
130out: 131out:
@@ -177,7 +178,7 @@ static int spufs_rmdir(struct inode *parent, struct dentry *dir)
177 return simple_rmdir(parent, dir); 178 return simple_rmdir(parent, dir);
178} 179}
179 180
180static int spufs_fill_dir(struct dentry *dir, struct tree_descr *files, 181static int spufs_fill_dir(struct dentry *dir, struct spufs_tree_descr *files,
181 int mode, struct spu_context *ctx) 182 int mode, struct spu_context *ctx)
182{ 183{
183 struct dentry *dentry, *tmp; 184 struct dentry *dentry, *tmp;
@@ -189,7 +190,7 @@ static int spufs_fill_dir(struct dentry *dir, struct tree_descr *files,
189 if (!dentry) 190 if (!dentry)
190 goto out; 191 goto out;
191 ret = spufs_new_file(dir->d_sb, dentry, files->ops, 192 ret = spufs_new_file(dir->d_sb, dentry, files->ops,
192 files->mode & mode, ctx); 193 files->mode & mode, files->size, ctx);
193 if (ret) 194 if (ret)
194 goto out; 195 goto out;
195 files++; 196 files++;
diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h
index 433dece5c823..413605406bda 100644
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -235,8 +235,15 @@ struct spufs_inode_info {
235#define SPUFS_I(inode) \ 235#define SPUFS_I(inode) \
236 container_of(inode, struct spufs_inode_info, vfs_inode) 236 container_of(inode, struct spufs_inode_info, vfs_inode)
237 237
238extern struct tree_descr spufs_dir_contents[]; 238struct spufs_tree_descr {
239extern struct tree_descr spufs_dir_nosched_contents[]; 239 const char *name;
240 const struct file_operations *ops;
241 int mode;
242 size_t size;
243};
244
245extern struct spufs_tree_descr spufs_dir_contents[];
246extern struct spufs_tree_descr spufs_dir_nosched_contents[];
240 247
241/* system call implementation */ 248/* system call implementation */
242extern struct spufs_calls spufs_calls; 249extern struct spufs_calls spufs_calls;