Re: [PATCH 12/12] cgroup: unify pidlist and other file handling

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

 



> +static void *cgroup_seqfile_start(struct seq_file *seq, loff_t *ppos)
> +{
> +	struct cftype *cft = seq_cft(seq);
> +
> +	if (cft->seq_start) {
> +		return cft->seq_start(seq, ppos);
> +	} else {
> +		/*
> +		 * The same behavior and code as single_open().  Returns
> +		 * !NULL if pos is at the beginning; otherwise, NULL.
> +		 */

Isn't it simpler to choose between seq_open() and single_open() depending
on if cft->seq_start is implemented?

> +		return NULL + !*ppos;
> +	}
> +}
...
>  static int cgroup_file_open(struct inode *inode, struct file *file)
>  {
>  	struct cfent *cfe = __d_cfe(file->f_dentry);
> @@ -2338,20 +2384,17 @@ static int cgroup_file_open(struct inode *inode, struct file *file)
>  	WARN_ON_ONCE(cfe->css && cfe->css != css);
>  	cfe->css = css;
>  
> -	if (cft->open) {
> -		err = cft->open(inode, file);
> -	} else {
> -		err = single_open_size(file, cgroup_seqfile_show, cfe,
> -				       sizeof(struct cgroup_open_file));
> -		if (!err) {
> -			struct seq_file *sf = file->private_data;
> -			struct cgroup_open_file *of = sf->private;
> +	err = seq_open_private(file, &cgroup_seq_operations,
> +			       sizeof(struct cgroup_open_file));
> +	if (!err) {
> +		struct seq_file *sf = file->private_data;
> +		struct cgroup_open_file *of = sf->private;
>  
> -			of->cfe = cfe;
> -		}
> +		of->cfe = cfe;
> +		return 0;
>  	}
>  
> -	if (css->ss && err)
> +	if (css->ss)
>  		css_put(css);
>  	return err;
>  }


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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux