If this function fails to touch a dummy header due to missing parent directory, then it creates it and touches the file again. This was needed because CONFIG_FOO_BAR was previously tracked by include/config/foo/bar.h. (include/config/foo/ may not exist here) This is no longer the case since commit 0e0345b77ac4 ("kbuild: redo fake deps at include/config/*.h"); now all the fake headers are placed right under include/config/, like include/config/FOO_BAR. Do not try to create parent directory, include/config/, which already exists.
Showing the changes to scripts (1 of 1 file). Show all
Unified · Split
| @@ -130,31 +130,17 @@ static size_t depfile_prefix_len; · 129 unmodified lines | ||
| 130 | 130 | /* touch depfile for symbol 'name' */ |
| 131 | 131 | static int conf_touch_dep(const char *name) |
| 132 | 132 | { |
| 133 | − int fd, ret; | |
| 134 | − char *d; | |
| 133 | + int fd; | |
| 135 | 134 | |
| 136 | 135 | /* check overflow: prefix + name + '\0' must fit in buffer. */ |
| 137 | 136 | if (depfile_prefix_len + strlen(name) + 1 > sizeof(depfile_path)) |
| 138 | 137 | return -1; |
| 139 | 138 | |
| 140 | − d = depfile_path + depfile_prefix_len; | |
| 141 | − strcpy(d, name); | |
| 139 | + strcpy(depfile_path + depfile_prefix_len, name); | |
| 142 | 140 | |
| 143 | − /* Assume directory path already exists. */ | |
| 144 | 141 | fd = open(depfile_path, O_WRONLY | O_CREAT | O_TRUNC, 0644); |
| 145 | − if (fd == -1) { | |
| 146 | − if (errno != ENOENT) | |
| 147 | − return -1; | |
| 148 | − | |
| 149 | − ret = make_parent_dir(depfile_path); | |
| 150 | − if (ret) | |
| 151 | − return ret; | |
| 152 | − | |
| 153 | − /* Try it again. */ | |
| 154 | − fd = open(depfile_path, O_WRONLY | O_CREAT | O_TRUNC, 0644); | |
| 155 | − if (fd == -1) | |
| 156 | − return -1; | |
| 157 | − } | |
| 142 | + if (fd == -1) | |
| 143 | + return -1; | |
| 158 | 144 | close(fd); |
| 159 | 145 | |
| 160 | 146 | return 0; |