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

Commit 2c3e4787 authored by Jeremy Kerr's avatar Jeremy Kerr
Browse files

powerpc/spufs: only add ".ctx" file with "debug" mount option



Currently, the .ctx debug file in spu context directories is always
present.

We'd prefer to prevent users from relying on this file, so add a
"debug" mount option to spufs. The .ctx file will only be added to
the context directories when this option is present.

Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
parent 6f7dde81
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -2645,7 +2645,6 @@ struct spufs_tree_descr spufs_dir_contents[] = {
	{ "tid", &spufs_tid_fops, 0444, },
	{ "tid", &spufs_tid_fops, 0444, },
	{ "stat", &spufs_stat_fops, 0444, },
	{ "stat", &spufs_stat_fops, 0444, },
	{ "switch_log", &spufs_switch_log_fops, 0444 },
	{ "switch_log", &spufs_switch_log_fops, 0444 },
	{ ".ctx", &spufs_ctx_fops, 0444, },
	{},
	{},
};
};


@@ -2671,6 +2670,10 @@ struct spufs_tree_descr spufs_dir_nosched_contents[] = {
	{ "object-id", &spufs_object_id_ops, 0666, },
	{ "object-id", &spufs_object_id_ops, 0666, },
	{ "tid", &spufs_tid_fops, 0444, },
	{ "tid", &spufs_tid_fops, 0444, },
	{ "stat", &spufs_stat_fops, 0444, },
	{ "stat", &spufs_stat_fops, 0444, },
	{},
};

struct spufs_tree_descr spufs_dir_debug_contents[] = {
	{ ".ctx", &spufs_ctx_fops, 0444, },
	{ ".ctx", &spufs_ctx_fops, 0444, },
	{},
	{},
};
};
+33 −7
Original line number Original line Diff line number Diff line
@@ -42,10 +42,19 @@


#include "spufs.h"
#include "spufs.h"


struct spufs_sb_info {
	int debug;
};

static struct kmem_cache *spufs_inode_cache;
static struct kmem_cache *spufs_inode_cache;
char *isolated_loader;
char *isolated_loader;
static int isolated_loader_size;
static int isolated_loader_size;


static struct spufs_sb_info *spufs_get_sb_info(struct super_block *sb)
{
	return sb->s_fs_info;
}

static struct inode *
static struct inode *
spufs_alloc_inode(struct super_block *sb)
spufs_alloc_inode(struct super_block *sb)
{
{
@@ -280,6 +289,13 @@ spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags,
	if (ret)
	if (ret)
		goto out_free_ctx;
		goto out_free_ctx;


	if (spufs_get_sb_info(dir->i_sb)->debug)
		ret = spufs_fill_dir(dentry, spufs_dir_debug_contents,
				mode, ctx);

	if (ret)
		goto out_free_ctx;

	d_instantiate(dentry, inode);
	d_instantiate(dentry, inode);
	dget(dentry);
	dget(dentry);
	dir->i_nlink++;
	dir->i_nlink++;
@@ -640,18 +656,19 @@ out:


/* File system initialization */
/* File system initialization */
enum {
enum {
	Opt_uid, Opt_gid, Opt_mode, Opt_err,
	Opt_uid, Opt_gid, Opt_mode, Opt_debug, Opt_err,
};
};


static match_table_t spufs_tokens = {
static match_table_t spufs_tokens = {
	{ Opt_uid,   "uid=%d" },
	{ Opt_uid,   "uid=%d" },
	{ Opt_gid,   "gid=%d" },
	{ Opt_gid,   "gid=%d" },
	{ Opt_mode,  "mode=%o" },
	{ Opt_mode,  "mode=%o" },
	{ Opt_debug, "debug" },
	{ Opt_err,    NULL  },
	{ Opt_err,    NULL  },
};
};


static int
static int
spufs_parse_options(char *options, struct inode *root)
spufs_parse_options(struct super_block *sb, char *options, struct inode *root)
{
{
	char *p;
	char *p;
	substring_t args[MAX_OPT_ARGS];
	substring_t args[MAX_OPT_ARGS];
@@ -679,6 +696,9 @@ spufs_parse_options(char *options, struct inode *root)
				return 0;
				return 0;
			root->i_mode = option | S_IFDIR;
			root->i_mode = option | S_IFDIR;
			break;
			break;
		case Opt_debug:
			spufs_get_sb_info(sb)->debug = 1;
			break;
		default:
		default:
			return 0;
			return 0;
		}
		}
@@ -737,7 +757,7 @@ spufs_create_root(struct super_block *sb, void *data)
	SPUFS_I(inode)->i_ctx = NULL;
	SPUFS_I(inode)->i_ctx = NULL;


	ret = -EINVAL;
	ret = -EINVAL;
	if (!spufs_parse_options(data, inode))
	if (!spufs_parse_options(sb, data, inode))
		goto out_iput;
		goto out_iput;


	ret = -ENOMEM;
	ret = -ENOMEM;
@@ -755,6 +775,7 @@ out:
static int
static int
spufs_fill_super(struct super_block *sb, void *data, int silent)
spufs_fill_super(struct super_block *sb, void *data, int silent)
{
{
	struct spufs_sb_info *info;
	static struct super_operations s_ops = {
	static struct super_operations s_ops = {
		.alloc_inode = spufs_alloc_inode,
		.alloc_inode = spufs_alloc_inode,
		.destroy_inode = spufs_destroy_inode,
		.destroy_inode = spufs_destroy_inode,
@@ -766,11 +787,16 @@ spufs_fill_super(struct super_block *sb, void *data, int silent)


	save_mount_options(sb, data);
	save_mount_options(sb, data);


	info = kzalloc(sizeof(*info), GFP_KERNEL);
	if (!info)
		return -ENOMEM;

	sb->s_maxbytes = MAX_LFS_FILESIZE;
	sb->s_maxbytes = MAX_LFS_FILESIZE;
	sb->s_blocksize = PAGE_CACHE_SIZE;
	sb->s_blocksize = PAGE_CACHE_SIZE;
	sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
	sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
	sb->s_magic = SPUFS_MAGIC;
	sb->s_magic = SPUFS_MAGIC;
	sb->s_op = &s_ops;
	sb->s_op = &s_ops;
	sb->s_fs_info = info;


	return spufs_create_root(sb, data);
	return spufs_create_root(sb, data);
}
}
+1 −0
Original line number Original line Diff line number Diff line
@@ -244,6 +244,7 @@ struct spufs_tree_descr {


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


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