[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210914073003.GA31077@lst.de>
Date: Tue, 14 Sep 2021 09:30:03 +0200
From: Christoph Hellwig <hch@....de>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Christoph Hellwig <hch@....de>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
Jens Axboe <axboe@...nel.dk>, Tejun Heo <tj@...nel.org>,
linux-block@...r.kernel.org, linux-xfs@...r.kernel.org,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 13/13] xfs: convert xfs_sysfs attrs to use ->seq_show
On Mon, Sep 13, 2021 at 08:27:50AM +0200, Greg Kroah-Hartman wrote:
> Anyway, I like the idea, but as you can see here, it could lead to even
> more abuse of sysfs files. We are just now getting people to use
> sysfs_emit() and that is showing us where people have been abusing the
> api in bad ways.
To be honest I've always seen sysfs_emit as at best a horrible band aid
to enforce the PAGE_SIZE bounds checking. Better than nothing, but
not a solution at all, as you can't force anyone to actually use it.
> Is there any way that sysfs can keep the existing show functionality and
> just do the seq_printf() for the buffer returned by the attribute file
> inside of the sysfs core?
Well, you'd need one page allocated in the seq_file code, and one in
the sysfs code. At which point we might as well drop using seq_file
at all. But in general seq_file seems like a very nice helper for
over flow free printing into a buffer. If sysfs files actually were
all limited to a single print we wouldn't really need it, and could
just have something like sysfs_emit just with the buffer hidden inside
a structure that is opaqueue to the caller. But looking at various
attributes that is not exactly the case. While the majority certainly
uses a single value and a single print statement there is plenty where
this is not the case. Either because they use multiple values, or
often also because they dynamically append to the string to print
things like comma-separated flags.
Powered by blists - more mailing lists