/* Copyright (c) 2009-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "str.h"
#include "hex-binary.h"
#include "hostpid.h"
#include "randgen.h"
#include "read-full.h"
#include "fs-sis-common.h"
#include "doveadm.h"
#include "doveadm-print.h"
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
They may be hard linked to hashes/<hash>
*/
{
}
static int
{
*path2_inode_r = 0;
/* do a byte-by-byte comparison for the files to find out if they're
the same or if this is a hash collision */
if (fd1 == -1) {
return -1;
}
if (fd2 == -1) {
i_close_fd(&fd1);
return -1;
}
ret = 0;
else {
/* @UNSAFE: sizes match. compare. */
int ret2;
if (ret2 < 0)
else
ret = 0;
break;
}
ret = 0;
break;
}
}
if (ret1 < 0)
else if (ret1 == 0)
ret = 1;
}
return ret;
}
static int
{
return 0;
return -1;
}
return -1;
}
return 0;
}
return -1;
}
return 1;
}
{
int ret;
/* fname should be in <hash>-<guid> format */
/* first file with this hash. we're done */
return 0;
}
/* either path was already deleted or hashes dir
doesn't exist */
return 0;
return -1;
}
/* try again */
return 0;
}
return -1;
}
/* need to do a byte-by-byte comparison. but check first if someone
else already had deduplicated the file. */
/* just got deleted */
return 0;
}
return -1;
}
/* already deduplicated */
return 0;
}
if (ret < 0) {
/* either path or hashes_path was deleted. */
}
return -1;
}
if (ret > 0) {
/* equal, replace with hard link */
if (ret > 0)
return 0;
else if (ret < 0)
return -1;
/* too many hard links or inode changed */
}
/* replace hashes link with this */
}
{
struct dirent *d;
int ret;
if (argc < 3)
/* go through the filenames in the queue dir and see if
we can deduplicate them. */
if (d->d_name[0] == '.')
continue;
}
i_fatal("%s is not a valid sis-queue file, "
"is the queue directory correct?",
}
T_BEGIN {
} T_END;
if (ret == 0)
}
}
{
struct dirent *d;
}
return;
}
}
}
}
};
};