From 50f9ebb55b7edb22aceb4963fb6816469ac8250c Mon Sep 17 00:00:00 2001 From: TapTap Date: Thu, 3 Sep 2026 16:31:37 +0200 Subject: [PATCH] feat: add secluded args compatibility option --- README.md | 7 +++++++ RSYNC_COMPAT.md | 2 +- src/client/client_cli.c | 1 + src/client/usage.c | 1 + src/shared/config.c | 1 + src/shared/config.h | 1 + tests/test_client_cli.c | 27 +++++++++++++++++++++++++++ 7 files changed, 39 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fdbd9f3..ba38c1c 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ partial, alternate, and planned behavior. | `-a, --archive` | Archive mode: enables `-c -m -M` (no `-s`) | | `-m` | Multithreading mode | | `-s` | Chunk serialization (batch all files per chunk) | +| `--secluded-args` | Rsync-compatible long form. SSH already sends transfer arguments through FastSync's protocol; `-s` remains chunk serialization. | | `-f, --sendfile` | Sendfile zero-copy. Incompatible with `-c` / `-s`. TCP only. | | `-M, --preserve` | Preserve supported file metadata (mode and mtime; ownership and atime are unsupported) | | `-n, --dry-run` | Scan and print what would be transferred | @@ -359,6 +360,12 @@ particular, FastSync currently uses `-p` for SSH port, `-s` for chunk serialization, and `-S` for sparse handling. These meanings must be reconciled before FastSync can claim full rsync CLI compatibility. +`--secluded-args` is supported as a long-form compatibility option. FastSync's +SSH transport already launches only the remote server's `--stdio` command and +sends transfer configuration through its protocol. The rsync short form `-s` +is intentionally not aliased because it remains FastSync's chunk-serialization +option. + ## Client Options ### Selection and transfer diff --git a/RSYNC_COMPAT.md b/RSYNC_COMPAT.md index 4b236ec..dcf8462 100644 --- a/RSYNC_COMPAT.md +++ b/RSYNC_COMPAT.md @@ -233,7 +233,7 @@ This document maps rsync's full feature set to FastSync's current implementation | `--protocol=NUM` | Force older protocol version | ❌ Not Implemented | | | `--iconv=CONVERT_SPEC` | Charset conversion | ❌ Not Implemented | | | `--checksum-seed=NUM` | Set checksum seed | ❌ Not Implemented | | -| `-s`, `--secluded-args` | Use protocol to send args | ❌ Not Implemented | | +| `--secluded-args` | Use protocol to send args | ✅ Implemented | SSH already sends transfer configuration through FastSync's protocol; `-s` remains chunk serialization because of the existing FastSync short-option meaning. | | `--no-OPTION` | Turn off implied option | ❌ Not Implemented | | --- diff --git a/src/client/client_cli.c b/src/client/client_cli.c index 191cc07..7ce00b5 100644 --- a/src/client/client_cli.c +++ b/src/client/client_cli.c @@ -146,6 +146,7 @@ static const OptionEntry OPTION_TABLE[] = { {"--backup", NULL, OPT_FLAG, offsetof(Config, backup)}, {"--stats", NULL, OPT_FLAG, offsetof(Config, stats)}, {"--partial", NULL, OPT_FLAG, offsetof(Config, partial)}, + {"--secluded-args", NULL, OPT_FLAG, offsetof(Config, use_secluded_args)}, {"--links", "-l", OPT_FLAG, offsetof(Config, follow_symlinks)}, {"--copy-links", NULL, OPT_FLAG, offsetof(Config, copy_links)}, {"--safe-links", NULL, OPT_FLAG, offsetof(Config, safe_links)}, diff --git a/src/client/usage.c b/src/client/usage.c index 2f800af..cee07bc 100644 --- a/src/client/usage.c +++ b/src/client/usage.c @@ -35,6 +35,7 @@ void print_usage(void) { DELTA_MAX_FILE_SIZE); printf(" -m Enable multithreading\n"); printf(" -s Enable chunk serialization\n"); + printf(" --secluded-args Send transfer arguments through the protocol (SSH)\n"); printf(" -f Enable sendfile (TCP only, not with -c or -s)\n"); printf(" -v, --verbose Enable debug logging\n"); printf(" -M, --preserve Preserve file metadata\n"); diff --git a/src/shared/config.c b/src/shared/config.c index efc2708..f88c1bd 100644 --- a/src/shared/config.c +++ b/src/shared/config.c @@ -82,6 +82,7 @@ static void config_set_defaults(Config* config) { config->relative = false; config->rsh_command = NULL; config->rsync_path = NULL; + config->use_secluded_args = false; config->temp_dir = NULL; config->compare_dest = NULL; config->copy_dest = NULL; diff --git a/src/shared/config.h b/src/shared/config.h index 4a218b0..b76b606 100644 --- a/src/shared/config.h +++ b/src/shared/config.h @@ -96,6 +96,7 @@ typedef struct Config { // Issue #130: Remote shell/connection options char* rsh_command; char* rsync_path; + bool use_secluded_args; char* temp_dir; char* compare_dest; char* copy_dest; diff --git a/tests/test_client_cli.c b/tests/test_client_cli.c index 656fd40..d0c3948 100644 --- a/tests/test_client_cli.c +++ b/tests/test_client_cli.c @@ -339,6 +339,31 @@ static void test_parse_args_archive() { config_delete(cfg); } +/* --secluded-args is the rsync-compatible long form; -s keeps its FastSync meaning. */ +static void test_parse_args_secluded_args() { + Config* cfg = config_create(); + char* argv[] = {"fastsync", "--secluded-args", "/src", "/dst"}; + int positional_args[2]; + int positional_count = 0; + + EXPECT_EQ_INT(parse_args(cfg, 4, argv, positional_args, &positional_count), 0); + EXPECT_TRUE(cfg->use_secluded_args); + EXPECT_FALSE(cfg->use_chunk_serialization); + config_delete(cfg); +} + +static void test_parse_args_short_s_remains_chunk_serialization() { + Config* cfg = config_create(); + char* argv[] = {"fastsync", "-s", "/src", "/dst"}; + int positional_args[2]; + int positional_count = 0; + + EXPECT_EQ_INT(parse_args(cfg, 4, argv, positional_args, &positional_count), 0); + EXPECT_TRUE(cfg->use_chunk_serialization); + EXPECT_FALSE(cfg->use_secluded_args); + config_delete(cfg); +} + void test_client_cli() { test_validate_config_required_paths(); test_validate_config_incompatible_options(); @@ -360,4 +385,6 @@ void test_client_cli() { test_parse_args_unknown_option(); test_parse_args_rejects_unimplemented_options(); test_parse_args_archive(); + test_parse_args_secluded_args(); + test_parse_args_short_s_remains_chunk_serialization(); }