+static struct bloom *global_bloom_filter;
+static struct bloom *user_bloom_filter;
+
+static int consider_bloom(struct stat64 *s)
+{
+ if (!global_bloom_filter)
+ return 0;
+ if (s->st_nlink <= 1)
+ return 0;
+ return 1;
+}
+
+/** Data size to hash for the global bloom filter. */
+#define GLOBAL_BLOOM_BUF_SIZE (sizeof(ino_t) + sizeof(dev_t) + sizeof(off_t))
+/** For the user bloom filter also the uid is being hashed. */
+#define USER_BLOOM_BUF_SIZE (GLOBAL_BLOOM_BUF_SIZE + sizeof(uid_t))
+
+static void make_bloom_buf(struct stat64 *s, uint8_t buf[USER_BLOOM_BUF_SIZE])
+{
+ uint8_t *p = buf;
+
+ if (!consider_bloom(s))
+ return;
+ memcpy(p, &s->st_ino, sizeof(ino_t));
+ p += sizeof(ino_t);
+ memcpy(p, &s->st_dev, sizeof(dev_t));
+ p += sizeof(dev_t);
+ memcpy(p, &s->st_size, sizeof(off_t));
+ p += sizeof(off_t);
+ memcpy(p, &s->st_uid, sizeof(uid_t));
+}
+
+static int insert_global_bloom(struct stat64 *s,
+ uint8_t buf[USER_BLOOM_BUF_SIZE])
+{
+ if (!consider_bloom(s))
+ return 0;
+ return bloom_insert(buf, GLOBAL_BLOOM_BUF_SIZE, global_bloom_filter);
+}
+
+static int insert_user_bloom(struct stat64 *s,
+ uint8_t buf[USER_BLOOM_BUF_SIZE])
+{
+ if (!consider_bloom(s))
+ return 0;
+ return bloom_insert(buf, USER_BLOOM_BUF_SIZE, user_bloom_filter);
+}