mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-03-28 23:19:03 +02:00
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>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -215,16 +211,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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user