Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1isTx7-0004Ce-Pz for mharc-grub-devel@gnu.org; Fri, 17 Jan 2020 10:54:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40588) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isTx5-00047x-6L for grub-devel@gnu.org; Fri, 17 Jan 2020 10:54:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1isTx2-0005du-12 for grub-devel@gnu.org; Fri, 17 Jan 2020 10:54:25 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:44377 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1isTx1-0005VA-IE for grub-devel@gnu.org; Fri, 17 Jan 2020 10:54:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579276459; 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=Fu7r7e2jgrOWY9Q/riPBKZCgc+i4Nwp+yGMv1vwj418=; b=HTzhjvQdhNz4YqEXxOJjQFhEOeTrjFbcqPEqRjw/Q0XTs2KwcXzuRF2+Bm+8RtsJy4GJTh I+o7DxLpnFbPWCIDiMQa2f+6tHrFOlPVAPDWYtf5Thv5VEUNtUnD39oFrIkJYwJVNGf7w9 n2SniSSakJI75y2s61dUgQqXCfFVpek= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-237-ntSCo_APN7moKLEkNHAupA-1; Fri, 17 Jan 2020 10:54:18 -0500 Received: by mail-wm1-f72.google.com with SMTP id c4so2421349wmb.8 for ; Fri, 17 Jan 2020 07:54:18 -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=LS7V/B+mTy1Yy5ms21XUk6Ln1K72bQ1sGkzdDDFSgMk=; b=sJhlit4g+21rkIcBSawIWIwIqww7aYjxTPoV/7R++/NtkPX4td0KaoONOxUkybLvem rkK0ZpcIo7I+216ylcvRla/a3mgoXTz1BCKqPxffaUNi9Jtn9ZPAyW+oSGQvaFWemrcl lZlksz4ssqxkIF4ocrOq77GJORuHlJY/FjT7ZgepAcwkZDRNcSqQ/MXQFqEY//Sosd6I 7fBETbfEUPawgRCpPD6y7Der4cw9v5su2EC7LhRhOFhgSJe5cBbG5CyPKNG5FLc9Jy8S 5Z0PJNsSjIr2pIx+IyhyGXAvpoj2uobahAaR6n0ZEWcE6CBh/RfzgeTFYtul9KjN59P3 AHwA== X-Gm-Message-State: APjAAAWo7FyHOXVrttgvMfm/71o5G9VyJdtbyTPZwIJjTYGvV76JzBsi GWmhgxWqubYy5wAk7c5OOKj94S62n/xPk5K1oLygKuWScBNRDkWTlS8iraNAGjaiyFXq1r7TyGT n01uZpd9R8c0= X-Received: by 2002:a5d:44cd:: with SMTP id z13mr3894871wrr.104.1579276456780; Fri, 17 Jan 2020 07:54:16 -0800 (PST) X-Google-Smtp-Source: APXvYqwYiEQ39J58uAKMRnEo2pP8xR1ZQbUFdRxkhPQtgH624fozvXasyygQ+rHYzz7ipLlRUHPb9w== X-Received: by 2002:a5d:44cd:: with SMTP id z13mr3894849wrr.104.1579276456459; Fri, 17 Jan 2020 07:54:16 -0800 (PST) Received: from minerva.redhat.com ([195.166.127.210]) by smtp.gmail.com with ESMTPSA id b17sm35197405wrx.15.2020.01.17.07.54.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2020 07:54:15 -0800 (PST) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Peter Jones , Adam Jackson , Javier Martinez Canillas , Daniel Kiper Subject: [PATCH v4 1/2] Add grub_util_readlink() Date: Fri, 17 Jan 2020 16:54:07 +0100 Message-Id: <20200117155408.3395811-1-javierm@redhat.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-MC-Unique: ntSCo_APN7moKLEkNHAupA-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: 207.211.31.81 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 15:54:28 -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 --- 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