Re: [patch 3/7] procfs: Add ability to plug in auxiliary fdinfo providers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 27, 2012 at 07:48:28AM +0400, Pavel Emelyanov wrote:
> > +static int prep_fdinfo_driver(struct proc_fdinfo_extra *extra)
> > +{
> > +	struct proc_fdinfo_driver *s;
> > +
> > +	down_read(&fdinfo_drivers_sem);
> > +	list_for_each_entry(s, &fdinfo_drivers, list) {
> > +		if (s->probe(extra->f_file)) {
> > +			extra->driver = s;
> > +			break;
> > +		}
> > +	}
> > +	up_read(&fdinfo_drivers_sem);
> > +
> > +	return 0;
> > +}
> 
> Maybe a simple list of file_operations:seq_operations mappings would be simpler?

Yeah, I thought about it. This seems to be a way more simplier.
I think i'll switch to this.

> 
> > +static void *seq_next(struct seq_file *m, void *p, loff_t *pos)
> > +{
> > +	struct proc_fdinfo_extra *extra = m->private;
> > +	void *v = NULL;
> > +
> > +	if (extra->driver) {
> > +		int ret = 0;
> > +
> > +		if (*pos == 0) {
> > +			v = extra->driver->ops->start(m, pos);
> > +			if (v) {
> > +				ret = extra->driver->ops->show(m, v);
> 
> Why is it necessary to call ->show here? The logic should be
> 
> seq_start = (pos == 0 ? nop : extra->start)
> seq_next  = (pos == 0 ? extra->start : extra->next)
> seq_stop  = (pos == 0 ? nop : extra->stop)
> seq_show  = (pos == 0 ? proc_show : extra->show)
> 
> Or I'm missing something?

Well, I thought about it as two sequences -- first is procfs
seq-file, which prints out a general header, and second
is extra fdinfo provider.

Everything starts with printing procfs header

seq_start -> seq_show (prints "pos:\t%lli\nflags:\t0%o\n") ->
seq_next -> (if have extra driver we do extra's start/show at first,
then next and etc). In other words general header should be
shown always even if extra's start() fails.

	Cyrill
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux