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

Re: [Xen-devel] [PATCH V5 2/7] libxl_read_file_contents: add new entry to read sysfs file



Chun Yan Liu writes ("Re: [PATCH V5 2/7] libxl_read_file_contents: add new 
entry to read sysfs file"):
> On 6/26/2015 at 09:05 PM, in message
> <21901.20009.85407.581628@xxxxxxxxxxxxxxxxxxxxxxxx>, Ian Jackson
> <Ian.Jackson@xxxxxxxxxxxxx> wrote: 
> > But please feel free to explain why I'm wrong. 
> 
> You are right. I'm confused about the original logic. The original code
> doesn't consider this case (size bigger than requested) at all.

Indeed.  The original code assumes that files don't change size, and
only detects them shrinking because that causes a short read which it
has deal with somehow.

But if we are intending to use this with sysfs files, where the
reported size is known to be wrong, it seems to me that we should be
more proactive.

> So, we need to add a check if (rs == datalen && read end of file),
> if not, means bigger than requested, report error.

To detect a growing file it will be necessary to actually attempt to
read at least one byte more than expected.  This is probably done most
conveniently by making the buffer one byte bigger, too.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.