diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2008-06-29 22:17:28 -0400 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2008-07-08 20:13:40 -0400 |
commit | 23d893f51cde7013e4c29094da2237cce4f20035 (patch) | |
tree | 8501d50703820178ede0ea6a96796589c2464c5d | |
parent | 87ff6090bfe416c71730654ab53cd4ecffdd675e (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.c | 4 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/inode.c | 7 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/spufs.h | 11 |
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 | ||
2610 | struct tree_descr spufs_dir_contents[] = { | 2610 | struct 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 | ||
2650 | struct tree_descr spufs_dir_nosched_contents[] = { | 2650 | struct 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) | |||
109 | static int | 109 | static int |
110 | spufs_new_file(struct super_block *sb, struct dentry *dentry, | 110 | spufs_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); |
130 | out: | 131 | out: |
@@ -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 | ||
180 | static int spufs_fill_dir(struct dentry *dir, struct tree_descr *files, | 181 | static 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 | ||
238 | extern struct tree_descr spufs_dir_contents[]; | 238 | struct spufs_tree_descr { |
239 | extern 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 | |||
245 | extern struct spufs_tree_descr spufs_dir_contents[]; | ||
246 | extern struct spufs_tree_descr spufs_dir_nosched_contents[]; | ||
240 | 247 | ||
241 | /* system call implementation */ | 248 | /* system call implementation */ |
242 | extern struct spufs_calls spufs_calls; | 249 | extern struct spufs_calls spufs_calls; |