>From 2572ffd91de6b025081405b17937ebc0bf8df3db Mon Sep 17 00:00:00 2001 From: Vaclav Ovsik Date: Thu, 7 Jan 2010 23:03:48 +0100 Subject: [PATCH 4/6] Joined --{copy,write}-devices into --rw-devices --- generator.c | 7 +++---- options.c | 24 ++++++++---------------- receiver.c | 4 ++-- rsync.c | 4 ++-- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/generator.c b/generator.c index fff8500..e1a4685 100644 --- a/generator.c +++ b/generator.c @@ -39,8 +39,7 @@ extern int preserve_acls; extern int preserve_xattrs; extern int preserve_links; extern int preserve_devices; -extern int copy_devices; -extern int write_devices; +extern int rw_devices; extern int preserve_specials; extern int preserve_hard_links; extern int preserve_executability; @@ -1613,7 +1612,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, goto cleanup; } - if (!(S_ISREG(file->mode) || (copy_devices && IS_DEVICE(file->mode)))) { + if (!(S_ISREG(file->mode) || (rw_devices && IS_DEVICE(file->mode)))) { if (solo_file) fname = f_name(file, NULL); rprintf(FINFO, "skipping non-regular file \"%s\"\n", fname); @@ -1650,7 +1649,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, fnamecmp_type = FNAMECMP_FNAME; - if (statret == 0 && !(S_ISREG(sx.st.st_mode) || (write_devices && IS_DEVICE(sx.st.st_mode)))) { + if (statret == 0 && !(S_ISREG(sx.st.st_mode) || (rw_devices && IS_DEVICE(sx.st.st_mode)))) { if (delete_item(fname, sx.st.st_mode, del_opts | DEL_FOR_FILE) != 0) goto cleanup; statret = -1; diff --git a/options.c b/options.c index 36fef32..8da9c20 100644 --- a/options.c +++ b/options.c @@ -48,8 +48,7 @@ int append_mode = 0; int keep_dirlinks = 0; int copy_dirlinks = 0; int copy_links = 0; -int copy_devices = 0; -int write_devices = 0; +int rw_devices = 0; int preserve_links = 0; int preserve_hard_links = 0; int preserve_acls = 0; @@ -704,8 +703,7 @@ void usage(enum logcode F) rprintf(F," -o, --owner preserve owner (super-user only)\n"); rprintf(F," -g, --group preserve group\n"); rprintf(F," --devices preserve device files (super-user only)\n"); - rprintf(F," --copy-devices copy device contents as regular file\n"); - rprintf(F," -w --write-devices write to devices as regular files (implies --inplace)\n"); + rprintf(F," --rw-devices read/write device contents as regular file (implies --inplace)\n"); rprintf(F," --specials preserve special files\n"); rprintf(F," -D same as --devices --specials\n"); rprintf(F," -t, --times preserve modification times\n"); @@ -883,8 +881,7 @@ static struct poptOption long_options[] = { {"no-D", 0, POPT_ARG_NONE, 0, OPT_NO_D, 0, 0 }, {"devices", 0, POPT_ARG_VAL, &preserve_devices, 1, 0, 0 }, {"no-devices", 0, POPT_ARG_VAL, &preserve_devices, 0, 0, 0 }, - {"copy-devices", 0, POPT_ARG_NONE, ©_devices, 0, 0, 0 }, - {"write-devices", 'w', POPT_ARG_NONE, 0, 'w', 0, 0 }, + {"rw-devices", 0, POPT_ARG_NONE, &rw_devices, 0, 0, 0 }, {"specials", 0, POPT_ARG_VAL, &preserve_specials, 1, 0, 0 }, {"no-specials", 0, POPT_ARG_VAL, &preserve_specials, 0, 0, 0 }, {"links", 'l', POPT_ARG_VAL, &preserve_links, 1, 0, 0 }, @@ -1791,11 +1788,6 @@ int parse_arguments(int *argc_p, const char ***argv_p) return 0; #endif - case 'w': - write_devices = 1; - inplace = 1; - break; - default: /* A large opt value means that set_refuse_options() * turned this option off. */ @@ -1833,6 +1825,9 @@ int parse_arguments(int *argc_p, const char ***argv_p) set_output_verbosity(verbose, DEFAULT_PRIORITY); + if (rw_devices) + inplace = 1; + if (do_stats) { parse_output_words(info_words, info_levels, verbose > 1 ? "stats3" : "stats2", DEFAULT_PRIORITY); @@ -2711,11 +2706,8 @@ void server_options(char **args, int *argc_p) if (preallocate_files && am_sender) args[ac++] = "--preallocate"; - if (copy_devices) - args[ac++] = "--copy-devices"; - - if (write_devices) - args[ac++] = "--write-devices"; + if (rw_devices) + args[ac++] = "--rw-devices"; if (ac > MAX_SERVER_ARGS) { /* Not possible... */ rprintf(FERROR, "argc overflow in server_options().\n"); diff --git a/receiver.c b/receiver.c index bd3f8c2..cf43682 100644 --- a/receiver.c +++ b/receiver.c @@ -38,7 +38,7 @@ extern int protocol_version; extern int relative_paths; extern int preserve_hard_links; extern int preserve_perms; -extern int write_devices; +extern int rw_devices; extern int preserve_xattrs; extern int basis_dir_cnt; extern int make_backups; @@ -797,7 +797,7 @@ int recv_files(int f_in, int f_out, char *local_name) continue; } - if (fd1 != -1 && !(S_ISREG(st.st_mode) || (write_devices && IS_DEVICE(st.st_mode)))) { + if (fd1 != -1 && !(S_ISREG(st.st_mode) || (rw_devices && IS_DEVICE(st.st_mode)))) { close(fd1); fd1 = -1; } diff --git a/rsync.c b/rsync.c index 2e4988f..7e2184b 100644 --- a/rsync.c +++ b/rsync.c @@ -33,7 +33,7 @@ extern int preserve_xattrs; extern int preserve_perms; extern int preserve_executability; extern int preserve_times; -extern int copy_devices; +extern int rw_devices; extern int am_root; extern int am_server; extern int am_sender; @@ -397,7 +397,7 @@ int read_ndx_and_attrs(int f_in, int f_out, int *iflag_ptr, uchar *type_ptr, if (iflags & ITEM_TRANSFER) { int i = ndx - cur_flist->ndx_start; struct file_struct *file = cur_flist->files[i]; - if (i < 0 || !(S_ISREG(file->mode) || (copy_devices && IS_DEVICE(file->mode)))) { + if (i < 0 || !(S_ISREG(file->mode) || (rw_devices && IS_DEVICE(file->mode)))) { rprintf(FERROR, "received request to transfer non-regular file: %d [%s]\n", ndx, who_am_i()); -- 1.7.7.3