yet.
}
-void file_checksum(char *fname,char *sum,off_t size)
+void file_checksum(char *fname,char *sum,OFF_T size)
{
- off_t i;
+ OFF_T i;
MDstruct MD;
struct map_struct *buf;
int fd;
- off_t len = size;
+ OFF_T len = size;
char tmpchunk[CSUM_CHUNK];
bzero(sum,csum_length);
echo yes;AC_DEFINE(HAVE_LONGLONG),
echo no)
+echo $ac_n "checking for off64_t ... $ac_c"
+AC_TRY_RUN([#include <stdio.h>
+#include <sys/stat.h>
+main() { struct stat64 st; off64_t s; exit((lstat64("/dev/null", &st)==0)?0:1); }],
+echo yes;AC_DEFINE(HAVE_LONGLONG),
+echo no)
+
echo $ac_n "checking for utimbuf ... $ac_c"
AC_TRY_COMPILE([#include <sys/types.h>
#include <utime.h>],
static char **local_exclude_list;
-int link_stat(const char *Path, struct stat *Buffer)
+int link_stat(const char *Path, STRUCT_STAT *Buffer)
{
#if SUPPORT_LINKS
if (copy_links) {
- return stat(Path, Buffer);
+ return do_stat(Path, Buffer);
} else {
- return lstat(Path, Buffer);
+ return do_lstat(Path, Buffer);
}
#else
- return stat(Path, Buffer);
+ return do_stat(Path, Buffer);
#endif
}
This function is used to check if a file should be included/excluded
from the list of files based on its name and type etc
*/
-static int match_file_name(char *fname,struct stat *st)
+static int match_file_name(char *fname,STRUCT_STAT *st)
{
if (check_exclude(fname,local_exclude_list)) {
if (verbose > 2)
static void set_filesystem(char *fname)
{
- struct stat st;
+ STRUCT_STAT st;
if (link_stat(fname,&st) != 0) return;
filesystem_dev = st.st_dev;
}
/* determine if a file in a different filesstem should be skipped
when one_file_system is set. We bascally only want to include
the mount points - but they can be hard to find! */
-static int skip_filesystem(char *fname, struct stat *st)
+static int skip_filesystem(char *fname, STRUCT_STAT *st)
{
- struct stat st2;
+ STRUCT_STAT st2;
char *p = strrchr(fname, '/');
/* skip all but directories */
static struct file_struct *make_file(char *fname)
{
struct file_struct *file;
- struct stat st;
+ STRUCT_STAT st;
char sum[SUM_LENGTH];
char *p;
char cleaned_name[MAXPATHLEN];
struct file_list *send_file_list(int f,int argc,char *argv[])
{
int i,l;
- struct stat st;
+ STRUCT_STAT st;
char *p,*dir;
char dbuf[MAXPATHLEN];
char lastpath[MAXPATHLEN]="";
#if SUPPORT_HARD_LINKS
static void hard_link_one(int i)
{
- struct stat st1,st2;
+ STRUCT_STAT st1,st2;
if (link_stat(f_name(&hlink_list[i-1]),&st1) != 0) return;
static char *get_local_name(struct file_list *flist,char *name)
{
- struct stat st;
+ STRUCT_STAT st;
- if (stat(name,&st) == 0) {
+ if (do_stat(name,&st) == 0) {
if (S_ISDIR(st.st_mode)) {
if (chdir(name) != 0) {
fprintf(FERROR,"chdir %s : %s (1)\n",name,strerror(errno));
}
-static off_t last_match;
+static OFF_T last_match;
static void matched(int f,struct sum_struct *s,struct map_struct *buf,
- off_t offset,int i)
+ OFF_T offset,int i)
{
- off_t n = offset - last_match;
+ OFF_T n = offset - last_match;
int j;
if (verbose > 2 && i >= 0)
static void hash_search(int f,struct sum_struct *s,
- struct map_struct *buf,off_t len)
+ struct map_struct *buf,OFF_T len)
{
- off_t offset;
+ OFF_T offset;
int j,k;
int end;
char sum2[SUM_LENGTH];
}
-void match_sums(int f,struct sum_struct *s,struct map_struct *buf,off_t len)
+void match_sums(int f,struct sum_struct *s,struct map_struct *buf,OFF_T len)
{
char file_sum[MD4_SUM_LENGTH];
struct dirent *di;
char buf[MAXPATHLEN];
extern int force_delete;
- struct stat st;
+ STRUCT_STAT st;
int ret;
if (do_unlink(fname) == 0 || errno == ENOENT) return 0;
#if SUPPORT_LINKS
- ret = lstat(fname, &st);
+ ret = do_lstat(fname, &st);
#else
- ret = stat(fname, &st);
+ ret = do_stat(fname, &st);
#endif
if (ret) {
fprintf(FERROR,"stat(%s) : %s\n", fname, strerror(errno));
generate approximately one checksum every n bytes
*/
-static struct sum_struct *generate_sums(struct map_struct *buf,off_t len,int n)
+static struct sum_struct *generate_sums(struct map_struct *buf,OFF_T len,int n)
{
int i;
struct sum_struct *s;
int count;
int block_len = n;
int remainder = (len%block_len);
- off_t offset = 0;
+ OFF_T offset = 0;
count = (len+(block_len-1))/block_len;
{
struct sum_struct *s;
int i;
- off_t offset = 0;
+ OFF_T offset = 0;
s = (struct sum_struct *)malloc(sizeof(*s));
if (!s) out_of_memory("receive_sums");
}
-static int set_perms(char *fname,struct file_struct *file,struct stat *st,
+static int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
int report)
{
int updated = 0;
- struct stat st2;
+ STRUCT_STAT st2;
if (dry_run) return 0;
/* choose whether to skip a particular file */
static int skip_file(char *fname,
- struct file_struct *file, struct stat *st)
+ struct file_struct *file, STRUCT_STAT *st)
{
if (st->st_size != file->length) {
return 0;
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
{
int fd;
- struct stat st;
+ STRUCT_STAT st;
struct map_struct *buf;
struct sum_struct *s;
int statret;
static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname)
{
int i,n,remainder,len,count;
- off_t offset = 0;
- off_t offset2;
+ OFF_T offset = 0;
+ OFF_T offset2;
char *data;
static char file_sum1[MD4_SUM_LENGTH];
static char file_sum2[MD4_SUM_LENGTH];
static int delete_already_done(struct file_list *flist,int j)
{
int i;
- struct stat st;
+ STRUCT_STAT st;
if (link_stat(f_name(flist->files[j]), &st)) return 1;
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
{
int fd1,fd2;
- struct stat st;
+ STRUCT_STAT st;
char *fname;
char fnametmp[MAXPATHLEN];
struct map_struct *buf;
/* open the file */
fd1 = open(fname,O_RDONLY);
- if (fd1 != -1 && fstat(fd1,&st) != 0) {
+ if (fd1 != -1 && do_fstat(fd1,&st) != 0) {
fprintf(FERROR,"fstat %s : %s\n",fname,strerror(errno));
receive_data(f_in,NULL,-1,NULL);
close(fd1);
int fd;
struct sum_struct *s;
struct map_struct *buf;
- struct stat st;
+ STRUCT_STAT st;
char fname[MAXPATHLEN];
int i;
struct file_struct *file;
}
/* map the local file */
- if (fstat(fd,&st) != 0) {
+ if (do_fstat(fd,&st) != 0) {
io_error = 1;
fprintf(FERROR,"fstat failed : %s\n",strerror(errno));
free_sums(s);
#define uint32 unsigned int32
#endif
-#if (SIZEOF_LONG == 8)
+#if HAVE_OFF64_T
+#define OFF_T off64_t
+#define STRUCT_STAT struct stat64
+#else
+#define OFF_T off_t
+#define STRUCT_STAT struct stat
+#endif
+
+#if HAVE_OFF64_T
+#define int64 off64_t
+#elif (SIZEOF_LONG == 8)
#define int64 long
#elif (SIZEOF_INT == 8)
#define int64 int
struct file_struct {
unsigned flags;
time_t modtime;
- off_t length;
+ OFF_T length;
mode_t mode;
ino_t inode;
dev_t dev;
};
struct sum_buf {
- off_t offset; /* offset in file of this chunk */
+ OFF_T offset; /* offset in file of this chunk */
int len; /* length of chunk of file */
int i; /* index of this chunk */
uint32 sum1; /* simple checksum */
};
struct sum_struct {
- off_t flength; /* total file length */
+ OFF_T flength; /* total file length */
int count; /* how many chunks */
int remainder; /* flength % block_length */
int n; /* block_length */
struct map_struct {
char *map,*p;
int fd,p_size,p_len;
- off_t size, p_offset;
+ OFF_T size, p_offset;
};
/* we need this function because of the silly way in which duplicate
if (dry_run) return NULL;
return mktemp(template);
}
+
+int do_stat(const char *fname, STRUCT_STAT *st)
+{
+#if HAVE_OFF64_T
+ return stat64(fname, st);
+#else
+ return stat(fname, st);
+#endif
+}
+
+int do_lstat(const char *fname, STRUCT_STAT *st)
+{
+#if HAVE_OFF64_T
+ return lstat64(fname, st);
+#else
+ return lstat(fname, st);
+#endif
+}
+
+int do_fstat(int fd, STRUCT_STAT *st)
+{
+#if HAVE_OFF64_T
+ return fstat64(fd, st);
+#else
+ return fstat(fd, st);
+#endif
+}
}
-struct map_struct *map_file(int fd,off_t len)
+struct map_struct *map_file(int fd,OFF_T len)
{
struct map_struct *ret;
ret = (struct map_struct *)malloc(sizeof(*ret));
}
-char *map_ptr(struct map_struct *map,off_t offset,int len)
+char *map_ptr(struct map_struct *map,OFF_T offset,int len)
{
int nread = -2;