From bf081914a314cbf8e0e141bfe77751dedcbc021b Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 3 Mar 2026 19:10:12 +0000 Subject: 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 --- util/nvmutil/nvmutil.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'util/nvmutil') 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); @@ -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) { -- cgit v1.2.1