aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2008-07-02 21:42:20 -0400
committerJeremy Kerr <jk@ozlabs.org>2008-07-08 20:13:41 -0400
commit2c3e47871d18f93b8bc2892fb41432111201356d (patch)
tree2336e5a9eaf69bfd92f5eee198a13a1382107a67 /arch
parent6f7dde812defe5bc49cf463ac1579ffeda5cbfd4 (diff)
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: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c5
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c40
-rw-r--r--arch/powerpc/platforms/cell/spufs/spufs.h1
3 files changed, 38 insertions, 8 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index fee645b580cc..99c73066b82f 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -2645,7 +2645,6 @@ struct spufs_tree_descr spufs_dir_contents[] = {
2645 { "tid", &spufs_tid_fops, 0444, }, 2645 { "tid", &spufs_tid_fops, 0444, },
2646 { "stat", &spufs_stat_fops, 0444, }, 2646 { "stat", &spufs_stat_fops, 0444, },
2647 { "switch_log", &spufs_switch_log_fops, 0444 }, 2647 { "switch_log", &spufs_switch_log_fops, 0444 },
2648 { ".ctx", &spufs_ctx_fops, 0444, },
2649 {}, 2648 {},
2650}; 2649};
2651 2650
@@ -2671,6 +2670,10 @@ struct spufs_tree_descr spufs_dir_nosched_contents[] = {
2671 { "object-id", &spufs_object_id_ops, 0666, }, 2670 { "object-id", &spufs_object_id_ops, 0666, },
2672 { "tid", &spufs_tid_fops, 0444, }, 2671 { "tid", &spufs_tid_fops, 0444, },
2673 { "stat", &spufs_stat_fops, 0444, }, 2672 { "stat", &spufs_stat_fops, 0444, },
2673 {},
2674};
2675
2676struct spufs_tree_descr spufs_dir_debug_contents[] = {
2674 { ".ctx", &spufs_ctx_fops, 0444, }, 2677 { ".ctx", &spufs_ctx_fops, 0444, },
2675 {}, 2678 {},
2676}; 2679};
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index c662ca783601..7123472801d9 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -42,10 +42,19 @@
42 42
43#include "spufs.h" 43#include "spufs.h"
44 44
45struct spufs_sb_info {
46 int debug;
47};
48
45static struct kmem_cache *spufs_inode_cache; 49static struct kmem_cache *spufs_inode_cache;
46char *isolated_loader; 50char *isolated_loader;
47static int isolated_loader_size; 51static int isolated_loader_size;
48 52
53static struct spufs_sb_info *spufs_get_sb_info(struct super_block *sb)
54{
55 return sb->s_fs_info;
56}
57
49static struct inode * 58static struct inode *
50spufs_alloc_inode(struct super_block *sb) 59spufs_alloc_inode(struct super_block *sb)
51{ 60{
@@ -280,6 +289,13 @@ spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags,
280 if (ret) 289 if (ret)
281 goto out_free_ctx; 290 goto out_free_ctx;
282 291
292 if (spufs_get_sb_info(dir->i_sb)->debug)
293 ret = spufs_fill_dir(dentry, spufs_dir_debug_contents,
294 mode, ctx);
295
296 if (ret)
297 goto out_free_ctx;
298
283 d_instantiate(dentry, inode); 299 d_instantiate(dentry, inode);
284 dget(dentry); 300 dget(dentry);
285 dir->i_nlink++; 301 dir->i_nlink++;
@@ -640,18 +656,19 @@ out:
640 656
641/* File system initialization */ 657/* File system initialization */
642enum { 658enum {
643 Opt_uid, Opt_gid, Opt_mode, Opt_err, 659 Opt_uid, Opt_gid, Opt_mode, Opt_debug, Opt_err,
644}; 660};
645 661
646static match_table_t spufs_tokens = { 662static match_table_t spufs_tokens = {
647 { Opt_uid, "uid=%d" }, 663 { Opt_uid, "uid=%d" },
648 { Opt_gid, "gid=%d" }, 664 { Opt_gid, "gid=%d" },
649 { Opt_mode, "mode=%o" }, 665 { Opt_mode, "mode=%o" },
650 { Opt_err, NULL }, 666 { Opt_debug, "debug" },
667 { Opt_err, NULL },
651}; 668};
652 669
653static int 670static int
654spufs_parse_options(char *options, struct inode *root) 671spufs_parse_options(struct super_block *sb, char *options, struct inode *root)
655{ 672{
656 char *p; 673 char *p;
657 substring_t args[MAX_OPT_ARGS]; 674 substring_t args[MAX_OPT_ARGS];
@@ -679,6 +696,9 @@ spufs_parse_options(char *options, struct inode *root)
679 return 0; 696 return 0;
680 root->i_mode = option | S_IFDIR; 697 root->i_mode = option | S_IFDIR;
681 break; 698 break;
699 case Opt_debug:
700 spufs_get_sb_info(sb)->debug = 1;
701 break;
682 default: 702 default:
683 return 0; 703 return 0;
684 } 704 }
@@ -737,7 +757,7 @@ spufs_create_root(struct super_block *sb, void *data)
737 SPUFS_I(inode)->i_ctx = NULL; 757 SPUFS_I(inode)->i_ctx = NULL;
738 758
739 ret = -EINVAL; 759 ret = -EINVAL;
740 if (!spufs_parse_options(data, inode)) 760 if (!spufs_parse_options(sb, data, inode))
741 goto out_iput; 761 goto out_iput;
742 762
743 ret = -ENOMEM; 763 ret = -ENOMEM;
@@ -755,6 +775,7 @@ out:
755static int 775static int
756spufs_fill_super(struct super_block *sb, void *data, int silent) 776spufs_fill_super(struct super_block *sb, void *data, int silent)
757{ 777{
778 struct spufs_sb_info *info;
758 static struct super_operations s_ops = { 779 static struct super_operations s_ops = {
759 .alloc_inode = spufs_alloc_inode, 780 .alloc_inode = spufs_alloc_inode,
760 .destroy_inode = spufs_destroy_inode, 781 .destroy_inode = spufs_destroy_inode,
@@ -766,11 +787,16 @@ spufs_fill_super(struct super_block *sb, void *data, int silent)
766 787
767 save_mount_options(sb, data); 788 save_mount_options(sb, data);
768 789
790 info = kzalloc(sizeof(*info), GFP_KERNEL);
791 if (!info)
792 return -ENOMEM;
793
769 sb->s_maxbytes = MAX_LFS_FILESIZE; 794 sb->s_maxbytes = MAX_LFS_FILESIZE;
770 sb->s_blocksize = PAGE_CACHE_SIZE; 795 sb->s_blocksize = PAGE_CACHE_SIZE;
771 sb->s_blocksize_bits = PAGE_CACHE_SHIFT; 796 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
772 sb->s_magic = SPUFS_MAGIC; 797 sb->s_magic = SPUFS_MAGIC;
773 sb->s_op = &s_ops; 798 sb->s_op = &s_ops;
799 sb->s_fs_info = info;
774 800
775 return spufs_create_root(sb, data); 801 return spufs_create_root(sb, data);
776} 802}
diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h
index 413605406bda..8ae8ef9dfc22 100644
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -244,6 +244,7 @@ struct spufs_tree_descr {
244 244
245extern struct spufs_tree_descr spufs_dir_contents[]; 245extern struct spufs_tree_descr spufs_dir_contents[];
246extern struct spufs_tree_descr spufs_dir_nosched_contents[]; 246extern struct spufs_tree_descr spufs_dir_nosched_contents[];
247extern struct spufs_tree_descr spufs_dir_debug_contents[];
247 248
248/* system call implementation */ 249/* system call implementation */
249extern struct spufs_calls spufs_calls; 250extern struct spufs_calls spufs_calls;