Re: [PATCH v4] proc/mounts: add cursor

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

 



On Fri, Apr 10, 2020 at 07:05:22AM +0200, Miklos Szeredi wrote:
> +	/* read after we'd reached the end? */
> +	if (*pos && list_empty(&mnt->mnt_list))
> +		return NULL;
> +
> +	lock_ns_list(p->ns);
> +	if (!*pos)
> +		mnt = list_first_entry(&p->ns->list, typeof(*mnt), mnt_list);
> +	mnt = mnt_skip_cursors(p->ns, mnt);
> +	unlock_ns_list(p->ns);
>  
> -	p->cached_event = p->ns->event;
> -	p->cached_mount = seq_list_start(&p->ns->list, *pos);
> -	p->cached_index = *pos;
> -	return p->cached_mount;
> +	return mnt;
>  }

Hmm...  I wonder if it would be better to do something like
	if (!*pos)
		prev = &p->ns->list.next;
	else
		prev = &p->mnt.mnt_list.next;
	mnt = mnt_skip_cursors(p->ns, prev);

>  static void *m_next(struct seq_file *m, void *v, loff_t *pos)
>  {
>  	struct proc_mounts *p = m->private;
> +	struct mount *mnt = v;
> +
> +	lock_ns_list(p->ns);
> +	mnt = mnt_skip_cursors(p->ns, list_next_entry(mnt, mnt_list));

... and mnt = mnt_skip_cursors(p->ns, &mnt->mnt_list.next);



[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