int process_symlink (const char *path, const struct stat *sb) { int ret = 0; char buf[4096] = {0, }; unsigned long long csum = 0; count_symlink++; avg_uid_symlink ^= sb->st_uid; avg_gid_symlink ^= sb->st_gid; avg_mode_symlink ^= sb->st_mode; ret = readlink (path, buf, 4096); if (ret < 0) { perror (path); goto out; } DBG ("readlink (%s) => %s\n", path, buf); csum = checksum_path (buf); DBG ("checksum_path (%s) => %llx\n", buf, csum); checksum_symlink ^= csum; ret = 0; out: return ret; }
snapshot_entry repository::cache::read_checksum(const entry &package) { try { return pm::read_checksum(checksum_path(package)); } catch (std::exception &) { BOOST_THROW_EXCEPTION(cache_read_checksum_error() << cache_read_checksum_error::package(package) << enable_nested_current()); } }
int checksum_filenames (const char *path, const struct stat *sb) { DIR *dirp = NULL; struct dirent *entry = NULL; unsigned long long csum = 0; int i = 0; int found = 0; dirp = opendir (path); if (!dirp) { perror (path); goto out; } errno = 0; while ((entry = readdir (dirp))) { /* do not calculate the checksum of the entries which user has told to ignore and proceed to other siblings.*/ if (arequal_config.ignored_directory) { for (i = 0;i < arequal_config.directories_ignored;i++) { if ((strcmp (entry->d_name, arequal_config.ignored_directory[i]) == 0)) { found = 1; DBG ("ignoring the entry %s\n", entry->d_name); break; } } if (found == 1) { found = 0; continue; } } csum = checksum_path (entry->d_name); checksum_dir ^= csum; } if (errno) { perror (path); goto out; } out: if (dirp) closedir (dirp); return 0; }