UPSTREAM: binderfs: add support for feature files
Provide userspace with a mechanism to discover features supported by the binder driver to refrain from using any unsupported ones in the first place. Starting with "oneway_spam_detection" only new features are to be listed under binderfs and all previous ones are assumed to be supported. Assuming an instance of binderfs has been mounted at /dev/binderfs, binder feature files can be found under /dev/binderfs/features/. Usage example: $ mkdir /dev/binderfs $ mount -t binder binder /dev/binderfs $ cat /dev/binderfs/features/oneway_spam_detection 1 Acked-by: Christian Brauner <christian.brauner@ubuntu.com> Signed-off-by: Carlos Llamas <cmllamas@google.com> Link: https://lore.kernel.org/r/20210715031805.1725878-1-cmllamas@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit fc470abf54b2bd6e539065e07905e767b443d719) Bug: 191910201 Signed-off-by: Carlos Llamas <cmllamas@google.com> Change-Id: Ia5c03aa1881981bee26459e741134b83d5b59693
This commit is contained in:
parent
ca0d4326b0
commit
c20a164edd
1 changed files with 39 additions and 0 deletions
|
@ -58,6 +58,10 @@ enum binderfs_stats_mode {
|
||||||
binderfs_stats_mode_global,
|
binderfs_stats_mode_global,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct binder_features {
|
||||||
|
bool oneway_spam_detection;
|
||||||
|
};
|
||||||
|
|
||||||
static const struct constant_table binderfs_param_stats[] = {
|
static const struct constant_table binderfs_param_stats[] = {
|
||||||
{ "global", binderfs_stats_mode_global },
|
{ "global", binderfs_stats_mode_global },
|
||||||
{}
|
{}
|
||||||
|
@ -69,6 +73,10 @@ static const struct fs_parameter_spec binderfs_fs_parameters[] = {
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct binder_features binder_features = {
|
||||||
|
.oneway_spam_detection = true,
|
||||||
|
};
|
||||||
|
|
||||||
static inline struct binderfs_info *BINDERFS_SB(const struct super_block *sb)
|
static inline struct binderfs_info *BINDERFS_SB(const struct super_block *sb)
|
||||||
{
|
{
|
||||||
return sb->s_fs_info;
|
return sb->s_fs_info;
|
||||||
|
@ -581,6 +589,33 @@ out:
|
||||||
return dentry;
|
return dentry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int binder_features_show(struct seq_file *m, void *unused)
|
||||||
|
{
|
||||||
|
bool *feature = m->private;
|
||||||
|
|
||||||
|
seq_printf(m, "%d\n", *feature);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
DEFINE_SHOW_ATTRIBUTE(binder_features);
|
||||||
|
|
||||||
|
static int init_binder_features(struct super_block *sb)
|
||||||
|
{
|
||||||
|
struct dentry *dentry, *dir;
|
||||||
|
|
||||||
|
dir = binderfs_create_dir(sb->s_root, "features");
|
||||||
|
if (IS_ERR(dir))
|
||||||
|
return PTR_ERR(dir);
|
||||||
|
|
||||||
|
dentry = binderfs_create_file(dir, "oneway_spam_detection",
|
||||||
|
&binder_features_fops,
|
||||||
|
&binder_features.oneway_spam_detection);
|
||||||
|
if (IS_ERR(dentry))
|
||||||
|
return PTR_ERR(dentry);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int init_binder_logs(struct super_block *sb)
|
static int init_binder_logs(struct super_block *sb)
|
||||||
{
|
{
|
||||||
struct dentry *binder_logs_root_dir, *dentry, *proc_log_dir;
|
struct dentry *binder_logs_root_dir, *dentry, *proc_log_dir;
|
||||||
|
@ -694,6 +729,10 @@ static int binderfs_fill_super(struct super_block *sb, struct fs_context *fc)
|
||||||
name++;
|
name++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = init_binder_features(sb);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
if (info->mount_opts.stats_mode == binderfs_stats_mode_global)
|
if (info->mount_opts.stats_mode == binderfs_stats_mode_global)
|
||||||
return init_binder_logs(sb);
|
return init_binder_logs(sb);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue