From 476765a7a7809185464067fe19b4b88f6c16812e Mon Sep 17 00:00:00 2001 From: Richard Nyberg Date: Sun, 22 Jan 2006 21:57:04 +0000 Subject: [PATCH] Added option --prealloc and a directory argument to btpd. Synced the command line help with the available options. --- btpd/main.c | 26 +++++++++++++------------- btpd/opts.c | 1 + btpd/opts.h | 1 + 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/btpd/main.c b/btpd/main.c index fe5f9ba..ba6361b 100644 --- a/btpd/main.c +++ b/btpd/main.c @@ -81,14 +81,10 @@ setup_daemon(const char *dir) static void usage(void) { - printf("Usage: btpd [options]\n" + printf("Usage: btpd [options] [dir]\n" "\n" "Options:\n" "\n" - "--bw-hz n\n" - "\tRun the bandwidth limiter at n hz.\n" - "\tDefault is 8 hz.\n" - "\n" "--bw-in n\n" "\tLimit incoming BitTorrent traffic to n kB/s.\n" "\tDefault is 0 which means unlimited.\n" @@ -101,16 +97,14 @@ usage(void) "\tKeep the btpd process in the foregorund and log to std{out,err}.\n" "\tThis option is intended for debugging purposes.\n" "\n" - "--ipc key\n" - "\tThe same key must be used by the cli to talk to this\n" - "\tbtpd instance. You shouldn't need to use this option.\n" - "\n" - "--logfile file\n" - "\tLog to the given file. By default btpd logs to ./btpd.log.\n" - "\n" "-p n, --port n\n" "\tListen at port n. Default is 6881.\n" "\n" + "--prealloc n\n" + "\tPreallocate disk space in chunks n kB. Default is 1.\n" + "\tNote that n will be rounded up to the closest multiple of the\n" + "\ttorrent piece size. If n is zero no preallocation will be done.\n" + "\n" "--help\n" "\tShow this help.\n" "\n"); @@ -123,6 +117,7 @@ static struct option longopts[] = { { "port", required_argument, NULL, 'p' }, { "bw-in", required_argument, &longval, 1 }, { "bw-out", required_argument, &longval, 2 }, + { "prealloc", required_argument, &longval, 3 }, { "help", no_argument, &longval, 5 }, { NULL, 0, NULL, 0 } }; @@ -152,6 +147,9 @@ main(int argc, char **argv) case 2: net_bw_limit_out = atoi(optarg) * 1024; break; + case 3: + cm_alloc_size = atoi(optarg) * 1024; + break; default: usage(); } @@ -165,8 +163,10 @@ args_done: argc -= optind; argv += optind; - if (argc != 0) + if (argc > 1) usage(); + if (argc > 0) + dir = argv[0]; setup_daemon(dir); diff --git a/btpd/opts.c b/btpd/opts.c index 780228f..9c68678 100644 --- a/btpd/opts.c +++ b/btpd/opts.c @@ -11,3 +11,4 @@ unsigned net_max_peers; unsigned net_bw_limit_in; unsigned net_bw_limit_out; int net_port = 6881; +off_t cm_alloc_size = 1; diff --git a/btpd/opts.h b/btpd/opts.h index cdf698f..98e2dbd 100644 --- a/btpd/opts.h +++ b/btpd/opts.h @@ -8,5 +8,6 @@ extern unsigned net_max_peers; extern unsigned net_bw_limit_in; extern unsigned net_bw_limit_out; extern int net_port; +extern off_t cm_alloc_size; #endif