aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2021-01-24 04:15:13 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2021-02-01 12:39:15 +0000
commit996912046b4d7188636cc4da6a3808010862e93e (patch)
tree17795971c61db6b7960af84dd56e7ff9e93ae937 /lib
parentba0689009b712c558f4ec2b28202a4e45c5bab91 (diff)
downloadsrc-996912046b4d7188636cc4da6a3808010862e93e.tar.gz
src-996912046b4d7188636cc4da6a3808010862e93e.zip
libc: skip spurious stat in _gettemp
It was only done to catch ENOTDIR, but the kernel already returns the error where appropriate. (cherry picked from commit 97a463120bf99819fcb21a781e410fb43dde2a43)
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdio/mktemp.c21
1 files changed, 0 insertions, 21 deletions
diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c
index f08d92cc3ec7..f64eda748d0b 100644
--- a/lib/libc/stdio/mktemp.c
+++ b/lib/libc/stdio/mktemp.c
@@ -121,7 +121,6 @@ _gettemp(int dfd, char *path, int *doopen, int domkdir, int slen, int oflags)
char *start, *trv, *suffp, *carryp;
char *pad;
struct stat sbuf;
- int rval;
uint32_t rand;
char carrybuf[MAXPATHLEN];
@@ -156,26 +155,6 @@ _gettemp(int dfd, char *path, int *doopen, int domkdir, int slen, int oflags)
/* save first combination of random characters */
memcpy(carrybuf, start, suffp - start);
- /*
- * check the target directory.
- */
- if (doopen != NULL || domkdir) {
- for (; trv > path; --trv) {
- if (*trv == '/') {
- *trv = '\0';
- rval = fstatat(dfd, path, &sbuf, 0);
- *trv = '/';
- if (rval != 0)
- return (0);
- if (!S_ISDIR(sbuf.st_mode)) {
- errno = ENOTDIR;
- return (0);
- }
- break;
- }
- }
- }
-
oflags |= O_CREAT | O_EXCL | O_RDWR;
for (;;) {
if (doopen) {