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

  • src/rrd_create.c

    diff -Naur rrdtool-1.4.2-orig/src/rrd_create.c rrdtool-1.4.2/src/rrd_create.c
    old new  
    1313#include "rrd_hw.h" 
    1414 
    1515#include "rrd_is_thread_safe.h" 
     16static int opt_no_overwrite = 0; 
    1617 
    1718#ifdef WIN32 
    1819# include <process.h> 
     
    3940    struct option long_options[] = { 
    4041        {"start", required_argument, 0, 'b'}, 
    4142        {"step", required_argument, 0, 's'}, 
     43        {"no-overwrite", no_argument, 0, 'O'}, 
    4244        {0, 0, 0, 0} 
    4345    }; 
    4446    int       option_index = 0; 
     
    5456    opterr = 0;         /* initialize getopt */ 
    5557 
    5658    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); 
    5860 
    5961        if (opt == EOF) 
    6062            break; 
     
    9092            pdp_step = long_tmp; 
    9193            break; 
    9294 
     95        case 'O': 
     96            opt_no_overwrite = 1; 
     97            break; 
     98 
    9399        case '?': 
    94100            if (optopt != 0) 
    95101                rrd_set_error("unknown option '%c'", optopt); 
     
    679685    rrd_t     rrd_dn; 
    680686    unsigned  rrd_flags = RRD_READWRITE | RRD_CREAT; 
    681687 
     688    if (opt_no_overwrite) { 
     689      rrd_flags |= RRD_EXCL ; 
     690    } 
     691 
    682692    unkn_cnt = 0; 
    683693    for (i = 0; i < rrd->stat_head->rra_cnt; i++) 
    684694        unkn_cnt += rrd->stat_head->ds_cnt * rrd->rra_def[i].row_cnt; 
  • src/rrd_open.c

    diff -Naur rrdtool-1.4.2-orig/src/rrd_open.c rrdtool-1.4.2/src/rrd_open.c
    old new  
    172172        if (rdwr & RRD_CREAT) { 
    173173            flags |= (O_CREAT | O_TRUNC); 
    174174        } 
     175        if (rdwr & RRD_EXCL) { 
     176            flags |= O_EXCL; 
     177        } 
    175178    } 
    176179    if (rdwr & RRD_READAHEAD) { 
    177180#ifdef MAP_POPULATE 
  • src/rrd_tool.c

    diff -Naur rrdtool-1.4.2-orig/src/rrd_tool.c rrdtool-1.4.2/src/rrd_tool.c
    old new  
    6565        N_("* create - create a new RRD\n\n" 
    6666           "\trrdtool create filename [--start|-b start time]\n" 
    6767           "\t\t[--step|-s step]\n" 
     68           "\t\t[--no-overwrite|-O]\n" 
    6869           "\t\t[DS:ds-name:DST:dst arguments]\n" 
    6970           "\t\t[RRA:CF:cf arguments]\n\n"); 
    7071 
  • src/rrd_tool.h

    diff -Naur rrdtool-1.4.2-orig/src/rrd_tool.h rrdtool-1.4.2/src/rrd_tool.h
    old new  
    107107#define RRD_CREAT       (1<<2) 
    108108#define RRD_READAHEAD   (1<<3) 
    109109#define RRD_COPY        (1<<4) 
     110#define RRD_EXCL        (1<<5) 
    110111 
    111112    enum cf_en cf_conv( 
    112113    const char *string); 

NOTE: The content of this website is accessible with any browser. The graphical design though relies completely on CSS2 styles. If you see this text, this means that your browser does not support CSS2. Consider upgrading to a standard conformant browser like Mozilla Firefox or Opera but also Apple's Safari or KDE's Konqueror for example. It may also be that you are looking at a mirror page which did not copy the CSS for this page. Or if some pictu res are missing, then the mirror may not have picked up the contents of the inc directory.