From bee64b871a5ceb1c832babaddeedff0fb78caa7b Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 11 Feb 1998 22:17:38 +0000 Subject: [PATCH] Add my comment from ChangeLog entry for gkm's change. --- lib/makepath.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/makepath.c b/lib/makepath.c index ea0a021d86..99119a2131 100644 --- a/lib/makepath.c +++ b/lib/makepath.c @@ -217,6 +217,14 @@ make_path (const char *argpath, if (!do_chdir) basename_dir = dirpath; + /* The mkdir and stat calls below appear to be reversed. + They are not. It is important to call mkdir first and then to + call stat (to distinguish the three cases) only if mkdir fails. + The alternative to this approach is to `stat' each directory, + then to call mkdir if it doesn't exist. But if some other process + were to create the directory between the stat & mkdir, the mkdir + would fail with EEXIST. */ + *slash = '\0'; if (mkdir (basename_dir, tmp_mode)) { -- 2.30.2