rc_newer/older_than only report file if time_t is a pointer, so it

should take precedence in the argument list.
This commit is contained in:
Roy Marples 2009-01-13 09:11:31 +00:00
parent 3d37005a3d
commit fcf1cce549
3 changed files with 30 additions and 24 deletions

View File

@ -545,7 +545,7 @@ librc_hidden_def(rc_deptree_order)
static bool static bool
mtime_check(const char *source, const char *target, bool newer, mtime_check(const char *source, const char *target, bool newer,
char *file, time_t *rel) time_t *rel, char *file)
{ {
struct stat buf; struct stat buf;
time_t mtime; time_t mtime;
@ -599,7 +599,7 @@ mtime_check(const char *source, const char *target, bool newer,
if (d->d_name[0] == '.') if (d->d_name[0] == '.')
continue; continue;
snprintf(path, sizeof(path), "%s/%s", target, d->d_name); snprintf(path, sizeof(path), "%s/%s", target, d->d_name);
if (!mtime_check(source, path, newer, file, rel)) { if (!mtime_check(source, path, newer, rel, file)) {
retval = false; retval = false;
if (rel == NULL) if (rel == NULL)
break; break;
@ -611,18 +611,18 @@ mtime_check(const char *source, const char *target, bool newer,
bool bool
rc_newer_than(const char *source, const char *target, rc_newer_than(const char *source, const char *target,
char *file, time_t *newest) time_t *newest, char *file)
{ {
return mtime_check(source, target, true, file, newest); return mtime_check(source, target, true, newest, file);
} }
librc_hidden_def(rc_newer_than) librc_hidden_def(rc_newer_than)
bool bool
rc_older_than(const char *source, const char *target, rc_older_than(const char *source, const char *target,
char *file, time_t *oldest) time_t *oldest, char *file)
{ {
return mtime_check(source, target, false, file, oldest); return mtime_check(source, target, false, oldest, file);
} }
librc_hidden_def(rc_older_than) librc_hidden_def(rc_older_than)
@ -659,7 +659,7 @@ static const char *const depdirs[] =
}; };
bool bool
rc_deptree_update_needed(char *file, time_t *newest) rc_deptree_update_needed(time_t *newest, char *file)
{ {
bool newer = false; bool newer = false;
RC_STRINGLIST *config; RC_STRINGLIST *config;
@ -675,34 +675,34 @@ rc_deptree_update_needed(char *file, time_t *newest)
* data in our deptree */ * data in our deptree */
if (!existss(RC_DEPTREE_CACHE)) if (!existss(RC_DEPTREE_CACHE))
return true; return true;
if (!rc_newer_than(RC_DEPTREE_CACHE, RC_INITDIR, file, newest)) if (!rc_newer_than(RC_DEPTREE_CACHE, RC_INITDIR, newest, file))
newer = true; newer = true;
if (!rc_newer_than(RC_DEPTREE_CACHE, RC_CONFDIR, file, newest)) if (!rc_newer_than(RC_DEPTREE_CACHE, RC_CONFDIR, newest, file))
newer = true; newer = true;
#ifdef RC_PKG_INITDIR #ifdef RC_PKG_INITDIR
if (!rc_newer_than(RC_DEPTREE_CACHE, RC_PKG_INITDIR, file, newest)) if (!rc_newer_than(RC_DEPTREE_CACHE, RC_PKG_INITDIR, newest, file))
newer = true; newer = true;
#endif #endif
#ifdef RC_PKG_CONFDIR #ifdef RC_PKG_CONFDIR
if (!rc_newer_than(RC_DEPTREE_CACHE, RC_PKG_CONFDIR, file, newest)) if (!rc_newer_than(RC_DEPTREE_CACHE, RC_PKG_CONFDIR, newest, file))
newer = true; newer = true;
#endif #endif
#ifdef RC_LOCAL_INITDIR #ifdef RC_LOCAL_INITDIR
if (!rc_newer_than(RC_DEPTREE_CACHE, RC_LOCAL_INITDIR, file, newest)) if (!rc_newer_than(RC_DEPTREE_CACHE, RC_LOCAL_INITDIR, newest, file))
newer = true; newer = true;
#endif #endif
#ifdef RC_LOCAL_CONFDIR #ifdef RC_LOCAL_CONFDIR
if (!rc_newer_than(RC_DEPTREE_CACHE, RC_LOCAL_CONFDIR, file, newest)) if (!rc_newer_than(RC_DEPTREE_CACHE, RC_LOCAL_CONFDIR, newest, file))
newer = true; newer = true;
#endif #endif
if (!rc_newer_than(RC_DEPTREE_CACHE, "/etc/rc.conf", file, newest)) if (!rc_newer_than(RC_DEPTREE_CACHE, "/etc/rc.conf", newest, file))
newer = true; newer = true;
/* Some init scripts dependencies change depending on config files /* Some init scripts dependencies change depending on config files
* outside of baselayout, like syslog-ng, so we check those too. */ * outside of baselayout, like syslog-ng, so we check those too. */
config = rc_config_list(RC_DEPCONFIG); config = rc_config_list(RC_DEPCONFIG);
TAILQ_FOREACH(s, config, entries) { TAILQ_FOREACH(s, config, entries) {
if (!rc_newer_than(RC_DEPTREE_CACHE, s->value, file, newest)) { if (!rc_newer_than(RC_DEPTREE_CACHE, s->value, newest, file)) {
newer = true; newer = true;
if (newest == NULL) if (newest == NULL)
break; break;

View File

@ -304,15 +304,21 @@ typedef void *RC_DEPTREE;
/*! Check to see if source is newer than target. /*! Check to see if source is newer than target.
* If target is a directory then we traverse it and it's children. * If target is a directory then we traverse it and it's children.
* time_t returns the time of the newest file found if newer. * @param source
* @return true if source is newer than target, otherwise false */ * @param target
bool rc_newer_than(const char *, const char *, char *, time_t *); * @param mtime of newest target
* @param filename of the newest target (needs mtime param)
* @return true if source is newer than target, otherwise false */
bool rc_newer_than(const char *, const char *, time_t *, char *);
/*! Check to see if source is older than target. /*! Check to see if source is older than target.
* If target is a directory then we traverse it and it's children. * If target is a directory then we traverse it and it's children.
* time_t returns the time of the oldest file found if older. * @param source
* @return true if source is older than target, otherwise false */ * @param target
bool rc_older_than(const char *, const char *, char *, time_t *); * @param mtime of oldest target
* @param filename of the oldest target (needs mtime param)
* @return true if source is older than target, otherwise false */
bool rc_older_than(const char *, const char *, time_t *, char *);
/*! Update the cached dependency tree if it's older than any init script, /*! Update the cached dependency tree if it's older than any init script,
* its configuration file or an external configuration file the init script * its configuration file or an external configuration file the init script
@ -325,10 +331,10 @@ bool rc_deptree_update(void);
/*! Check if the cached dependency tree is older than any init script, /*! Check if the cached dependency tree is older than any init script,
* its configuration file or an external configuration file the init script * its configuration file or an external configuration file the init script
* has specified. * has specified.
* @param buffer of PATH_MAX to store newest file
* @param mtime of newest file * @param mtime of newest file
* @param buffer of PATH_MAX to store newest file
* @return true if it needs updating, otherwise false */ * @return true if it needs updating, otherwise false */
bool rc_deptree_update_needed(char *, time_t *); bool rc_deptree_update_needed(time_t *, char *);
/*! Load the cached dependency tree and return a pointer to it. /*! Load the cached dependency tree and return a pointer to it.
* This pointer should be freed with rc_deptree_free when done. * This pointer should be freed with rc_deptree_free when done.

View File

@ -65,7 +65,7 @@ _rc_deptree_load(int force, int *regen) {
FILE *fp; FILE *fp;
t = 0; t = 0;
if (rc_deptree_update_needed(file, &t) || force != 0) { if (rc_deptree_update_needed(&t, file) || force != 0) {
/* Test if we have permission to update the deptree */ /* Test if we have permission to update the deptree */
fd = open(RC_DEPTREE_CACHE, O_WRONLY); fd = open(RC_DEPTREE_CACHE, O_WRONLY);
merrno = errno; merrno = errno;