summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e9af6e7)
raw | patch | inline | side by side (parent: e9af6e7)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Mon, 8 Mar 2010 17:10:02 +0000 (17:10 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Mon, 8 Mar 2010 17:10:02 +0000 (17:10 +0000) |
program/doc/rrdcreate.pod | patch | blob | history | |
program/src/rrd_create.c | patch | blob | history | |
program/src/rrd_tool.c | patch | blob | history |
index abb42fc977a6fab48dc34ec240e723bb7b16e5d0..d4390b9010bfbdd8f9b76ea03ce4e82eb7f9f407 100644 (file)
B<rrdtool> B<create> I<filename>
S<[B<--start>|B<-b> I<start time>]>
S<[B<--step>|B<-s> I<step>]>
+S<[B<--no-overwrite>]>
S<[B<DS:>I<ds-name>B<:>I<DST>B<:>I<dst arguments>]>
S<[B<RRA:>I<CF>B<:>I<cf arguments>]>
Specifies the base interval in seconds with which data will be fed
into the B<RRD>.
+=head2 B<--no-overwrite>
+
+Do not clobber an existing file of the same name.
+
=head2 B<DS:>I<ds-name>B<:>I<DST>B<:>I<dst arguments>
A single B<RRD> can accept input from several data sources (B<DS>),
index 75c3722fe24b2680f9c6d4d03fedf4c106ea1628..4e98d53c40be069539ee45c19334f271362f631b 100644 (file)
--- a/program/src/rrd_create.c
+++ b/program/src/rrd_create.c
#include "rrd_hw.h"
#include "rrd_is_thread_safe.h"
+static int opt_no_overwrite = 0;
#ifdef WIN32
#include <fcntl.h>
struct option long_options[] = {
{"start", required_argument, 0, 'b'},
{"step", required_argument, 0, 's'},
+ {"no-overwrite", no_argument, 0, 'O'},
{0, 0, 0, 0}
};
int option_index = 0;
opterr = 0; /* initialize getopt */
while (1) {
- opt = getopt_long(argc, argv, "b:s:", long_options, &option_index);
+ opt = getopt_long(argc, argv, "Ob:s:", long_options, &option_index);
if (opt == EOF)
break;
pdp_step = long_tmp;
break;
+ case 'O':
+ opt_no_overwrite = 1;
+ break;
+
case '?':
if (optopt != 0)
rrd_set_error("unknown option '%c'", optopt);
flags |= O_BINARY;
#endif
+ /* with O_CREAT (above) causes open to fail with EEXIST when if exists */
+ if (opt_no_overwrite) {
+ flags |= O_EXCL;
+ }
+
if ((rrd_file = open(file_name, flags, 0666)) < 0) {
rrd_set_error("creating '%s': %s", file_name, rrd_strerror(errno));
rrd_free2(rrd);
diff --git a/program/src/rrd_tool.c b/program/src/rrd_tool.c
index 03b018ae124403a194ac2c0b96262ea7bf223495..2e59b8e008a66cac6e6b74061a8bb317ebaf61a2 100644 (file)
--- a/program/src/rrd_tool.c
+++ b/program/src/rrd_tool.c
N_("* create - create a new RRD\n\n"
"\trrdtool create filename [--start|-b start time]\n"
"\t\t[--step|-s step]\n"
+ "\t\t[--no-overwrite|-O]\n"
"\t\t[DS:ds-name:DST:dst arguments]\n"
"\t\t[RRA:CF:cf arguments]\n\n");