From patchwork Fri Jul 20 02:57:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 142419 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2440811ljj; Thu, 19 Jul 2018 20:04:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpddImH8VdcjJFROrTL9W3nTM7K665mK537kkEEN/FxNKQwJ0BkbuWHtOjkhy44JNLaZUVBZ X-Received: by 2002:a50:db03:: with SMTP id o3-v6mr528556edk.76.1532055863970; Thu, 19 Jul 2018 20:04:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532055863; cv=none; d=google.com; s=arc-20160816; b=lt4poBcL7TZv0AzwuzDJDRaJztl9apUyfEz4FeSA5j6RrM7N1A1rfnXCE3ElbODd6o hcPo3wzQxhk7WzZ/mC3z8B8ytNzCpNRQZzsV5Pg8ubrIrXD4bs5oYw2Xi7ay2wnWSRc3 28kmGeKlZWG2+1y9BKdX/xyg0aZ36g70B7UeguZ19e7PGtAO4saOu3n5bxKS2FBYKXbw 2BLg003vnlE/njslwpeF9I+ICJALsOrnY6E5eK1iYcpmzgdK40gx44GHzCDDTb05SLwy qZohYHJ3oeGVLRsTn+IlWgizWWJskTn9HHywZvxCiO0r2sXDD1btoTSVee0XLp/Noi1h gcsg== 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:arc-authentication-results; bh=miO1LB8uRIK/opUJk9iGPja81xlTJkmIQ9FE4JPhASI=; b=oMuH05l2cemQDJ2rfWfjluAr9V0mQlr5CsaEZo08b0l8WCpnq4tk8tUZ572PMjcgvi y2wsHsiqLw17lIdz3qPKMA9Cd8OX2bw1aGcD7vIsijSNyDTwVpwqvocqhyLciDY4caa+ vw+/gcMMfYkdUAz9jneMcye9/vhtr+gUPO/BzNIJ2bBmzbrrlXDpMrVH8+ZNMIkY36VU YwXJZLDnSkfpHyBVLg5BcwG2frY3yazY4EPB7W/e/WT1Uuf75dbXocDwoFIAVsc/Q0FV PN1DyYFQgaTweFkxWu/omI18FPUus99DV6p5Nrh+pIPwasPjuNy4tHvKX2UZOJ/gy+W6 Ok4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WVlHw0tF; 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 w11-v6si577971edq.75.2018.07.19.20.04.23; Thu, 19 Jul 2018 20:04:23 -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=WVlHw0tF; 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 9AA94C21E50; Fri, 20 Jul 2018 03:00:11 +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 42B0AC21D4A; Fri, 20 Jul 2018 02:59:49 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AE462C21D74; Fri, 20 Jul 2018 02:58:49 +0000 (UTC) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by lists.denx.de (Postfix) with ESMTPS id EBB76C21D74 for ; Fri, 20 Jul 2018 02:58:45 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id r1-v6so5506790pgp.11 for ; Thu, 19 Jul 2018 19:58:45 -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=2Io2oeoR/DFJb2qJUSf9S9jujfFCbN3bLZmhiLBVUmw=; b=WVlHw0tF3Hs/6fPef3f4hVnwT/zF0CwnZAKVdbidG7BXV9HKnwfwIhNSgz5tjIr2oB lEbJAp4Kw9XZnJHnU3euCSgt2cNa2x3OtFbxWTmsRA+SJAzePI0YS/1e34tCKKUAtbuL hUqFzLRRV9xefyLx+v6Z7DtZsFDO2JW7wtneM= 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=2Io2oeoR/DFJb2qJUSf9S9jujfFCbN3bLZmhiLBVUmw=; b=YALJvJ9p/KhtL5O40Y2OIllwA6paFlRZNckwKyb9yuFUI4eC2LqG45b9YViXrY26G6 NyL7NkK8U+50/5zC7lL9myNmC0sWDjGL6XcorHfRbgUetqS+sykEIwQJ7lhpqWaXq7b2 EQfzwflB6uFbvU9hh6DuqWDZA2Jnli85r/VN6Bh4MTSxNYOEnNPq82KFgXCXYOtmLhO8 qXQlZyKB0H+6SvtuEYhL4zZrtl5oz27qM/c1QJYCX3YLbo4pXIzCiUjLWIdFyM3hLcnz 5XcSf2Zgmaxd4YcbrB86nSuJegupYMMtFfipoYGYsuGkzMIvQupLvQyAixEn/2DVkcHc aRig== X-Gm-Message-State: AOUpUlHG/CLVRv5xZneUGP44WfcwJP0iQJeof66zg6HKhwmIYlb5Iz1J 1pcN8tLgJZCn0kaN1mSIPDC2Ig== X-Received: by 2002:a65:49c7:: with SMTP id t7-v6mr290254pgs.23.1532055524650; Thu, 19 Jul 2018 19:58:44 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id x5-v6sm599923pfh.67.2018.07.19.19.58.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jul 2018 19:58:44 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com Date: Fri, 20 Jul 2018 11:57:21 +0900 Message-Id: <20180720025723.6736-16-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180720025723.6736-1-takahiro.akashi@linaro.org> References: <20180720025723.6736-1-takahiro.akashi@linaro.org> Cc: u-boot@lists.denx.de, xypron.glpk@gmx.de, agraf@suse.de Subject: [U-Boot] [PATCH 15/17] 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" 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 e6a15bcb52..6ec98c8022 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); }