98 lines
4.0 KiB
Diff
98 lines
4.0 KiB
Diff
From c52069f7a0adab4b5c5b911a44d65d3ba0989d7e Mon Sep 17 00:00:00 2001
|
|
From: classabbyamp <dev@placeviolette.net>
|
|
Date: Sat, 12 Oct 2024 20:06:12 -0400
|
|
Subject: [PATCH] Revert "perf(dracut-install): stat() w/unused buf ->
|
|
access(F_OK) in dracut-install"
|
|
|
|
This reverts commit e7ed8337bb9fec0283af5dc745450394ba649a03.
|
|
|
|
This commit broke compatibility with musl 1.1.
|
|
---
|
|
src/install/dracut-install.c | 19 +++++++++++--------
|
|
1 file changed, 11 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/src/install/dracut-install.c b/src/install/dracut-install.c
|
|
index 96bc2eb6..30c51a30 100644
|
|
--- a/src/install/dracut-install.c
|
|
+++ b/src/install/dracut-install.c
|
|
@@ -812,7 +812,7 @@ static int dracut_mkdir(const char *src)
|
|
|
|
static int dracut_install(const char *orig_src, const char *orig_dst, bool isdir, bool resolvedeps, bool hashdst)
|
|
{
|
|
- struct stat sb;
|
|
+ struct stat sb, db;
|
|
_cleanup_free_ char *fullsrcpath = NULL;
|
|
_cleanup_free_ char *fulldstpath = NULL;
|
|
_cleanup_free_ char *fulldstdir = NULL;
|
|
@@ -898,7 +898,7 @@ static int dracut_install(const char *orig_src, const char *orig_dst, bool isdir
|
|
return 1;
|
|
}
|
|
|
|
- ret = access(fulldstdir, F_OK);
|
|
+ ret = stat(fulldstdir, &db);
|
|
|
|
if (ret < 0) {
|
|
_cleanup_free_ char *dname = NULL;
|
|
@@ -958,12 +958,12 @@ static int dracut_install(const char *orig_src, const char *orig_dst, bool isdir
|
|
return 1;
|
|
}
|
|
|
|
- if (faccessat(AT_FDCWD, abspath, F_OK, AT_SYMLINK_NOFOLLOW) != 0) {
|
|
+ if (lstat(abspath, &sb) != 0) {
|
|
log_debug("lstat '%s': %m", abspath);
|
|
return 1;
|
|
}
|
|
|
|
- if (faccessat(AT_FDCWD, fulldstpath, F_OK, AT_SYMLINK_NOFOLLOW) != 0) {
|
|
+ if (lstat(fulldstpath, &sb) != 0) {
|
|
_cleanup_free_ char *absdestpath = NULL;
|
|
|
|
_asprintf(&absdestpath, "%s/%s", destrootdir,
|
|
@@ -1313,6 +1313,7 @@ static char **find_binary(const char *src)
|
|
char *newsrc = NULL;
|
|
|
|
STRV_FOREACH(q, pathdirs) {
|
|
+ struct stat sb;
|
|
char *fullsrcpath;
|
|
|
|
_asprintf(&newsrc, "%s/%s", *q, src);
|
|
@@ -1325,8 +1326,8 @@ static char **find_binary(const char *src)
|
|
continue;
|
|
}
|
|
|
|
- if (faccessat(AT_FDCWD, fullsrcpath, F_OK, AT_SYMLINK_NOFOLLOW) != 0) {
|
|
- log_debug("lstat(%s) != 0", fullsrcpath);
|
|
+ if (lstat(fullsrcpath, &sb) != 0) {
|
|
+ log_debug("stat(%s) != 0", fullsrcpath);
|
|
free(newsrc);
|
|
newsrc = NULL;
|
|
free(fullsrcpath);
|
|
@@ -1441,8 +1442,9 @@ static int install_firmware_fullpath(const char *fwpath)
|
|
{
|
|
const char *fw = fwpath;
|
|
_cleanup_free_ char *fwpath_compressed = NULL;
|
|
+ struct stat sb;
|
|
int ret;
|
|
- if (access(fwpath, F_OK) != 0) {
|
|
+ if (stat(fwpath, &sb) != 0) {
|
|
_asprintf(&fwpath_compressed, "%s.zst", fwpath);
|
|
if (access(fwpath_compressed, F_OK) != 0) {
|
|
strcpy(fwpath_compressed + strlen(fwpath) + 1, "xz");
|
|
@@ -1485,11 +1487,12 @@ static int install_firmware(struct kmod_module *mod)
|
|
ret = -1;
|
|
STRV_FOREACH(q, firmwaredirs) {
|
|
_cleanup_free_ char *fwpath = NULL;
|
|
+ struct stat sb;
|
|
|
|
_asprintf(&fwpath, "%s/%s", *q, value);
|
|
|
|
if (strpbrk(value, "*?[") != NULL
|
|
- && access(fwpath, F_OK) != 0) {
|
|
+ && stat(fwpath, &sb) != 0) {
|
|
size_t i;
|
|
_cleanup_globfree_ glob_t globbuf;
|
|
|
|
--
|
|
2.46.0
|
|
|