Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1isUD7-00071J-39 for mharc-grub-devel@gnu.org; Fri, 17 Jan 2020 11:11:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43320) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isUD4-00070s-De for grub-devel@gnu.org; Fri, 17 Jan 2020 11:10:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1isUCz-0002MB-Ky for grub-devel@gnu.org; Fri, 17 Jan 2020 11:10:57 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:28781 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1isUCz-0002L0-3r for grub-devel@gnu.org; Fri, 17 Jan 2020 11:10:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579277450; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HoHfXRSmkoyLBe5wXAE9FA3ISBz2x63l8SGvR6ZkzJk=; b=GQogdqkoYwmiUyTAPo4zkNl37KVWgJhuBdTlcx1Vuzi68sPH0gWoUBf2OHd8xFLhdJB6eN zFqteEdulfrXZWYzxGnfwrms60V29xD2QASktcB9Bjk+GcRbG4eJB0pf7Es9qkOeYUj+Jb Y3kXhOfG0CSj87jmDPvmdYGA1cl+IXs= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-112--M1zT9A9OnGn61uTK0guUw-1; Fri, 17 Jan 2020 11:10:49 -0500 Received: by mail-wm1-f71.google.com with SMTP id o24so1306804wmh.0 for ; Fri, 17 Jan 2020 08:10:49 -0800 (PST) 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:mime-version :content-transfer-encoding; bh=dv4JZ3liWfYBdt5EYjV+fu1ITQn3zRt2+R6+NlumzZg=; b=i9Wp/3FnKHHhvagETs5wmH++B4WhmbPZVKMJyP+a4lzpdn3OjZ5+ssJy282hQTXVlz 8qKoYq/t0+AF1a2dvU5AqEeNgasSVYoquqGtjj+V02AoXPmP8xwhiv2fxZv1eFvWrJRI VvF1Fs37b8QPp48ATZXreu9EgkrsIuSd60b+48wOLPvVGGpDOlTbmZtUTeyLA32Yh3Uh B1RiFlHzVvjd8N4kpFUIhrO5bropzL0mBt2jgw0obKaZN1tlh6LBL4LRy3jzIbjPu0o0 XXF51IqR1GP5SqZ9W5UwxqPriGUfzCWX+n70eq+WHIFvr+gjPC8LVUhuEIldr67Ku1UE 9ITg== X-Gm-Message-State: APjAAAX8ntyB/RjjAJpl2yVgw7418hqKTcLiS0VxSlBRntBKDdpZy04r vTYfeqaqzE9e5ZfEldcXT9MJlmqFl/M2iVVtPYZFzr/6EL6vjNv+63lYC5A8795beDhdk/9gOz5 LldNqdSYxl7E= X-Received: by 2002:a7b:c114:: with SMTP id w20mr5589816wmi.151.1579277447747; Fri, 17 Jan 2020 08:10:47 -0800 (PST) X-Google-Smtp-Source: APXvYqwP/n7Tt3+6O950A956niybZSOPcx46ViCtEfSee1jM/cVEmpNm8zMjy7cUCm4AO96hTZ7SMQ== X-Received: by 2002:a7b:c114:: with SMTP id w20mr5589797wmi.151.1579277447537; Fri, 17 Jan 2020 08:10:47 -0800 (PST) Received: from minerva.redhat.com ([195.166.127.210]) by smtp.gmail.com with ESMTPSA id n1sm32924704wrw.52.2020.01.17.08.10.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2020 08:10:46 -0800 (PST) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Peter Jones , Adam Jackson , Javier Martinez Canillas , Daniel Kiper Subject: [RESEND PATCH v4 1/2] Add grub_util_readlink() Date: Fri, 17 Jan 2020 17:10:42 +0100 Message-Id: <20200117161043.3474202-1-javierm@redhat.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-MC-Unique: -M1zT9A9OnGn61uTK0guUw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jan 2020 16:10:59 -0000 From: Peter Jones Currently grub-editenv and related tools are not able to follow symbolic links when finding their config file. For example the grub-editenv create command will wrongly overwrite a symlink in /boot/grub2/grubenv with a new regular file, instead of creating a file in the path the symlink points to. A following patch will change that and add support in grub-editenv to follow symbolic links when finding the grub environment variables file. Add a grub_util_readlink() helper function that is just a wrapper around the platform specific function to read the value of a symbolic link. This helper function will be used by the following patch for grub-editenv. The helper function is not added for Windows, since this operating system doesn't have a primitive to read the contents of a symbolic link. Signed-off-by: Peter Jones Reviewed-by: Adam Jackson Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Kiper --- Resending the patches rebased on top of the latest master branch so they apply cleanly. Sorry for the noise. Changes in v4: - Don't add this helper for Windows OS since doesn't support it. Changes in v3: None Changes in v2: - Add a better commit message explaining why the change is needed. - Add Reviewed-by tag from Daniel Kiper. include/grub/osdep/hostfile_aros.h | 6 ++++++ include/grub/osdep/hostfile_unix.h | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/include/grub/osdep/hostfile_aros.h b/include/grub/osdep/hostfi= le_aros.h index a059c0fa40a..161fbb7bdfd 100644 --- a/include/grub/osdep/hostfile_aros.h +++ b/include/grub/osdep/hostfile_aros.h @@ -68,6 +68,12 @@ grub_util_rename (const char *from, const char *to) return rename (from, to); } =20 +static inline ssize_t +grub_util_readlink (const char *name, char *buf, size_t bufsize) +{ + return readlink(name, buf, bufsize); +} + #define grub_util_mkdir(a) mkdir ((a), 0755) =20 struct grub_util_fd diff --git a/include/grub/osdep/hostfile_unix.h b/include/grub/osdep/hostfi= le_unix.h index 9ffe46fa3ca..17cd3aa8b30 100644 --- a/include/grub/osdep/hostfile_unix.h +++ b/include/grub/osdep/hostfile_unix.h @@ -71,6 +71,12 @@ grub_util_rename (const char *from, const char *to) return rename (from, to); } =20 +static inline ssize_t +grub_util_readlink (const char *name, char *buf, size_t bufsize) +{ + return readlink(name, buf, bufsize); +} + #define grub_util_mkdir(a) mkdir ((a), 0755) =20 #if defined (__NetBSD__) --=20 2.23.0