From patchwork Tue Sep 4 07:49:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 145871 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3374637ljw; Tue, 4 Sep 2018 01:04:59 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbTefPR0nPQukjQa02C0gDxGnXL//oyuq/yhHn3El0fcQcGQFM0Atg+ob/1HcIbo1t33+nr X-Received: by 2002:a50:fb8f:: with SMTP id e15-v6mr35185036edq.153.1536048299745; Tue, 04 Sep 2018 01:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536048299; cv=none; d=google.com; s=arc-20160816; b=c72ZxD7loy1wgAauq/xMxDVCn3awQe7KTYXt8vd+WInl5/me5jYvVK05IA9Zo87TyP Q0nP7V8e4C7F127jawtAGV0//VLgfYE+kR/A20zN4Ol8mkM26S4GHIsB8IVFYNu2JWra 5bkqkttaqoU8QaEMk6Sm0TfWnny9EjqRnssMg0I9g1tHTeTX5pXAAEpcs1FPkTTUYAm2 pw+v79suX8zLqVEZ33brfDKppNy4jrcJmwom8iFmiBpzKLFPAsrHfllEhnTArKqanpln bJBDkiM6o8LZKGfmyoEUmjZpFVpPtg9UEjlwZajDyqq3zNFO25b32+X/l0crz48eniXQ 5BFA== 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=qEumHJoma6I9rOhAXkRT27kYLV7UEVut3Z+Eb84uF4w=; b=eNeiNdEVZ0/a3xKQbgITaZxT4khm3pu0hHU28fX0ZfnTfSr3O3rvZt0veTndTdBo8Q MSL7E4YbRPqUENUh3h+bygRf6AdB5Ihc6UbLAU0Bby6zbWtAWyTx6m/oXSuX2XPnWumH /4JMXuCQTYF4WOcfj7I5oNp4iT1CI527Isn3lSDssAjyekNMJAg41lTqL1svT0hAQxpn +wcmQ3XZaQVSaxKWhHwMAjZITYibUzqhh2nAqlFzEUW0Mlp1p6WQCA+Q5ajTlRD6idwS WKIGth5omL8AWom4/XniGCgenVrlHt2GtpmHmzOOsS2/cbFFt8z3woC3CodMOC9py6UF /g/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fqauzOqL; 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 r7-v6si2544330edr.289.2018.09.04.01.04.59; Tue, 04 Sep 2018 01:04:59 -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=fqauzOqL; 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 51475C21F5E; Tue, 4 Sep 2018 08:00:26 +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 C2C29C21F4F; Tue, 4 Sep 2018 08:00:23 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 20F2EC21F24; Tue, 4 Sep 2018 07:52:35 +0000 (UTC) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by lists.denx.de (Postfix) with ESMTPS id BD932C21F3C for ; Tue, 4 Sep 2018 07:52:31 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id s7-v6so1269117pgc.0 for ; Tue, 04 Sep 2018 00:52:31 -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=qs2D+cCVxC+acpJQJmuZkvuxYHb9rvuKa+A/1Qvufe8=; b=fqauzOqL+aldc6ZZlaTtODAJkYa1lh4TItRnewvM2/tHpTiylhh/Hv7p9u6zrQnTWz a7oc4ODTmRDBJQFK3FWV7s8G3gjP3bT/5JnT9U6fyU4CqS/HA5BmiZXbt0qNiF6PP73K NtVmFH+i/i2iqCEUyPYwMG4mwlOdsxt1sasHQ= 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=qs2D+cCVxC+acpJQJmuZkvuxYHb9rvuKa+A/1Qvufe8=; b=N2csKErAWYvht2W7vLsicXQz5kat/4cCv+/lOPAZL6mFbkbaGEd5NKdIQoSs3u51A2 5MXmgKAqZO/D8NylfEZMv9p7TmDD+LcSBHccgNq3AYhOpM8WOILHH0N7x9pfxX6GWMsl nIw7OBK5Fh4gxOqQkCLyrdmaAlnJc6CuwcP3SQiTxsHPOoABAni/PogCy/5h05tVfrZu xdfTKMTRnecmvixxKiQqv0UGnYJNcJi1kxsSeRL9Gjxjn6/si/aneKiG8bu1eblD/euU zbdKRJ7ZPijLV0s7yXCbeVBpCJ+ZqUfqKdDZyVwsrf1khaGHVbPS1C+MddzGlEMSReVT ku5w== X-Gm-Message-State: APzg51CNL3jjwMx00W6+zrkT5Q82yhAX2cLRPpEreCc1nvhSS572v958 8BehzG6GlF/TgWWG2oel5obThCDC364= X-Received: by 2002:a63:8f17:: with SMTP id n23-v6mr11109399pgd.131.1536047550480; Tue, 04 Sep 2018 00:52:30 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id 83-v6sm37996583pft.40.2018.09.04.00.52.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 00:52:29 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com Date: Tue, 4 Sep 2018 16:49:42 +0900 Message-Id: <20180904074948.18146-18-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180904074948.18146-1-takahiro.akashi@linaro.org> References: <20180904074948.18146-1-takahiro.akashi@linaro.org> Cc: xypron.glpk@gmx.de, agraf@suse.de, u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 17/23] 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 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); }