Re: [PATCH 24/28] proc: Supply an accessor to get the name in a proc_dir_entry struct [RFC]
Hi David, On Tue, Apr 16, 2013 at 07:27:25PM +0100, David Howells wrote: > This is only needed by the xt_hashlimit netfilter module as that appears to > use the name in the pde to save a label in the xt_hashlimit_htable struct - > which will be a problem if CONFIG_PROC_FS=n. I don't know the larger context of this patch (and am not follwing filesystem related work in general), but at least from the xt_hashlimit point of view this of course looks fine. We can always wrap direct accesses to structure members behind an API call. For consistency reasons 'proc_get_name()' might be a better name than get_proc_name(), but that's probably a matter of taste. Pleaes note that I'm only the original author but not the active maintainer of the xt_hashlimit (formerly ipt_hashlimit) code. Regards, Harald -- - Harald Welte http://netfilter.org/ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed."-- Paul Vixie -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 24/28] proc: Supply an accessor to get the name in a proc_dir_entry struct [RFC]
Supply an accessor to get access to the name in a proc_dir_entry struct, just returning a const pointer to it. This is only needed by the xt_hashlimit netfilter module as that appears to use the name in the pde to save a label in the xt_hashlimit_htable struct - which will be a problem if CONFIG_PROC_FS=n. Signed-off-by: David Howells cc: Harald Welte cc: Jan Engelhardt cc: netfilter-de...@vger.kernel.org --- fs/proc/generic.c|6 ++ include/linux/proc_fs.h |1 + net/netfilter/xt_hashlimit.c |2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/proc/generic.c b/fs/proc/generic.c index 75e08d3..2c6d6be 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c @@ -624,3 +624,9 @@ void *proc_get_parent_data(const struct inode *inode) return de->parent->data; } EXPORT_SYMBOL_GPL(proc_get_parent_data); + +const char *get_proc_name(const struct proc_dir_entry *de) +{ + return de->name; +} +EXPORT_SYMBOL_GPL(get_proc_name); diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 12694ef..718e966 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h @@ -87,6 +87,7 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode, extern void proc_set_size(struct proc_dir_entry *, loff_t); extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t); extern void *proc_get_parent_data(const struct inode *); +extern const char *get_proc_name(const struct proc_dir_entry *); #else static inline void proc_flush_task(struct task_struct *task) diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index ebfad03..d2fd53b 100644 --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c @@ -344,7 +344,7 @@ static struct xt_hashlimit_htable *htable_find_get(struct net *net, struct xt_hashlimit_htable *hinfo; hlist_for_each_entry(hinfo, _net->htables, node) { - if (!strcmp(name, hinfo->pde->name) && + if (!strcmp(name, get_proc_name(hinfo->pde)) && hinfo->family == family) { hinfo->use++; return hinfo; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 24/28] proc: Supply an accessor to get the name in a proc_dir_entry struct [RFC]
Supply an accessor to get access to the name in a proc_dir_entry struct, just returning a const pointer to it. This is only needed by the xt_hashlimit netfilter module as that appears to use the name in the pde to save a label in the xt_hashlimit_htable struct - which will be a problem if CONFIG_PROC_FS=n. Signed-off-by: David Howells dhowe...@redhat.com cc: Harald Welte lafo...@netfilter.org cc: Jan Engelhardt jeng...@medozas.de cc: netfilter-de...@vger.kernel.org --- fs/proc/generic.c|6 ++ include/linux/proc_fs.h |1 + net/netfilter/xt_hashlimit.c |2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/proc/generic.c b/fs/proc/generic.c index 75e08d3..2c6d6be 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c @@ -624,3 +624,9 @@ void *proc_get_parent_data(const struct inode *inode) return de-parent-data; } EXPORT_SYMBOL_GPL(proc_get_parent_data); + +const char *get_proc_name(const struct proc_dir_entry *de) +{ + return de-name; +} +EXPORT_SYMBOL_GPL(get_proc_name); diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 12694ef..718e966 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h @@ -87,6 +87,7 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode, extern void proc_set_size(struct proc_dir_entry *, loff_t); extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t); extern void *proc_get_parent_data(const struct inode *); +extern const char *get_proc_name(const struct proc_dir_entry *); #else static inline void proc_flush_task(struct task_struct *task) diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index ebfad03..d2fd53b 100644 --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c @@ -344,7 +344,7 @@ static struct xt_hashlimit_htable *htable_find_get(struct net *net, struct xt_hashlimit_htable *hinfo; hlist_for_each_entry(hinfo, hashlimit_net-htables, node) { - if (!strcmp(name, hinfo-pde-name) + if (!strcmp(name, get_proc_name(hinfo-pde)) hinfo-family == family) { hinfo-use++; return hinfo; -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 24/28] proc: Supply an accessor to get the name in a proc_dir_entry struct [RFC]
Hi David, On Tue, Apr 16, 2013 at 07:27:25PM +0100, David Howells wrote: This is only needed by the xt_hashlimit netfilter module as that appears to use the name in the pde to save a label in the xt_hashlimit_htable struct - which will be a problem if CONFIG_PROC_FS=n. I don't know the larger context of this patch (and am not follwing filesystem related work in general), but at least from the xt_hashlimit point of view this of course looks fine. We can always wrap direct accesses to structure members behind an API call. For consistency reasons 'proc_get_name()' might be a better name than get_proc_name(), but that's probably a matter of taste. Pleaes note that I'm only the original author but not the active maintainer of the xt_hashlimit (formerly ipt_hashlimit) code. Regards, Harald -- - Harald Welte lafo...@netfilter.org http://netfilter.org/ Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed.-- Paul Vixie -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/