Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 23d893f5 authored by Jeremy Kerr's avatar Jeremy Kerr
Browse files

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: default avatarJeremy Kerr <jk@ozlabs.org>
parent 87ff6090
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -2607,7 +2607,7 @@ static const struct file_operations spufs_ctx_fops = {
	.release        = single_release,
	.release        = single_release,
};
};


struct tree_descr spufs_dir_contents[] = {
struct spufs_tree_descr spufs_dir_contents[] = {
	{ "capabilities", &spufs_caps_fops, 0444, },
	{ "capabilities", &spufs_caps_fops, 0444, },
	{ "mem",  &spufs_mem_fops,  0666, },
	{ "mem",  &spufs_mem_fops,  0666, },
	{ "regs", &spufs_regs_fops,  0666, },
	{ "regs", &spufs_regs_fops,  0666, },
@@ -2647,7 +2647,7 @@ struct tree_descr spufs_dir_contents[] = {
	{},
	{},
};
};


struct tree_descr spufs_dir_nosched_contents[] = {
struct spufs_tree_descr spufs_dir_nosched_contents[] = {
	{ "capabilities", &spufs_caps_fops, 0444, },
	{ "capabilities", &spufs_caps_fops, 0444, },
	{ "mem",  &spufs_mem_fops,  0666, },
	{ "mem",  &spufs_mem_fops,  0666, },
	{ "mbox", &spufs_mbox_fops, 0444, },
	{ "mbox", &spufs_mbox_fops, 0444, },
+4 −3
Original line number Original line Diff line number Diff line
@@ -109,7 +109,7 @@ spufs_setattr(struct dentry *dentry, struct iattr *attr)
static int
static int
spufs_new_file(struct super_block *sb, struct dentry *dentry,
spufs_new_file(struct super_block *sb, struct dentry *dentry,
		const struct file_operations *fops, int mode,
		const struct file_operations *fops, int mode,
		struct spu_context *ctx)
		size_t size, struct spu_context *ctx)
{
{
	static struct inode_operations spufs_file_iops = {
	static struct inode_operations spufs_file_iops = {
		.setattr = spufs_setattr,
		.setattr = spufs_setattr,
@@ -125,6 +125,7 @@ spufs_new_file(struct super_block *sb, struct dentry *dentry,
	ret = 0;
	ret = 0;
	inode->i_op = &spufs_file_iops;
	inode->i_op = &spufs_file_iops;
	inode->i_fop = fops;
	inode->i_fop = fops;
	inode->i_size = size;
	inode->i_private = SPUFS_I(inode)->i_ctx = get_spu_context(ctx);
	inode->i_private = SPUFS_I(inode)->i_ctx = get_spu_context(ctx);
	d_add(dentry, inode);
	d_add(dentry, inode);
out:
out:
@@ -177,7 +178,7 @@ static int spufs_rmdir(struct inode *parent, struct dentry *dir)
	return simple_rmdir(parent, dir);
	return simple_rmdir(parent, dir);
}
}


static int spufs_fill_dir(struct dentry *dir, struct tree_descr *files,
static int spufs_fill_dir(struct dentry *dir, struct spufs_tree_descr *files,
			  int mode, struct spu_context *ctx)
			  int mode, struct spu_context *ctx)
{
{
	struct dentry *dentry, *tmp;
	struct dentry *dentry, *tmp;
@@ -189,7 +190,7 @@ static int spufs_fill_dir(struct dentry *dir, struct tree_descr *files,
		if (!dentry)
		if (!dentry)
			goto out;
			goto out;
		ret = spufs_new_file(dir->d_sb, dentry, files->ops,
		ret = spufs_new_file(dir->d_sb, dentry, files->ops,
					files->mode & mode, ctx);
					files->mode & mode, files->size, ctx);
		if (ret)
		if (ret)
			goto out;
			goto out;
		files++;
		files++;
+9 −2
Original line number Original line Diff line number Diff line
@@ -235,8 +235,15 @@ struct spufs_inode_info {
#define SPUFS_I(inode) \
#define SPUFS_I(inode) \
	container_of(inode, struct spufs_inode_info, vfs_inode)
	container_of(inode, struct spufs_inode_info, vfs_inode)


extern struct tree_descr spufs_dir_contents[];
struct spufs_tree_descr {
extern struct tree_descr spufs_dir_nosched_contents[];
	const char *name;
	const struct file_operations *ops;
	int mode;
	size_t size;
};

extern struct spufs_tree_descr spufs_dir_contents[];
extern struct spufs_tree_descr spufs_dir_nosched_contents[];


/* system call implementation */
/* system call implementation */
extern struct spufs_calls spufs_calls;
extern struct spufs_calls spufs_calls;