diff options
author | peter <peter@FreeBSD.org> | 2001-01-31 08:42:35 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2001-01-31 08:42:35 +0000 |
commit | 312d4981dc089e0a17e1a9f2cdf4d7327f25af69 (patch) | |
tree | 8e6ad9783bf845045f2db81e36e2cfc996e45a16 /usr.sbin/config | |
parent | c276446c27b0fa9eca7b39c089fd2bf663a59212 (diff) | |
download | FreeBSD-src-312d4981dc089e0a17e1a9f2cdf4d7327f25af69.zip FreeBSD-src-312d4981dc089e0a17e1a9f2cdf4d7327f25af69.tar.gz |
Redo the stray header file cleanup code to not depend on timestamps
or access times or anything. Just bite the bullet and keep a list of
header files that we know about.
Diffstat (limited to 'usr.sbin/config')
-rw-r--r-- | usr.sbin/config/config.h | 1 | ||||
-rw-r--r-- | usr.sbin/config/main.c | 71 | ||||
-rw-r--r-- | usr.sbin/config/mkheaders.c | 9 | ||||
-rw-r--r-- | usr.sbin/config/mkoptions.c | 1 |
4 files changed, 54 insertions, 28 deletions
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index 71542b5..5a98de2 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -139,6 +139,7 @@ char *get_word(FILE *); char *get_quoted_word(FILE *); char *path(char *); char *raisestr(char *); +void remember(char *); void moveifchanged(const char *, const char *); void newbus_ioconf(void); int yyparse(void); diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c index 055e65b..32be90d 100644 --- a/usr.sbin/config/main.c +++ b/usr.sbin/config/main.c @@ -79,9 +79,12 @@ int profiling; static void configfile(void); static void get_srcdir(void); static void usage(void); -#if 0 -static void cleanheaders(char *, time_t); -#endif +static void cleanheaders(char *); + +struct hdr_list { + char *h_name; + struct hdr_list *h_next; +} *htab; /* * Config builds a set of files for building a UNIX @@ -94,9 +97,6 @@ main(int argc, char **argv) struct stat buf; int ch, len; char *p; - time_t starttime; - - starttime = time(0); while ((ch = getopt(argc, argv, "d:gp")) != -1) switch (ch) { @@ -178,9 +178,7 @@ main(int argc, char **argv) makefile(); /* build Makefile */ headers(); /* make a lot of .h files */ configfile(); /* put config file into kernel*/ -#if 0 - cleanheaders(p, starttime); -#endif + cleanheaders(p); printf("Kernel build directory is %s\n", p); exit(0); } @@ -420,17 +418,19 @@ moveifchanged(const char *from_name, const char *to_name) } } -#if 0 static void -cleanheaders(char *p, time_t starttime) +cleanheaders(char *p) { DIR *dirp; struct dirent *dp; - struct stat st; struct file_list *fl; + struct hdr_list *hl; int i; - starttime--; + remember("y.tab.h"); + remember("setdefs.h"); + for (fl = ftab; fl != NULL; fl = fl->f_next) + remember(fl->f_fn); /* * Scan the build directory and clean out stuff that looks like @@ -442,32 +442,49 @@ cleanheaders(char *p, time_t starttime) /* Skip non-headers */ if (dp->d_name[i] != '.' || dp->d_name[i + 1] != 'h') continue; - /* Skip stuff that config created or examined in this pass */ - if (stat(path(dp->d_name), &st) == -1) - err(1, "stat(%s)", dp->d_name); - if (st.st_mtime >= starttime || st.st_atime >= starttime || - st.st_ctime >= starttime) - continue; /* Skip special stuff, eg: bus_if.h, but check opt_*.h */ if (index(dp->d_name, '_') && strncmp(dp->d_name, "opt_", 4) != 0) continue; - /* Some more magic names to skip. Sigh. */ - if (strcmp(dp->d_name, "setdefs.h") == 0 || - strcmp(dp->d_name, "y.tab.h") == 0) - continue; /* Check if it is a target file */ - for (fl = ftab; fl != NULL; fl = fl->f_next) { - if (strcmp(dp->d_name, fl->f_fn) == 0) { + for (hl = htab; hl != NULL; hl = hl->h_next) { + if (strcmp(dp->d_name, hl->h_name) == 0) { break; } } - if (fl) + if (hl) continue; printf("Removing stale header: %s\n", dp->d_name); unlink(path(dp->d_name)); } (void)closedir(dirp); +} +void +remember(char *file) +{ + char *s; + struct hdr_list *hl; + + if ((s = strrchr(file, '/')) != NULL) + s++; + else + s = file; + s = ns(s); + + if (index(s, '_') && strncmp(s, "opt_", 4) != 0) { + free(s); + return; + } + for (hl = htab; hl != NULL; hl = hl->h_next) { + if (strcmp(s, hl->h_name) == 0) { + free(s); + return; + } + } + hl = malloc(sizeof(*hl)); + bzero(hl, sizeof(*hl)); + hl->h_name = s; + hl->h_next = htab; + htab = hl; } -#endif diff --git a/usr.sbin/config/mkheaders.c b/usr.sbin/config/mkheaders.c index 9b44da4..91fccf2 100644 --- a/usr.sbin/config/mkheaders.c +++ b/usr.sbin/config/mkheaders.c @@ -61,17 +61,23 @@ headers(void) { struct file_list *fl; struct device *dp; + int match; for (fl = ftab; fl != 0; fl = fl->f_next) { if (fl->f_needs != 0) { + match = 0; for (dp = dtab; dp != 0; dp = dp->d_next) { if (eq(dp->d_name, fl->f_needs)) { + match++; if ((dp->d_type & TYPEMASK) == DEVICE) dp->d_type |= DEVDONE; } } - if (fl->f_flags & NEED_COUNT) + if (fl->f_flags & NEED_COUNT) { + if (match) +printf("warning: static limits for %s are set\n", fl->f_needs); do_count(fl->f_needs); + } } } for (dp = dtab; dp != 0; dp = dp->d_next) { @@ -118,6 +124,7 @@ do_header(char *dev, int count) file = toheader(dev); name = tomacro(dev); + remember(file); inf = fopen(file, "r"); oldcount = -1; if (inf == 0) { diff --git a/usr.sbin/config/mkoptions.c b/usr.sbin/config/mkoptions.c index 0ddf29f..2bc64a6 100644 --- a/usr.sbin/config/mkoptions.c +++ b/usr.sbin/config/mkoptions.c @@ -161,6 +161,7 @@ do_option(char *name) } } + remember(file); inf = fopen(file, "r"); if (inf == 0) { outf = fopen(file, "w"); |