From patchwork Tue Sep 11 06:59:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 146414 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3320901ljw; Tue, 11 Sep 2018 00:11:47 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ9NDtCrOOJiZ+iNQY8ZgOKEXdrwTDM7baaAgiLRFh8p548t7Uvjcfs3DJWKAv1rUA1eKev X-Received: by 2002:a50:b5e6:: with SMTP id a93-v6mr4404141ede.94.1536649907303; Tue, 11 Sep 2018 00:11:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536649907; cv=none; d=google.com; s=arc-20160816; b=tuLohbmL8v24iGiYP4SXodIpw4a+8BrOLhzCUksixzxQ3vLwK/1+JBEcdEVphxL82B iV98cj55T8qVosckiTRj+WbPzHTquqcdeWSFELuMfIlTK4j9XuiTqnfeAeeEhwaKqlOJ OwE8vQcGeGB3KTPpCygMwQilFKMCIvlTTOHjicDG4F6F0qrPNBl6YoIdAh86iFbvNI3S PEWkrhgyfYCOSESUSTbEa75B2lnee1B86UipvImQYFEvGQV60Z+vdrHy1ykHd/d3nMQR 7NwgZfiJfsYsBksvkXz/sAs+QrNTQkL5onTcaOnYWAmwmBfpPjI4oTNWVUKtpDKg6pey jqTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature; bh=JjG+XLCDrDY2TPS8NwWoK0Bw7QrWsnCPFraKsHoivvE=; b=X5EeGXmEanRPgBms1DxUOOQdqXBo/999kJCxfCU3i4R8g0yr3laPopjdPDx5v01oV3 gLoryqwJirUy+NlWm/1iOE+fxYrQbbZCWxT2YlkSFtMZPe4Ygn5LBKeQBY+go3uQi3Zx MixGMQGPFu1wFwYE1e3DbNVEZlI0R8SwznWUh0CbYy7ufU3RtIOXW9+d1Lj91ju2UyXK cgxF+p4qnEzBNtsIfb60iCyNVsf2+uVvSSI6BQs0zz/Kzy9uICY/DVzLARgm2VUnXI99 S/js3a3LDYfp2ktdIzJ+dCcM3QvEpWd/pb5cLAWiEkt73VSLsfRhQ955X8i94kD6yw1u m7mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZBTeEpf2; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id l60-v6si2213030ede.26.2018.09.11.00.11.47; Tue, 11 Sep 2018 00:11:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZBTeEpf2; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id CE53BC21E6C; Tue, 11 Sep 2018 07:05:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C4958C21EF7; Tue, 11 Sep 2018 07:00:43 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3C5D4C21F18; Tue, 11 Sep 2018 07:00:09 +0000 (UTC) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by lists.denx.de (Postfix) with ESMTPS id 3DC6DC21EFD for ; Tue, 11 Sep 2018 07:00:04 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id w14-v6so10881055plp.6 for ; Tue, 11 Sep 2018 00:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sIUjgMi15niwdxNpCMu99DQmDjkdIUo6+OFO+w+4tvY=; b=ZBTeEpf2taB2uO8ooMWPzAUP0XZNyb26T2f4eiRfABD8yEjm6bLMHte716NZGzOOly X7YhRSdcyZgQb8adoNpfUcCWUndGxEzrX1R2XSmdlGsGp8YdvI2eX7mgzbk6hEDcr8ZZ xWn/m7PJ7gZDWu50XcMfjfhHG5LDLxF/5zgR0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sIUjgMi15niwdxNpCMu99DQmDjkdIUo6+OFO+w+4tvY=; b=c7KPlb/KaQv8uC/2r/9KZ3NZP6baFrS8rCFdGioQvROSw1vgFjXqj6etlamGXHPG0H 9NUvo1dnaGoN6pTE6eE634O+TKkd/iHesxVcxdVnjAQDl0ZGSS9DDC4Y5+TyF721GOq/ 9+JQq8pgbryVRkSpdkGMIo72JsYwLql5NINb/aBxPcosYNZCN1zEoqLWU/uMnuW8OJ3k aOYkeDSDsEZFAuLPDJ0naCUbfHiaXzRgjCyp5HHeSIJsSZ7oCF/t7bSRyQywNn7gDlmi +Wb8TnkWk8RKaPSss1ar7KZ4we3Xd19BeHLlH7UOYgsi9xKqJNgXwXlO0Soj59RMlTRM M/rw== X-Gm-Message-State: APzg51BgiU2N+937ONVxHk8yDI0BVj6DBEBt9o2wlbT6qw9jBL/j7OeN 21Oz+2ECT2jIVaJWThhc8cvH8Q== X-Received: by 2002:a17:902:1001:: with SMTP id b1-v6mr25730527pla.155.1536649202933; Tue, 11 Sep 2018 00:00:02 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id j184-v6sm19672412pge.77.2018.09.11.00.00.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Sep 2018 00:00:02 -0700 (PDT) From: "Akashi, Takahiro" To: trini@konsulko.com Date: Tue, 11 Sep 2018 15:59:12 +0900 Message-Id: <20180911065922.19141-17-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180911065922.19141-1-takahiro.akashi@linaro.org> References: <20180911065922.19141-1-takahiro.akashi@linaro.org> Cc: u-boot@lists.denx.de, xypron.glpk@gmx.de, agraf@suse.de Subject: [U-Boot] [PATCH v3 16/26] efi_loader: file: support creating a directory X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: AKASHI Takahiro In efi world, there is no obvious "mkdir" interface, instead, Open() with EFI_FILE_MODE_CREATE in mode parameter and EFI_FILE_DIRECTORY in attributes parameter creates a directory. In this patch, efi_file_open() is extended so as to accept such a combination of parameters and call u-boot's mkdir interface for expected action. Signed-off-by: AKASHI Takahiro --- lib/efi_loader/efi_file.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c index e6a15bcb523e..6ec98c80227e 100644 --- a/lib/efi_loader/efi_file.c +++ b/lib/efi_loader/efi_file.c @@ -130,7 +130,8 @@ static int sanitize_path(char *path) * With windoze style backlashes, ofc. */ static struct efi_file_handle *file_open(struct file_system *fs, - struct file_handle *parent, s16 *file_name, u64 mode) + struct file_handle *parent, s16 *file_name, u64 mode, + u64 attributes) { struct file_handle *fh; char f0[MAX_UTF8_PER_UTF16] = {0}; @@ -173,7 +174,12 @@ static struct efi_file_handle *file_open(struct file_system *fs, if (set_blk_dev(fh)) goto error; - if (!((mode & EFI_FILE_MODE_CREATE) || fs_exists(fh->path))) + if ((mode & EFI_FILE_MODE_CREATE) && + (attributes & EFI_FILE_DIRECTORY)) { + if (fs_mkdir(fh->path)) + goto error; + } else if (!((mode & EFI_FILE_MODE_CREATE) || + fs_exists(fh->path))) goto error; /* figure out if file is a directory: */ @@ -199,7 +205,7 @@ static efi_status_t EFIAPI efi_file_open(struct efi_file_handle *file, EFI_ENTRY("%p, %p, \"%ls\", %llx, %llu", file, new_handle, file_name, open_mode, attributes); - *new_handle = file_open(fh->fs, fh, file_name, open_mode); + *new_handle = file_open(fh->fs, fh, file_name, open_mode, attributes); if (!*new_handle) return EFI_EXIT(EFI_NOT_FOUND); @@ -598,7 +604,7 @@ efi_open_volume(struct efi_simple_file_system_protocol *this, EFI_ENTRY("%p, %p", this, root); - *root = file_open(fs, NULL, NULL, 0); + *root = file_open(fs, NULL, NULL, 0, 0); return EFI_EXIT(EFI_SUCCESS); }