From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932128AbbCJRbi (ORCPT ); Tue, 10 Mar 2015 13:31:38 -0400 Received: from mail-la0-f44.google.com ([209.85.215.44]:40382 "EHLO mail-la0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753546AbbCJRbb (ORCPT ); Tue, 10 Mar 2015 13:31:31 -0400 MIME-Version: 1.0 In-Reply-To: <20150310172603.GF1208@fenchurch.internal.datastacks.com> References: <20150306213912.GA8020@fenchurch.internal.datastacks.com> <20150310122652.GA17573@codeblueprint.co.uk> <20150310152155.GB1208@fenchurch.internal.datastacks.com> <20150310154000.GD1208@fenchurch.internal.datastacks.com> <20150310172603.GF1208@fenchurch.internal.datastacks.com> From: Andy Lutomirski Date: Tue, 10 Mar 2015 10:31:09 -0700 Message-ID: Subject: Re: Re: [PATCH v2 3/3] efi: Capsule update with user helper interface To: Peter Jones Cc: Matt Fleming , "Kweh, Hock Leong" , Sam Protsenko , Ming Lei , Greg Kroah-Hartman , "Ong, Boon Leong" , LKML , "linux-efi@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 10, 2015 at 10:26 AM, Peter Jones wrote: > On Tue, Mar 10, 2015 at 08:51:59AM -0700, Andy Lutomirski wrote: >> On Tue, Mar 10, 2015 at 8:40 AM, Peter Jones wrote: >> > >> >> >> So, for the sysfs interface, let's not allow loading from /lib. Let's >> >> >> not require a userland tool. Let's just do, >> >> >> >> >> >> # echo /path/to/my/awesome/capsule.bin > /sys/../capsule >> >> > >> >> >> >> >> >> and be done with it. >> >> >> >> >> >> Hmmm? >> >> > >> >> > I assume you're implying a) the capsule header with the guid is embedded >> >> > in the .bin there already, and b) one contiguous write(2) with error >> >> > reporting coming through something like vars.c's efi_status_to_err()? >> >> > >> >> > If so, yes, I prefer this API. >> >> > >> >> >> >> Is using a char device really so bad? I have a "simple_char" that >> >> makes this really easy that's pending review. >> > >> > As long as there's straightforward propagation of the EFI_STATUS return >> > from UpdateCapsule() back, sysfs file vs char device makes very little >> > difference to me. Either way it's open(), write(), close(). Using the >> > runtime firmware upload interface designed for wifi and scsi devices is >> > the part I don't really like. >> > >> >> I'm not 100% happy with write(2) (which is all we have in sysfs) for >> two reasons: >> >> 1. If we write a file name, eww. That's more complicated, requires >> temporary files, has annoying mount namespace issues, etc. >> >> 2. If we write the full contents, we need to do it in a single call to >> write. That means that we can't use cat, which mostly defeats the >> purpose. In fact, using cat could be actively harmful. > > So if what we wind up with is: > > fd = open("/sys/.../capsule", O_RDWR); > write(fd, buf, size/N); > ... > write(fd, buf + M*size/N, size/N); > close(fd); > > You're suggesting the error code would post on close()? My worry about > that is that I imagine a lot less code in the wild checks the error code > on close() than on write() - though gnu cat does do so on both. But > there are other questions still - will it post on fdatasync()? On > fsync()? Cat, for example, doesn't check any of the above, which is why I don't like this approach. --Andy