X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_open.c;h=0939e7c2d50164a1d5175a92b9d7edb44459c1c4;hp=59526d8b4c3ae3c49582afbd6da2ee440e500123;hb=8f9c2c2b3c3f8a65e24dd9d8d612eafe48ccfb2e;hpb=cd6581d4edf9cd9c73f023eb9b1f5529959bf816 diff --git a/src/rrd_open.c b/src/rrd_open.c index 59526d8..0939e7c 100644 --- a/src/rrd_open.c +++ b/src/rrd_open.c @@ -1,5 +1,5 @@ /***************************************************************************** - * RRDtool 1.3.2 Copyright by Tobi Oetiker, 1997-2008 + * RRDtool 1.4.2 Copyright by Tobi Oetiker, 1997-2009 ***************************************************************************** * rrd_open.c Open an RRD File ***************************************************************************** @@ -172,6 +172,9 @@ rrd_file_t *rrd_open( if (rdwr & RRD_CREAT) { flags |= (O_CREAT | O_TRUNC); } + if (rdwr & RRD_EXCL) { + flags |= O_EXCL; + } } if (rdwr & RRD_READAHEAD) { #ifdef MAP_POPULATE @@ -216,7 +219,10 @@ rrd_file_t *rrd_open( } else { rrd_file->file_len = newfile_size; lseek(rrd_simple_file->fd, newfile_size - 1, SEEK_SET); - write(rrd_simple_file->fd, "\0", 1); /* poke */ + if ( write(rrd_simple_file->fd, "\0", 1) == -1){ /* poke */ + rrd_set_error("write '%s': %s", file_name, rrd_strerror(errno)); + goto out_close; + } lseek(rrd_simple_file->fd, 0, SEEK_SET); } #ifdef HAVE_POSIX_FADVISE @@ -259,12 +265,14 @@ rrd_file_t *rrd_open( #ifdef USE_MADVISE if (rdwr & RRD_COPY) { /* We will read everything in a moment (copying) */ - madvise(data, rrd_file->file_len, MADV_WILLNEED | MADV_SEQUENTIAL); + madvise(data, rrd_file->file_len, MADV_WILLNEED ); + madvise(data, rrd_file->file_len, MADV_SEQUENTIAL ); } else { /* We do not need to read anything in for the moment */ madvise(data, rrd_file->file_len, MADV_RANDOM); /* the stat_head will be needed soonish, so hint accordingly */ - madvise(data, sizeof(stat_head_t), MADV_WILLNEED | MADV_RANDOM); + madvise(data, sizeof(stat_head_t), MADV_WILLNEED); + madvise(data, sizeof(stat_head_t), MADV_RANDOM); } #endif