|
Ticket #250: rrdtool-1.4.2-create-no-overwrite.patch
| File rrdtool-1.4.2-create-no-overwrite.patch,
2.8 KB
(added by human, 2 years ago) |
|
working version of 1.4.2 patch
|
-
diff -Naur rrdtool-1.4.2-orig/src/rrd_create.c rrdtool-1.4.2/src/rrd_create.c
|
old
|
new
|
|
| 13 | 13 | #include "rrd_hw.h" |
| 14 | 14 | |
| 15 | 15 | #include "rrd_is_thread_safe.h" |
| | 16 | static int opt_no_overwrite = 0; |
| 16 | 17 | |
| 17 | 18 | #ifdef WIN32 |
| 18 | 19 | # include <process.h> |
| … |
… |
|
| 39 | 40 | struct option long_options[] = { |
| 40 | 41 | {"start", required_argument, 0, 'b'}, |
| 41 | 42 | {"step", required_argument, 0, 's'}, |
| | 43 | {"no-overwrite", no_argument, 0, 'O'}, |
| 42 | 44 | {0, 0, 0, 0} |
| 43 | 45 | }; |
| 44 | 46 | int option_index = 0; |
| … |
… |
|
| 54 | 56 | opterr = 0; /* initialize getopt */ |
| 55 | 57 | |
| 56 | 58 | while (1) { |
| 57 | | opt = getopt_long(argc, argv, "b:s:", long_options, &option_index); |
| | 59 | opt = getopt_long(argc, argv, "Ob:s:", long_options, &option_index); |
| 58 | 60 | |
| 59 | 61 | if (opt == EOF) |
| 60 | 62 | break; |
| … |
… |
|
| 90 | 92 | pdp_step = long_tmp; |
| 91 | 93 | break; |
| 92 | 94 | |
| | 95 | case 'O': |
| | 96 | opt_no_overwrite = 1; |
| | 97 | break; |
| | 98 | |
| 93 | 99 | case '?': |
| 94 | 100 | if (optopt != 0) |
| 95 | 101 | rrd_set_error("unknown option '%c'", optopt); |
| … |
… |
|
| 679 | 685 | rrd_t rrd_dn; |
| 680 | 686 | unsigned rrd_flags = RRD_READWRITE | RRD_CREAT; |
| 681 | 687 | |
| | 688 | if (opt_no_overwrite) { |
| | 689 | rrd_flags |= RRD_EXCL ; |
| | 690 | } |
| | 691 | |
| 682 | 692 | unkn_cnt = 0; |
| 683 | 693 | for (i = 0; i < rrd->stat_head->rra_cnt; i++) |
| 684 | 694 | unkn_cnt += rrd->stat_head->ds_cnt * rrd->rra_def[i].row_cnt; |
-
diff -Naur rrdtool-1.4.2-orig/src/rrd_open.c rrdtool-1.4.2/src/rrd_open.c
|
old
|
new
|
|
| 172 | 172 | if (rdwr & RRD_CREAT) { |
| 173 | 173 | flags |= (O_CREAT | O_TRUNC); |
| 174 | 174 | } |
| | 175 | if (rdwr & RRD_EXCL) { |
| | 176 | flags |= O_EXCL; |
| | 177 | } |
| 175 | 178 | } |
| 176 | 179 | if (rdwr & RRD_READAHEAD) { |
| 177 | 180 | #ifdef MAP_POPULATE |
-
diff -Naur rrdtool-1.4.2-orig/src/rrd_tool.c rrdtool-1.4.2/src/rrd_tool.c
|
old
|
new
|
|
| 65 | 65 | N_("* create - create a new RRD\n\n" |
| 66 | 66 | "\trrdtool create filename [--start|-b start time]\n" |
| 67 | 67 | "\t\t[--step|-s step]\n" |
| | 68 | "\t\t[--no-overwrite|-O]\n" |
| 68 | 69 | "\t\t[DS:ds-name:DST:dst arguments]\n" |
| 69 | 70 | "\t\t[RRA:CF:cf arguments]\n\n"); |
| 70 | 71 | |
-
diff -Naur rrdtool-1.4.2-orig/src/rrd_tool.h rrdtool-1.4.2/src/rrd_tool.h
|
old
|
new
|
|
| 107 | 107 | #define RRD_CREAT (1<<2) |
| 108 | 108 | #define RRD_READAHEAD (1<<3) |
| 109 | 109 | #define RRD_COPY (1<<4) |
| | 110 | #define RRD_EXCL (1<<5) |
| 110 | 111 | |
| 111 | 112 | enum cf_en cf_conv( |
| 112 | 113 | const char *string); |
Download in other formats:
|