From: Ian Jackson Subject: Re: [PATCH V3 2/6] libxl_read_file_contents: fix reading sysfs file Date: Mon, 18 May 2015 15:23:38 +0100 Message-ID: <21849.62954.924664.677204@mariner.uk.xensource.com> References: <1429415452-6161-1-git-send-email-cyliu@suse.com> <1429415452-6161-3-git-send-email-cyliu@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1429415452-6161-3-git-send-email-cyliu@suse.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Chunyan Liu Cc: lars.kurth@citrix.com, wei.liu2@citrix.com, ian.campbell@citrix.com, george.dunlap@eu.citrix.com, xen-devel@lists.xen.org, caobosimon@gmail.com List-Id: xen-devel@lists.xenproject.org Chunyan Liu writes ("[PATCH V3 2/6] libxl_read_file_contents: fix reading sysfs file"): > Sysfs file has size=4096 but actual file content is less than that. Wow. Is there any danger that the actual size might be >4096 ? > Current libxl_read_file_contents will treat it as error when file size > and actual file content differs, so reading sysfs file content with > this function always fails. Fix it so that we can reuse this function > to get sysfs file content in later pvusb work. I'm uncomfortable with removing an error check from this function for all its call sites. I think, sadly, that we are going to need a new function - at least, a new entrypoint. We don't want to repeat the whole of libxl__read_file_contents. Perhaps the bulk should be made into libxl__read_file_contents_core which takes a boolean instructing whether to tolerate magically shrinking files ? Setting that boolean probably ought to arrange to insist that the function gets eof, in case the file is actually bigger rather than smaller than the size. Ian, Wei ? Ian.