Commit | Line | Data |
---|---|---|
c627d613 AT |
1 | /* |
2 | Copyright (C) Andrew Tridgell 1996 | |
3 | Copyright (C) Paul Mackerras 1996 | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation; either version 2 of the License, or | |
8 | (at your option) any later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with this program; if not, write to the Free Software | |
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
18 | */ | |
19 | ||
20 | /* generate and receive file lists */ | |
21 | ||
22 | #include "rsync.h" | |
23 | ||
43a481dc AT |
24 | extern int csum_length; |
25 | ||
c627d613 AT |
26 | extern int verbose; |
27 | extern int am_server; | |
28 | extern int always_checksum; | |
29 | extern off_t total_size; | |
30 | ||
31 | extern int cvs_exclude; | |
32 | ||
33 | extern int one_file_system; | |
34 | extern int make_backups; | |
35 | extern int preserve_links; | |
dc5ddbcc | 36 | extern int preserve_hard_links; |
c627d613 AT |
37 | extern int preserve_perms; |
38 | extern int preserve_devices; | |
39 | extern int preserve_uid; | |
40 | extern int preserve_gid; | |
41 | extern int preserve_times; | |
42 | ||
43 | static char **local_exclude_list = NULL; | |
44 | ||
45 | static void clean_fname(char *name); | |
46 | ||
47 | ||
48 | /* | |
49 | This function is used to check if a file should be included/excluded | |
50 | from the list of files based on its name and type etc | |
51 | */ | |
52 | static int match_file_name(char *fname,struct stat *st) | |
53 | { | |
54 | if (check_exclude(fname,local_exclude_list)) { | |
55 | if (verbose > 2) | |
dc5ddbcc | 56 | fprintf(FERROR,"excluding file %s\n",fname); |
c627d613 AT |
57 | return 0; |
58 | } | |
59 | return 1; | |
60 | } | |
61 | ||
62 | /* used by the one_file_system code */ | |
63 | static dev_t filesystem_dev; | |
64 | ||
65 | static void set_filesystem(char *fname) | |
66 | { | |
67 | struct stat st; | |
68 | if (lstat(fname,&st) != 0) return; | |
69 | filesystem_dev = st.st_dev; | |
70 | } | |
71 | ||
72 | ||
73 | static void send_directory(int f,struct file_list *flist,char *dir); | |
74 | ||
75 | static char *flist_dir = NULL; | |
76 | ||
4fe159a8 AT |
77 | extern void (*send_file_entry)(struct file_struct *file,int f); |
78 | extern void (*receive_file_entry)(struct file_struct *file, | |
79 | unsigned char flags,int f); | |
80 | ||
81 | ||
82 | void send_file_entry_v11(struct file_struct *file,int f) | |
c627d613 | 83 | { |
182dca5c | 84 | unsigned char flags; |
4fe159a8 | 85 | static time_t last_time=0; |
182dca5c | 86 | static mode_t last_mode=0; |
dc5ddbcc | 87 | static dev_t last_rdev=0; |
182dca5c AT |
88 | static uid_t last_uid=0; |
89 | static gid_t last_gid=0; | |
4fe159a8 AT |
90 | static char lastname[MAXPATHLEN]=""; |
91 | int l1,l2; | |
182dca5c | 92 | |
c627d613 AT |
93 | if (f == -1) return; |
94 | ||
182dca5c AT |
95 | if (!file) { |
96 | write_byte(f,0); | |
97 | return; | |
98 | } | |
99 | ||
100 | flags = FILE_VALID; | |
101 | ||
102 | if (file->mode == last_mode) flags |= SAME_MODE; | |
dc5ddbcc | 103 | if (file->rdev == last_rdev) flags |= SAME_RDEV; |
182dca5c AT |
104 | if (file->uid == last_uid) flags |= SAME_UID; |
105 | if (file->gid == last_gid) flags |= SAME_GID; | |
4fe159a8 | 106 | if (file->modtime == last_time) flags |= SAME_TIME; |
182dca5c | 107 | |
4fe159a8 AT |
108 | for (l1=0;lastname[l1] && file->name[l1] == lastname[l1];l1++) ; |
109 | l2 = strlen(file->name) - l1; | |
110 | ||
111 | if (l1 > 0) flags |= SAME_NAME; | |
112 | if (l2 > 255) flags |= LONG_NAME; | |
d89322c4 | 113 | |
4fe159a8 AT |
114 | write_byte(f,flags); |
115 | if (flags & SAME_NAME) | |
116 | write_byte(f,l1); | |
117 | if (flags & LONG_NAME) | |
118 | write_int(f,l2); | |
9f3541e6 | 119 | else |
4fe159a8 AT |
120 | write_byte(f,l2); |
121 | write_buf(f,file->name+l1,l2); | |
122 | ||
c627d613 | 123 | write_int(f,(int)file->length); |
4fe159a8 AT |
124 | if (!(flags & SAME_TIME)) |
125 | write_int(f,(int)file->modtime); | |
182dca5c AT |
126 | if (!(flags & SAME_MODE)) |
127 | write_int(f,(int)file->mode); | |
128 | if (preserve_uid && !(flags & SAME_UID)) | |
c627d613 | 129 | write_int(f,(int)file->uid); |
182dca5c | 130 | if (preserve_gid && !(flags & SAME_GID)) |
c627d613 | 131 | write_int(f,(int)file->gid); |
dc5ddbcc AT |
132 | if (preserve_devices && IS_DEVICE(file->mode) && !(flags & SAME_RDEV)) |
133 | write_int(f,(int)file->rdev); | |
c627d613 AT |
134 | |
135 | #if SUPPORT_LINKS | |
136 | if (preserve_links && S_ISLNK(file->mode)) { | |
137 | write_int(f,strlen(file->link)); | |
138 | write_buf(f,file->link,strlen(file->link)); | |
139 | } | |
140 | #endif | |
141 | ||
dc5ddbcc AT |
142 | #if SUPPORT_HARD_LINKS |
143 | if (preserve_hard_links && S_ISREG(file->mode)) { | |
144 | write_int(f,file->dev); | |
145 | write_int(f,file->inode); | |
146 | } | |
147 | #endif | |
148 | ||
c627d613 | 149 | if (always_checksum) { |
43a481dc | 150 | write_buf(f,file->sum,csum_length); |
c627d613 | 151 | } |
182dca5c AT |
152 | |
153 | last_mode = file->mode; | |
dc5ddbcc | 154 | last_rdev = file->rdev; |
182dca5c AT |
155 | last_uid = file->uid; |
156 | last_gid = file->gid; | |
4fe159a8 AT |
157 | last_time = file->modtime; |
158 | ||
159 | strcpy(lastname,file->name); | |
160 | lastname[255] = 0; | |
182dca5c AT |
161 | } |
162 | ||
163 | ||
164 | ||
4fe159a8 AT |
165 | void receive_file_entry_v11(struct file_struct *file, |
166 | unsigned char flags,int f) | |
182dca5c | 167 | { |
d89322c4 | 168 | static time_t last_time=0; |
182dca5c | 169 | static mode_t last_mode=0; |
dc5ddbcc | 170 | static dev_t last_rdev=0; |
182dca5c AT |
171 | static uid_t last_uid=0; |
172 | static gid_t last_gid=0; | |
4fe159a8 AT |
173 | static char lastname[MAXPATHLEN]=""; |
174 | int l1=0,l2=0; | |
182dca5c | 175 | |
4fe159a8 | 176 | if (flags & SAME_NAME) |
9f3541e6 | 177 | l1 = read_byte(f); |
4fe159a8 AT |
178 | |
179 | if (flags & LONG_NAME) | |
180 | l2 = read_int(f); | |
181 | else | |
182 | l2 = read_byte(f); | |
182dca5c | 183 | |
dc5ddbcc AT |
184 | bzero((char *)file,sizeof(*file)); |
185 | ||
182dca5c AT |
186 | file->name = (char *)malloc(l1+l2+1); |
187 | if (!file->name) out_of_memory("receive_file_entry"); | |
188 | ||
4fe159a8 AT |
189 | strncpy(file->name,lastname,l1); |
190 | read_buf(f,file->name+l1,l2); | |
182dca5c AT |
191 | file->name[l1+l2] = 0; |
192 | ||
182dca5c | 193 | file->length = (off_t)read_int(f); |
4fe159a8 | 194 | file->modtime = (flags & SAME_TIME) ? last_time : (time_t)read_int(f); |
182dca5c AT |
195 | file->mode = (flags & SAME_MODE) ? last_mode : (mode_t)read_int(f); |
196 | if (preserve_uid) | |
197 | file->uid = (flags & SAME_UID) ? last_uid : (uid_t)read_int(f); | |
198 | if (preserve_gid) | |
199 | file->gid = (flags & SAME_GID) ? last_gid : (gid_t)read_int(f); | |
200 | if (preserve_devices && IS_DEVICE(file->mode)) | |
dc5ddbcc | 201 | file->rdev = (flags & SAME_RDEV) ? last_rdev : (dev_t)read_int(f); |
182dca5c AT |
202 | |
203 | #if SUPPORT_LINKS | |
204 | if (preserve_links && S_ISLNK(file->mode)) { | |
205 | int l = read_int(f); | |
206 | file->link = (char *)malloc(l+1); | |
207 | if (!file->link) out_of_memory("receive_file_entry"); | |
208 | read_buf(f,file->link,l); | |
209 | file->link[l] = 0; | |
210 | } | |
211 | #endif | |
dc5ddbcc AT |
212 | |
213 | #if SUPPORT_HARD_LINKS | |
214 | if (preserve_hard_links && S_ISREG(file->mode)) { | |
215 | file->dev = read_int(f); | |
216 | file->inode = read_int(f); | |
217 | } | |
218 | #endif | |
182dca5c AT |
219 | |
220 | if (always_checksum) | |
43a481dc | 221 | read_buf(f,file->sum,csum_length); |
182dca5c AT |
222 | |
223 | last_mode = file->mode; | |
dc5ddbcc | 224 | last_rdev = file->rdev; |
182dca5c AT |
225 | last_uid = file->uid; |
226 | last_gid = file->gid; | |
4fe159a8 AT |
227 | last_time = file->modtime; |
228 | ||
229 | strcpy(lastname,file->name); | |
230 | lastname[255] = 0; | |
c627d613 AT |
231 | } |
232 | ||
233 | ||
4fe159a8 | 234 | |
c627d613 AT |
235 | static struct file_struct *make_file(int recurse,char *fname) |
236 | { | |
237 | static struct file_struct file; | |
238 | struct stat st; | |
239 | char sum[SUM_LENGTH]; | |
240 | ||
241 | bzero(sum,SUM_LENGTH); | |
242 | ||
243 | if (lstat(fname,&st) != 0) { | |
dc5ddbcc | 244 | fprintf(FERROR,"%s: %s\n", |
c627d613 AT |
245 | fname,strerror(errno)); |
246 | return NULL; | |
247 | } | |
248 | ||
249 | if (S_ISDIR(st.st_mode) && !recurse) { | |
dc5ddbcc | 250 | fprintf(FERROR,"skipping directory %s\n",fname); |
c627d613 AT |
251 | return NULL; |
252 | } | |
253 | ||
254 | if (one_file_system && st.st_dev != filesystem_dev) | |
255 | return NULL; | |
256 | ||
257 | if (!match_file_name(fname,&st)) | |
258 | return NULL; | |
259 | ||
260 | if (verbose > 2) | |
dc5ddbcc AT |
261 | fprintf(FERROR,"make_file(%s)\n",fname); |
262 | ||
263 | bzero((char *)&file,sizeof(file)); | |
c627d613 AT |
264 | |
265 | file.name = strdup(fname); | |
266 | file.modtime = st.st_mtime; | |
267 | file.length = st.st_size; | |
268 | file.mode = st.st_mode; | |
269 | file.uid = st.st_uid; | |
270 | file.gid = st.st_gid; | |
dc5ddbcc AT |
271 | file.dev = st.st_dev; |
272 | file.inode = st.st_ino; | |
c627d613 | 273 | #ifdef HAVE_ST_RDEV |
dc5ddbcc | 274 | file.rdev = st.st_rdev; |
c627d613 AT |
275 | #endif |
276 | ||
277 | #if SUPPORT_LINKS | |
278 | if (S_ISLNK(st.st_mode)) { | |
279 | int l; | |
280 | char lnk[MAXPATHLEN]; | |
281 | if ((l=readlink(fname,lnk,MAXPATHLEN-1)) == -1) { | |
dc5ddbcc | 282 | fprintf(FERROR,"readlink %s : %s\n",fname,strerror(errno)); |
c627d613 AT |
283 | return NULL; |
284 | } | |
285 | lnk[l] = 0; | |
286 | file.link = strdup(lnk); | |
287 | } | |
288 | #endif | |
289 | ||
290 | if (always_checksum && S_ISREG(st.st_mode)) { | |
291 | file_checksum(fname,file.sum,st.st_size); | |
292 | } | |
293 | ||
294 | if (flist_dir) | |
295 | file.dir = strdup(flist_dir); | |
296 | else | |
297 | file.dir = NULL; | |
298 | ||
299 | if (!S_ISDIR(st.st_mode)) | |
300 | total_size += st.st_size; | |
301 | ||
302 | return &file; | |
303 | } | |
304 | ||
305 | ||
306 | ||
307 | static void send_file_name(int f,struct file_list *flist, | |
308 | int recurse,char *fname) | |
309 | { | |
310 | struct file_struct *file; | |
311 | ||
312 | file = make_file(recurse,fname); | |
313 | ||
314 | if (!file) return; | |
315 | ||
316 | if (flist->count >= flist->malloced) { | |
317 | flist->malloced += 100; | |
318 | flist->files = (struct file_struct *)realloc(flist->files, | |
319 | sizeof(flist->files[0])* | |
320 | flist->malloced); | |
321 | if (!flist->files) | |
322 | out_of_memory("send_file_name"); | |
323 | } | |
324 | ||
325 | if (strcmp(file->name,".") && strcmp(file->name,"/")) { | |
326 | flist->files[flist->count++] = *file; | |
327 | send_file_entry(file,f); | |
328 | } | |
329 | ||
330 | if (S_ISDIR(file->mode) && recurse) { | |
331 | char **last_exclude_list = local_exclude_list; | |
332 | send_directory(f,flist,file->name); | |
333 | local_exclude_list = last_exclude_list; | |
334 | return; | |
335 | } | |
336 | } | |
337 | ||
338 | ||
339 | ||
340 | static void send_directory(int f,struct file_list *flist,char *dir) | |
341 | { | |
342 | DIR *d; | |
343 | struct dirent *di; | |
344 | char fname[MAXPATHLEN]; | |
345 | int l; | |
346 | char *p; | |
347 | ||
348 | d = opendir(dir); | |
349 | if (!d) { | |
dc5ddbcc | 350 | fprintf(FERROR,"%s: %s\n", |
c627d613 AT |
351 | dir,strerror(errno)); |
352 | return; | |
353 | } | |
354 | ||
355 | strcpy(fname,dir); | |
356 | l = strlen(fname); | |
357 | if (fname[l-1] != '/') | |
358 | strcat(fname,"/"); | |
359 | p = fname + strlen(fname); | |
360 | ||
361 | if (cvs_exclude) { | |
362 | strcpy(p,".cvsignore"); | |
363 | local_exclude_list = make_exclude_list(fname,NULL,0); | |
364 | } | |
365 | ||
366 | for (di=readdir(d); di; di=readdir(d)) { | |
367 | if (strcmp(di->d_name,".")==0 || | |
368 | strcmp(di->d_name,"..")==0) | |
369 | continue; | |
370 | strcpy(p,di->d_name); | |
371 | send_file_name(f,flist,1,fname); | |
372 | } | |
373 | ||
374 | closedir(d); | |
375 | } | |
376 | ||
377 | ||
378 | ||
379 | struct file_list *send_file_list(int f,int recurse,int argc,char *argv[]) | |
380 | { | |
381 | int i,l; | |
382 | struct stat st; | |
383 | char *p,*dir; | |
384 | char dbuf[MAXPATHLEN]; | |
385 | struct file_list *flist; | |
386 | ||
387 | if (verbose && recurse) { | |
dc5ddbcc AT |
388 | fprintf(FINFO,"building file list ... "); |
389 | fflush(FINFO); | |
c627d613 AT |
390 | } |
391 | ||
392 | flist = (struct file_list *)malloc(sizeof(flist[0])); | |
393 | if (!flist) out_of_memory("send_file_list"); | |
394 | ||
395 | flist->count=0; | |
396 | flist->malloced = 100; | |
397 | flist->files = (struct file_struct *)malloc(sizeof(flist->files[0])* | |
398 | flist->malloced); | |
399 | if (!flist->files) out_of_memory("send_file_list"); | |
400 | ||
401 | for (i=0;i<argc;i++) { | |
402 | char fname2[MAXPATHLEN]; | |
403 | char *fname = fname2; | |
404 | ||
405 | strcpy(fname,argv[i]); | |
406 | ||
407 | l = strlen(fname); | |
408 | if (l != 1 && fname[l-1] == '/') { | |
409 | strcat(fname,"."); | |
410 | } | |
411 | ||
412 | if (lstat(fname,&st) != 0) { | |
dc5ddbcc | 413 | fprintf(FERROR,"%s : %s\n",fname,strerror(errno)); |
c627d613 AT |
414 | continue; |
415 | } | |
416 | ||
417 | if (S_ISDIR(st.st_mode) && !recurse) { | |
dc5ddbcc | 418 | fprintf(FERROR,"skipping directory %s\n",fname); |
c627d613 AT |
419 | continue; |
420 | } | |
421 | ||
422 | dir = NULL; | |
423 | p = strrchr(fname,'/'); | |
424 | if (p) { | |
425 | *p = 0; | |
426 | dir = fname; | |
427 | fname = p+1; | |
428 | } | |
429 | if (!*fname) | |
430 | fname = "."; | |
431 | ||
432 | if (dir && *dir) { | |
433 | if (getcwd(dbuf,MAXPATHLEN-1) == NULL) { | |
dc5ddbcc | 434 | fprintf(FERROR,"getwd : %s\n",strerror(errno)); |
34ccb63e | 435 | exit_cleanup(1); |
c627d613 AT |
436 | } |
437 | if (chdir(dir) != 0) { | |
dc5ddbcc | 438 | fprintf(FERROR,"chdir %s : %s\n",dir,strerror(errno)); |
c627d613 AT |
439 | continue; |
440 | } | |
441 | flist_dir = dir; | |
442 | if (one_file_system) | |
443 | set_filesystem(fname); | |
444 | send_file_name(f,flist,recurse,fname); | |
445 | flist_dir = NULL; | |
446 | if (chdir(dbuf) != 0) { | |
dc5ddbcc | 447 | fprintf(FERROR,"chdir %s : %s\n",dbuf,strerror(errno)); |
34ccb63e | 448 | exit_cleanup(1); |
c627d613 AT |
449 | } |
450 | continue; | |
451 | } | |
452 | ||
453 | if (one_file_system) | |
454 | set_filesystem(fname); | |
455 | send_file_name(f,flist,recurse,fname); | |
456 | } | |
457 | ||
458 | if (f != -1) { | |
182dca5c | 459 | send_file_entry(NULL,f); |
c627d613 AT |
460 | write_flush(f); |
461 | } | |
462 | ||
c627d613 | 463 | if (verbose && recurse) |
dc5ddbcc AT |
464 | fprintf(FINFO,"done\n"); |
465 | ||
466 | clean_flist(flist); | |
c627d613 AT |
467 | |
468 | return flist; | |
469 | } | |
470 | ||
471 | ||
472 | struct file_list *recv_file_list(int f) | |
473 | { | |
c627d613 | 474 | struct file_list *flist; |
182dca5c | 475 | unsigned char flags; |
c627d613 AT |
476 | |
477 | if (verbose > 2) | |
dc5ddbcc | 478 | fprintf(FERROR,"recv_file_list starting\n"); |
c627d613 AT |
479 | |
480 | flist = (struct file_list *)malloc(sizeof(flist[0])); | |
481 | if (!flist) | |
482 | goto oom; | |
483 | ||
484 | flist->count=0; | |
485 | flist->malloced=100; | |
486 | flist->files = (struct file_struct *)malloc(sizeof(flist->files[0])* | |
487 | flist->malloced); | |
488 | if (!flist->files) | |
489 | goto oom; | |
490 | ||
491 | ||
182dca5c | 492 | for (flags=read_byte(f); flags; flags=read_byte(f)) { |
c627d613 AT |
493 | int i = flist->count; |
494 | ||
495 | if (i >= flist->malloced) { | |
496 | flist->malloced += 100; | |
497 | flist->files =(struct file_struct *)realloc(flist->files, | |
498 | sizeof(flist->files[0])* | |
499 | flist->malloced); | |
500 | if (!flist->files) | |
501 | goto oom; | |
502 | } | |
503 | ||
182dca5c | 504 | receive_file_entry(&flist->files[i],flags,f); |
c627d613 AT |
505 | |
506 | if (S_ISREG(flist->files[i].mode)) | |
507 | total_size += flist->files[i].length; | |
508 | ||
509 | flist->count++; | |
510 | ||
511 | if (verbose > 2) | |
dc5ddbcc | 512 | fprintf(FERROR,"recv_file_name(%s)\n",flist->files[i].name); |
c627d613 AT |
513 | } |
514 | ||
515 | ||
516 | if (verbose > 2) | |
dc5ddbcc | 517 | fprintf(FERROR,"received %d names\n",flist->count); |
c627d613 AT |
518 | |
519 | clean_flist(flist); | |
520 | ||
521 | return flist; | |
522 | ||
523 | oom: | |
524 | out_of_memory("recv_file_list"); | |
525 | return NULL; /* not reached */ | |
526 | } | |
527 | ||
528 | ||
dc5ddbcc | 529 | int file_compare(struct file_struct *f1,struct file_struct *f2) |
c627d613 AT |
530 | { |
531 | if (!f1->name && !f2->name) return 0; | |
532 | if (!f1->name) return -1; | |
533 | if (!f2->name) return 1; | |
534 | return strcmp(f1->name,f2->name); | |
535 | } | |
536 | ||
537 | ||
538 | int flist_find(struct file_list *flist,struct file_struct *f) | |
539 | { | |
540 | int low=0,high=flist->count; | |
541 | ||
542 | while (low != high) { | |
543 | int mid = (low+high)/2; | |
dc5ddbcc | 544 | int ret = file_compare(&flist->files[mid],f); |
c627d613 AT |
545 | if (ret == 0) return mid; |
546 | if (ret > 0) | |
547 | high=mid; | |
548 | else | |
549 | low=mid+1; | |
550 | } | |
dc5ddbcc | 551 | if (file_compare(&flist->files[low],f) == 0) |
c627d613 AT |
552 | return low; |
553 | return -1; | |
554 | } | |
555 | ||
556 | ||
557 | static void clean_fname(char *name) | |
558 | { | |
559 | char *p; | |
560 | int l; | |
561 | int modified = 1; | |
562 | ||
563 | if (!name) return; | |
564 | ||
565 | while (modified) { | |
566 | modified = 0; | |
567 | ||
568 | if ((p=strstr(name,"/./"))) { | |
569 | modified = 1; | |
570 | while (*p) { | |
571 | p[0] = p[2]; | |
572 | p++; | |
573 | } | |
574 | } | |
575 | ||
576 | if ((p=strstr(name,"//"))) { | |
577 | modified = 1; | |
578 | while (*p) { | |
579 | p[0] = p[1]; | |
580 | p++; | |
581 | } | |
582 | } | |
583 | ||
584 | if (strncmp(p=name,"./",2) == 0) { | |
585 | modified = 1; | |
586 | while (*p) { | |
587 | p[0] = p[2]; | |
588 | p++; | |
589 | } | |
590 | } | |
591 | ||
592 | l = strlen(p=name); | |
593 | if (l > 1 && p[l-1] == '/') { | |
594 | modified = 1; | |
595 | p[l-1] = 0; | |
596 | } | |
597 | } | |
598 | } | |
599 | ||
600 | ||
601 | /* | |
602 | * This routine ensures we don't have any duplicate names in our file list. | |
603 | * duplicate names can cause corruption because of the pipelining | |
604 | */ | |
605 | void clean_flist(struct file_list *flist) | |
606 | { | |
607 | int i; | |
608 | ||
609 | if (!flist || flist->count == 0) | |
610 | return; | |
611 | ||
612 | for (i=0;i<flist->count;i++) { | |
613 | clean_fname(flist->files[i].name); | |
614 | } | |
615 | ||
616 | qsort(flist->files,flist->count, | |
617 | sizeof(flist->files[0]), | |
dc5ddbcc | 618 | (int (*)())file_compare); |
c627d613 AT |
619 | |
620 | for (i=1;i<flist->count;i++) { | |
621 | if (flist->files[i].name && | |
622 | strcmp(flist->files[i].name,flist->files[i-1].name) == 0) { | |
623 | if (verbose > 1 && !am_server) | |
dc5ddbcc AT |
624 | fprintf(FERROR,"removing duplicate name %s from file list %d\n", |
625 | flist->files[i-1].name,i-1); | |
c627d613 | 626 | free(flist->files[i-1].name); |
dc5ddbcc AT |
627 | bzero((char *)&flist->files[i-1],sizeof(flist->files[i-1])); |
628 | } | |
c627d613 AT |
629 | } |
630 | } | |
631 |