Skip to content

Commit 46a6b2e

Browse files
Remove needless access() in efivarfs_probe()
The access() is always seemingly-validated by a statfs(): there's no need for this, but this incurs an additional syscall Signed-off-by: Ahelenia Ziemiańska <[email protected]>
1 parent 90e88b2 commit 46a6b2e

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

src/efivarfs.c

+18-22
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,26 @@ efivarfs_probe(void)
6969
{
7070
const char *path = get_efivarfs_path();
7171

72-
if (!access(path, F_OK)) {
73-
int rc = 0;
74-
struct statfs buf;
75-
76-
memset(&buf, '\0', sizeof (buf));
77-
rc = statfs(path, &buf);
78-
if (rc == 0) {
79-
char *tmp;
80-
__typeof__(buf.f_type) magic = EFIVARFS_MAGIC;
81-
if (!memcmp(&buf.f_type, &magic, sizeof (magic)))
82-
return 1;
83-
else
84-
efi_error("bad fs type for %s", path);
85-
86-
tmp = getenv("EFIVARFS_PATH");
87-
if (tmp && !strcmp(tmp, path)) {
88-
efi_error_clear();
89-
return 1;
90-
}
91-
} else {
92-
efi_error("statfs(%s) failed", path);
72+
int rc = 0;
73+
struct statfs buf;
74+
75+
memset(&buf, '\0', sizeof (buf));
76+
rc = statfs(path, &buf);
77+
if (rc == 0) {
78+
char *tmp;
79+
__typeof__(buf.f_type) magic = EFIVARFS_MAGIC;
80+
if (!memcmp(&buf.f_type, &magic, sizeof (magic)))
81+
return 1;
82+
else
83+
efi_error("bad fs type for %s", path);
84+
85+
tmp = getenv("EFIVARFS_PATH");
86+
if (tmp && !strcmp(tmp, path)) {
87+
efi_error_clear();
88+
return 1;
9389
}
9490
} else {
95-
efi_error("access(%s, F_OK) failed", path);
91+
efi_error("statfs(%s) failed", path);
9692
}
9793

9894
return 0;

0 commit comments

Comments
 (0)