(void) strncpy (fname, dp->d_name, MAXNAMELEN);
(void) strncpy (fname, dp->d_name, MAXNAMLEN);
load_database (cron_db * old_db){  DIR *dir;  struct stat statbuf;  struct stat syscron_stat;  struct dirent *dp;  cron_db new_db;  user *u, *nu;  Debug (DLOAD, ("[%d] load_database()\n", getpid ()));  /* before we start loading any data, do a stat on spool_dir   * so that if anything changes as of this moment (i.e., before we've   * cached any of the database), we'll see the changes next time.   */  if (stat (spool_dir, &statbuf) < OK)    {      log_it ("CRON", getpid (), "STAT FAILED", spool_dir);      (void) exit (ERROR_EXIT);    }  /* track system crontab file   */  if (stat (syscrontab, &syscron_stat) < OK)    syscron_stat.st_mtime = 0;  /* if spooldir's mtime has not changed, we don't need to fiddle with   * the database.   *   * Note that old_db->mtime is initialized to 0 in main(), and   * so is guaranteed to be different than the stat() mtime the first   * time this function is called.   */  if (old_db->mtime == TMAX (statbuf.st_mtime, syscron_stat.st_mtime))    {      Debug (DLOAD, ("[%d] spool dir mtime unch, no load needed.\n",		     getpid ()));      return;    }  /* something's different.  make a new database, moving unchanged   * elements from the old database, reloading elements that have   * actually changed.  Whatever is left in the old database when   * we're done is chaff -- crontabs that disappeared.   */  new_db.mtime = TMAX (statbuf.st_mtime, syscron_stat.st_mtime);  new_db.head = new_db.tail = NULL;  if (syscron_stat.st_mtime)    {      process_crontab ("root", "*system*",		       syscrontab, &syscron_stat, &new_db, old_db);    }  /* we used to keep this dir open all the time, for the sake of   * efficiency.  however, we need to close it in every fork, and   * we fork a lot more often than the mtime of the dir changes.   */  if (!(dir = opendir (spool_dir)))    {      log_it ("CRON", getpid (), "OPENDIR FAILED", spool_dir);      (void) exit (ERROR_EXIT);    }  while (NULL != (dp = readdir (dir)))    {      char fname[MAXNAMLEN + 1], tabname[MAXNAMLEN + 1];      /* avoid file names beginning with ".".  this is good       * because we would otherwise waste two guaranteed calls       * to getpwnam() for . and .., and also because user names       * starting with a period are just too nasty to consider.       */      if (dp->d_name[0] == '.')	continue;      (void) strncpy (fname, dp->d_name, MAXNAMELEN);      snprintf (tabname, MAXNAMLEN + 1, CRON_TAB (fname));      process_crontab (fname, fname, tabname, &statbuf, &new_db, old_db);    }  closedir (dir);  /* if we don't do this, then when our children eventually call   * getpwnam() in do_command.c's child_process to verify MAILTO=,   * they will screw us up (and v-v).   */  endpwent ();  /* whatever's left in the old database is now junk.   */  Debug (DLOAD, ("unlinking old database:\n"));  for (u = old_db->head; u != NULL; u = nu)    {      Debug (DLOAD, ("\t%s\n", u->name));      nu = u->next;      unlink_user (old_db, u);      free_user (u);    }  /* overwrite the database control block with the new one.   */  *old_db = new_db;  Debug (DLOAD, ("load_database is done\n"));}