History

kconfig: refactor conf_touch_dep()

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.

Masahiro Yamada committed 5 years ago

Commit fee762d1 parent 00d674c1 file · +4 −18Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/kconfig/confdata.c+4−18
@@ -130,31 +130,17 @@ static size_t depfile_prefix_len; · 129 unmodified lines
130/* touch depfile for symbol 'name' */130/* touch depfile for symbol 'name' */
131static int conf_touch_dep(const char *name)131static int conf_touch_dep(const char *name)
132{132{
133 int fd, ret;133 int fd;
134 char *d;
135 134
136 /* check overflow: prefix + name + '\0' must fit in buffer. */135 /* check overflow: prefix + name + '\0' must fit in buffer. */
137 if (depfile_prefix_len + strlen(name) + 1 > sizeof(depfile_path))136 if (depfile_prefix_len + strlen(name) + 1 > sizeof(depfile_path))
138 return -1;137 return -1;
139 138
140 d = depfile_path + depfile_prefix_len;139 strcpy(depfile_path + depfile_prefix_len, name);
141 strcpy(d, name);
142 140
143 /* Assume directory path already exists. */
144 fd = open(depfile_path, O_WRONLY | O_CREAT | O_TRUNC, 0644);141 fd = open(depfile_path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
145 if (fd == -1) {142 if (fd == -1)
146 if (errno != ENOENT)143 return -1;
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 }
158 close(fd);144 close(fd);
159 145
160 return 0;146 return 0;