/*****************************************************************************
- * RRDtool 1.3.2 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010
*****************************************************************************
* rrd_open.c Open an RRD File
*****************************************************************************
if (rdwr & RRD_CREAT) {
flags |= (O_CREAT | O_TRUNC);
}
+ if (rdwr & RRD_EXCL) {
+ flags |= O_EXCL;
+ }
}
if (rdwr & RRD_READAHEAD) {
#ifdef MAP_POPULATE
} 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
#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