From e5b7ee2506fbb2353de7c55c8a7541bf69d23d97 Mon Sep 17 00:00:00 2001 From: hadaq Date: Wed, 18 Aug 2004 10:24:38 +0000 Subject: [PATCH] evtbuild check if space is left on disk --- hadaq/evtbuild.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hadaq/evtbuild.c b/hadaq/evtbuild.c index 74cef43..5403777 100644 --- a/hadaq/evtbuild.c +++ b/hadaq/evtbuild.c @@ -1,4 +1,4 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.71 2004-08-18 09:58:28 hadaq Exp $"; +static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.72 2004-08-18 10:24:38 hadaq Exp $"; #define _POSIX_C_SOURCE 199309L @@ -15,6 +15,7 @@ static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hada #include #include #include +#include #include #include @@ -161,7 +162,7 @@ static void argsDefault(TheArgs *my) my->queueSize = 1 * 1024 * 1024; strcpy(my->verbosity, "info"); my->evtId = 0; - my->maxFileSz = (2 * 1024 * 1024 * 1024UL); + my->maxFileSz = (2 * 1024 * 1024 * 1024UL - 1); } static int argsFromCL(TheArgs *my, int argc, char *argv[]) @@ -419,6 +420,17 @@ static int openFile(TheArgs *theArgs) syslog(LOG_ERR, "opening file %s: %s", theArgs->outPath, strerror(errno)); outFile = NULL; return -1; + } else { + struct statfs bufS, *buf = &bufS; + statfs(theArgs->outPath, buf); + if (theArgs->maxFileSz / buf->f_bsize > buf->f_bavail) { + errno = ENOSPC; + fclose(outFile); + outFile = NULL; + unlink(theArgs->outPath); + syslog(LOG_ERR, "opening file %s: %s", theArgs->outPath, strerror(errno)); + return -1; + } } } else if (strcmp(theArgs->outDev, "tape") == 0) { if (strcmp(theArgs->outPath, "") == 0) { -- 2.43.0