mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-03-14 12:27:09 -04:00
if no local destination is provided for the transfer then provide
a "ls -l" style listing of the files that would be transferred
This commit is contained in:
39
flist.c
39
flist.c
@@ -51,6 +51,36 @@ static struct exclude_struct **local_exclude_list;
|
||||
|
||||
static void clean_flist(struct file_list *flist, int strip_root);
|
||||
|
||||
|
||||
static void list_file_entry(struct file_struct *f)
|
||||
{
|
||||
char perms[11] = "----------";
|
||||
char *perm_map = "rwxrwxrwx";
|
||||
int i;
|
||||
|
||||
for (i=0;i<9;i++) {
|
||||
if (f->mode & (1<<i)) perms[9-i] = perm_map[8-i];
|
||||
}
|
||||
if (S_ISLNK(f->mode)) perms[0] = 'l';
|
||||
if (S_ISDIR(f->mode)) perms[0] = 'd';
|
||||
if (S_ISBLK(f->mode)) perms[0] = 'b';
|
||||
if (S_ISCHR(f->mode)) perms[0] = 'c';
|
||||
if (S_ISSOCK(f->mode)) perms[0] = 's';
|
||||
if (S_ISFIFO(f->mode)) perms[0] = 'p';
|
||||
|
||||
if (preserve_links && S_ISLNK(f->mode)) {
|
||||
rprintf(FINFO,"%s %11.0f %s %s -> %s\n",
|
||||
perms,
|
||||
(double)f->length, timestring(f->modtime),
|
||||
f_name(f), f->link);
|
||||
} else {
|
||||
rprintf(FINFO,"%s %11.0f %s %s\n",
|
||||
perms,
|
||||
(double)f->length, timestring(f->modtime), f_name(f));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int link_stat(const char *Path, STRUCT_STAT *Buffer)
|
||||
{
|
||||
#if SUPPORT_LINKS
|
||||
@@ -699,6 +729,7 @@ struct file_list *recv_file_list(int f)
|
||||
struct file_list *flist;
|
||||
unsigned char flags;
|
||||
int64 start_read;
|
||||
extern int list_only;
|
||||
|
||||
if (verbose && recurse && !am_server) {
|
||||
rprintf(FINFO,"receiving file list ... ");
|
||||
@@ -765,6 +796,14 @@ struct file_list *recv_file_list(int f)
|
||||
io_error |= read_int(f);
|
||||
}
|
||||
|
||||
if (list_only) {
|
||||
int i;
|
||||
for (i=0;i<flist->count;i++) {
|
||||
list_file_entry(flist->files[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (verbose > 2)
|
||||
rprintf(FINFO,"recv_file_list done\n");
|
||||
|
||||
|
||||
@@ -165,6 +165,9 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
|
||||
char *fnamecmp;
|
||||
char fnamecmpbuf[MAXPATHLEN];
|
||||
extern char *compare_dest;
|
||||
extern int list_only;
|
||||
|
||||
if (list_only) return;
|
||||
|
||||
if (verbose > 2)
|
||||
rprintf(FINFO,"recv_generator(%s,%d)\n",fname,i);
|
||||
|
||||
24
log.c
24
log.c
@@ -26,33 +26,11 @@
|
||||
static FILE *logfile;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
return the date and time as a string
|
||||
****************************************************************************/
|
||||
static char *timestring(void )
|
||||
{
|
||||
static char TimeBuf[200];
|
||||
time_t t = time(NULL);
|
||||
struct tm *tm = localtime(&t);
|
||||
|
||||
#ifdef HAVE_STRFTIME
|
||||
strftime(TimeBuf,sizeof(TimeBuf)-1,"%Y/%m/%d %T",tm);
|
||||
#else
|
||||
strlcpy(TimeBuf, asctime(tm), sizeof(TimeBuf)-1);
|
||||
#endif
|
||||
|
||||
if (TimeBuf[strlen(TimeBuf)-1] == '\n') {
|
||||
TimeBuf[strlen(TimeBuf)-1] = 0;
|
||||
}
|
||||
|
||||
return(TimeBuf);
|
||||
}
|
||||
|
||||
static void logit(int priority, char *buf)
|
||||
{
|
||||
if (logfile) {
|
||||
fprintf(logfile,"%s [%d] %s",
|
||||
timestring(), (int)getpid(), buf);
|
||||
timestring(time(NULL)), (int)getpid(), buf);
|
||||
fflush(logfile);
|
||||
} else {
|
||||
syslog(priority, "%s", buf);
|
||||
|
||||
21
main.c
21
main.c
@@ -384,6 +384,7 @@ int client_run(int f_in, int f_out, int pid, int argc, char *argv[])
|
||||
int status = 0, status2 = 0;
|
||||
char *local_name = NULL;
|
||||
extern int am_sender;
|
||||
extern int list_only;
|
||||
|
||||
setup_protocol(f_out,f_in);
|
||||
|
||||
@@ -412,6 +413,8 @@ int client_run(int f_in, int f_out, int pid, int argc, char *argv[])
|
||||
report(-1);
|
||||
exit_cleanup(status);
|
||||
}
|
||||
|
||||
if (argc == 0) list_only = 1;
|
||||
|
||||
send_exclude_list(f_out);
|
||||
|
||||
@@ -462,6 +465,20 @@ static int start_client(int argc, char *argv[])
|
||||
extern int am_sender;
|
||||
extern char *shell_cmd;
|
||||
|
||||
if (strncasecmp(URL_PREFIX, argv[0], strlen(URL_PREFIX)) == 0) {
|
||||
char *host, *path;
|
||||
|
||||
host = argv[0] + strlen(URL_PREFIX);
|
||||
p = strchr(host,'/');
|
||||
if (p) {
|
||||
*p = 0;
|
||||
path = p+1;
|
||||
} else {
|
||||
path="";
|
||||
}
|
||||
return start_socket_client(host, path, argc-1, argv+1);
|
||||
}
|
||||
|
||||
p = find_colon(argv[0]);
|
||||
|
||||
if (p) {
|
||||
@@ -470,7 +487,7 @@ static int start_client(int argc, char *argv[])
|
||||
return start_socket_client(argv[0], p+2, argc-1, argv+1);
|
||||
}
|
||||
|
||||
if (argc < 2) {
|
||||
if (argc < 1) {
|
||||
usage(FERROR);
|
||||
exit_cleanup(1);
|
||||
}
|
||||
@@ -525,7 +542,7 @@ static int start_client(int argc, char *argv[])
|
||||
shell_path?shell_path:"");
|
||||
}
|
||||
|
||||
if (!am_sender && argc != 1) {
|
||||
if (!am_sender && argc > 1) {
|
||||
usage(FERROR);
|
||||
exit_cleanup(1);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ int rsync_port = RSYNC_PORT;
|
||||
|
||||
int verbose = 0;
|
||||
int always_checksum = 0;
|
||||
|
||||
int list_only = 0;
|
||||
|
||||
void usage(int F)
|
||||
{
|
||||
|
||||
2
rsync.h
2
rsync.h
@@ -23,6 +23,8 @@
|
||||
#define RSYNC_NAME "rsync"
|
||||
#define RSYNCD_CONF "/etc/rsyncd.conf"
|
||||
|
||||
#define URL_PREFIX "rsync://"
|
||||
|
||||
#define BACKUP_SUFFIX "~"
|
||||
|
||||
/* a non-zero CHAR_OFFSET makes the rolling sum stronger, but is
|
||||
|
||||
3
rsync.yo
3
rsync.yo
@@ -140,6 +140,9 @@ itemize(
|
||||
|
||||
it() if you specify no path name on the remote server then the
|
||||
list of accessible paths on the server will be shown.
|
||||
|
||||
it() if you specify no local destination then a listing of the
|
||||
specified files on the remote server is provided
|
||||
)
|
||||
|
||||
Some paths on the remote server may require authentication. If so then
|
||||
|
||||
22
util.c
22
util.c
@@ -762,3 +762,25 @@ char *sanitize_path(char *p)
|
||||
return(copy);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
return the date and time as a string
|
||||
****************************************************************************/
|
||||
char *timestring(time_t t)
|
||||
{
|
||||
static char TimeBuf[200];
|
||||
struct tm *tm = localtime(&t);
|
||||
|
||||
#ifdef HAVE_STRFTIME
|
||||
strftime(TimeBuf,sizeof(TimeBuf)-1,"%Y/%m/%d %T",tm);
|
||||
#else
|
||||
strlcpy(TimeBuf, asctime(tm), sizeof(TimeBuf)-1);
|
||||
#endif
|
||||
|
||||
if (TimeBuf[strlen(TimeBuf)-1] == '\n') {
|
||||
TimeBuf[strlen(TimeBuf)-1] = 0;
|
||||
}
|
||||
|
||||
return(TimeBuf);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user