summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-03 19:10:12 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-03 19:11:20 +0000
commitbf081914a314cbf8e0e141bfe77751dedcbc021b (patch)
tree59447b8b3f761c428e97909a66bd8b32b55aa7c7
parent4325214d8231b9dded2fa3619bb32c8417971fa5 (diff)
util/nvmutil: remove checkdir()
we don't need it. what follows is a call to open(), which would fail anyway if the path is a directory; further, this removes a theoretical race condition in the program, and makes open() happen sooner, making it more likely that we get the file first, before another program can take it. checking whether /dev/urandom is a directory is the height of absurdity. Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r--util/nvmutil/nvmutil.c14
1 files changed, 0 insertions, 14 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index ca7f328f..ea8f248c 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -17,7 +17,6 @@ static void set_cmd(int, char **);
static void check_cmd_args(int, char **);
static void set_io_flags(int, char **);
static void open_files(void);
-static void checkdir(const char *);
static void xopen(int *, const char *, int, struct stat *);
static void read_gbe(void);
static void read_gbe_part(int, int);
@@ -197,9 +196,6 @@ open_files(void)
struct stat st;
struct stat st_rfd;
- checkdir("/dev/urandom");
- checkdir(fname);
-
xopen(&rfd, "/dev/urandom", O_RDONLY, &st_rfd);
xopen(&fd, fname, flags, &st);
@@ -216,16 +212,6 @@ open_files(void)
}
static void
-checkdir(const char *path)
-{
- struct stat st;
- if (stat(path, &st) == -1)
- err(ECANCELED, "%s", path);
- if (S_ISDIR(st.st_mode))
- err(EISDIR, "%s", path);
-}
-
-static void
xopen(int *f, const char *l, int p, struct stat *st)
{
if ((*f = open(l, p)) == -1)