Date: Tue, 23 Sep 2014 11:41:09 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r272026 - head/usr.bin/xinstall Message-ID: <201409231141.s8NBf9WD033171@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Tue Sep 23 11:41:09 2014 New Revision: 272026 URL: http://svnweb.freebsd.org/changeset/base/272026 Log: install: re-check failed mkdir for EEXIST Since the code stats and mkdirs in 2 separate steps, it is possible that the directory will be created in the meantime by something else (e.g. concurrent install).[1] While here alter the code to properly report stat failure, previously it would always claim it was mkdir which failed. Noted by: royger [1] MFC after: 1 week Modified: head/usr.bin/xinstall/xinstall.c Modified: head/usr.bin/xinstall/xinstall.c ============================================================================== --- head/usr.bin/xinstall/xinstall.c Tue Sep 23 11:27:43 2014 (r272025) +++ head/usr.bin/xinstall/xinstall.c Tue Sep 23 11:41:09 2014 (r272026) @@ -1263,13 +1263,18 @@ install_dir(char *path) if (!*p || (p != path && *p == '/')) { ch = *p; *p = '\0'; - if (stat(path, &sb)) { - if (errno != ENOENT || mkdir(path, 0755) < 0) { +again: + if (stat(path, &sb) < 0) { + if (errno != ENOENT) + err(EX_OSERR, "stat %s", path); + if (mkdir(path, 0755) < 0) { + if (errno == EEXIST) + goto again; err(EX_OSERR, "mkdir %s", path); - /* NOTREACHED */ - } else if (verbose) + } + if (verbose) (void)printf("install: mkdir %s\n", - path); + path); } else if (!S_ISDIR(sb.st_mode)) errx(EX_OSERR, "%s exists but is not a directory", path); if (!(*p = ch))
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409231141.s8NBf9WD033171>