From dda254d2ee359b31a68e69405e0da7a7d21e95d4c5f6e5320314e69a04a2f042 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Thu, 2 Jun 2011 09:40:42 +0000 Subject: [PATCH] Accepting request 70915 from home:elvigia:branches:Base:System - Open all file descriptors with O_CLOEXEC - handle out-of-disk-space situations somewhat better. OBS-URL: https://build.opensuse.org/request/show/70915 OBS-URL: https://build.opensuse.org/package/show/Base:System/fillup?expand=0&rev=12 --- fillup-1.42-cloexec.patch | 20 +++++++++ fillup-1.42.dif | 88 ++++++++++++++++++++++++++++++--------- fillup-optflags.patch | 19 ++++++--- fillup.changes | 6 +++ fillup.spec | 5 ++- 5 files changed, 112 insertions(+), 26 deletions(-) create mode 100644 fillup-1.42-cloexec.patch diff --git a/fillup-1.42-cloexec.patch b/fillup-1.42-cloexec.patch new file mode 100644 index 0000000..2a9f591 --- /dev/null +++ b/fillup-1.42-cloexec.patch @@ -0,0 +1,20 @@ +--- SRC/services.c.orig ++++ SRC/services.c +@@ -342,7 +342,7 @@ openFileForReading + { + Service_t returnValue; + +- *filePointer = fopen( filename, "r" ); ++ *filePointer = fopen( filename, "re" ); + if( *filePointer == NULL ) + { + fillup_exception( __FILE__, __LINE__, ServiceException, +@@ -368,7 +368,7 @@ openFileForWriting + { + Service_t returnValue; + +- *filePointer = fopen( filename, "w" ); ++ *filePointer = fopen( filename, "we" ); + if( *filePointer == NULL ) + { + fillup_exception( __FILE__, __LINE__, ServiceException, diff --git a/fillup-1.42.dif b/fillup-1.42.dif index f2b055c..c68607f 100644 --- a/fillup-1.42.dif +++ b/fillup-1.42.dif @@ -1,6 +1,6 @@ ---- SRC/consume.c -+++ SRC/consume.c 2005-09-02 12:44:00.000000000 +0200 -@@ -140,7 +140,7 @@ +--- SRC/consume.c.orig ++++ SRC/consume.c +@@ -140,7 +140,7 @@ consumeUptoBreak { break; /* line break detected */ } @@ -9,9 +9,9 @@ { break; /* End-Of-File detected */ } ---- SRC/file.c -+++ SRC/file.c 2005-09-02 12:44:00.000000000 +0200 -@@ -35,18 +35,34 @@ +--- SRC/file.c.orig ++++ SRC/file.c +@@ -35,18 +35,34 @@ readFile File_t returnValue; FILE * filePointer; long fileLength; @@ -52,9 +52,9 @@ addToWatchdog( fileLength ); associateBuffer( fileSpecifier, fileLength, &buffer ); returnValue = FileOperationsSuccessful; ---- SRC/parameters.c -+++ SRC/parameters.c 2005-09-02 12:44:00.000000000 +0200 -@@ -368,6 +368,13 @@ +--- SRC/parameters.c.orig ++++ SRC/parameters.c +@@ -368,6 +368,13 @@ queryParameter } break; @@ -68,9 +68,18 @@ case IgnoreDefinites: if( parameterIgnoreDefinites == IsSet ) { ---- SRC/parser.c -+++ SRC/parser.c 2005-09-02 12:44:00.000000000 +0200 -@@ -296,6 +296,7 @@ +--- SRC/parser.c.orig ++++ SRC/parser.c +@@ -19,7 +19,7 @@ + /*--------------------------------- IMPORTS ----------------------------------*/ + + #include +- ++#include + #include "portab.h" + #include "variableblock.h" + #include "parameters.h" +@@ -296,6 +296,7 @@ createAdministrationInfo unsigned long Size; char * delimiterString; char delimiterChar; @@ -78,7 +87,7 @@ queryStringParameter( Delimiter, &delimiterString ); delimiterChar = delimiterString[ 0 ]; -@@ -305,23 +306,25 @@ +@@ -305,23 +306,25 @@ createAdministrationInfo countDelimiters( delimiterChar, baseFileBuffer, baseFileBufferLength ); baseFileBlocksLength++; /* add possible trailing comment */ Size = baseFileBlocksLength * sizeof( VariableBlock_t ); @@ -106,7 +115,7 @@ if( queryParameter( ForbiddenFile ) == TRUE ) { -@@ -329,12 +332,13 @@ +@@ -329,12 +332,13 @@ createAdministrationInfo delimiterChar, forbiddenFileBuffer, forbiddenFileBufferLength ); forbiddenFileBlocksLength++; /* add possible trailing comment */ Size = forbiddenFileBlocksLength * sizeof( VariableBlock_t ); @@ -121,7 +130,7 @@ } } -@@ -477,8 +481,8 @@ +@@ -477,8 +481,8 @@ getVariable getVBeginOfBlock( outputBuffer, &Line ); Line = Line + getVLength( outputBuffer ); LinePointer = Line; @@ -132,9 +141,29 @@ lineIndex++ ) { LinePointer++; /* concerns only the current line */ ---- SRC/services.c -+++ SRC/services.c 2005-09-02 12:44:00.000000000 +0200 -@@ -444,8 +444,9 @@ +@@ -1768,6 +1772,8 @@ writeOutput + } + listPointer++; + } ++ if(fflush( filePointer ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot flush stream"); ++ if(fdatasync ( fileno(filePointer) ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot sync stream"); + closeFile( filePointer ); + } + } +@@ -1830,7 +1836,9 @@ writeOutput + default: break; + } + listPointer++; +- } ++ } ++ if(fflush( filePointer ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot flush stream"); ++ if(fdatasync ( fileno(filePointer) ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot sync stream"); + closeFile( filePointer ); + } + } +--- SRC/services.c.orig ++++ SRC/services.c +@@ -444,8 +444,9 @@ readFileToBuffer if( 0 == fseek( filePointer, 0L, SEEK_SET ) ) { @@ -146,7 +175,7 @@ { returnValue = Success; } -@@ -558,23 +559,22 @@ +@@ -558,23 +559,22 @@ dumpBlock Service_t allocateBuffer ( @@ -174,3 +203,24 @@ returnValue = Success; } +--- SRC/metadata.c.orig ++++ SRC/metadata.c +@@ -17,7 +17,7 @@ + /*--------------------------------- IMPORTS ----------------------------------*/ + + #include +- ++#include + #include "variableblock.h" + #include "services.h" + #include "parser.h" +@@ -392,7 +392,8 @@ setMetadataInfo + logfile ); + fprintf( logfile, ">\n\n" ); + } +- ++ if(fflush( logfile ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot flush stream"); ++ if(fdatasync( fileno(logfile) ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot sync stream"); + closeFile( logfile ); + } + } diff --git a/fillup-optflags.patch b/fillup-optflags.patch index 73016a9..77260cd 100644 --- a/fillup-optflags.patch +++ b/fillup-optflags.patch @@ -1,6 +1,15 @@ ---- fillup-1.42/SRC/Makefile -+++ fillup-1.42/SRC/Makefile -@@ -46,24 +46,23 @@ +--- SRC/Makefile.orig ++++ SRC/Makefile +@@ -37,7 +37,7 @@ ARCHIVE = ${PROJDIR}/ARCHIVE + WARNINGS = -Wall -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes + # WARNINGS = -Wunused -Wswitch -Wformat -Wreturn-type -Wimplicit -Wmissing-prototypes -Wmissing-declarations + +-DEFINES = ++DEFINES = -D_GNU_SOURCE + + # LINUX system + OPTISPLUS = +@@ -46,24 +46,23 @@ INC = -I/usr/include COMPILER = -DGCC=1 # Set OPTIS to the following values @@ -11,7 +20,7 @@ ifeq ($(COMPILE_OPTION),DEBUG) # compile for debugging - COMPILE = gcc -fsigned-char -DDEBUG -ansi -g -c ${WARNINGS} -I${SRC} -I${INC} ${COMPILER} ${SYS} ${DEFINES} -+ COMPILE = gcc -DDEBUG -ansi -g -c $(OPTIS) ${WARNINGS} -I${SRC} -I${INC} ${COMPILER} ${SYS} ${DEFINES} ++ COMPILE = gcc -DDEBUG -std=gnu99 -g -c $(OPTIS) ${WARNINGS} -I${SRC} -I${INC} ${COMPILER} ${SYS} ${DEFINES} LINK = gcc -g endif @@ -19,7 +28,7 @@ # compile with all optimizations - COMPILE = gcc -fsigned-char -ansi -c $(OPTIS) $(WARNINGS) -I${SRC} -I${INC} ${COMPILER} ${SYS} ${DEFINES} - LINK = gcc -O -s -+ COMPILE = gcc -ansi -c $(OPTIS) $(WARNINGS) -I${SRC} -I${INC} ${COMPILER} ${SYS} ${DEFINES} ++ COMPILE = gcc -std=gnu99 -c $(OPTIS) $(WARNINGS) -I${SRC} -I${INC} ${COMPILER} ${SYS} ${DEFINES} + LINK = gcc endif diff --git a/fillup.changes b/fillup.changes index 54becc1..f6eb37c 100644 --- a/fillup.changes +++ b/fillup.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Sat May 21 20:34:06 UTC 2011 - crrodriguez@opensuse.org + +- Open all file descriptors with O_CLOEXEC +- handle out-of-disk-space situations somewhat better. + ------------------------------------------------------------------- Mon Jun 28 06:38:35 UTC 2010 - jengelh@medozas.de diff --git a/fillup.spec b/fillup.spec index 8ef304e..21f3a79 100644 --- a/fillup.spec +++ b/fillup.spec @@ -32,6 +32,7 @@ Patch1: fillup-warnings.dif Patch2: fillup-%{version}.dif Patch3: fillup-retval.dif Patch4: fillup-nodate.patch +Patch5: fillup-1.42-cloexec.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build %define fillup_info_entry * fillup: (fillup) fillup. SuSE-fillup-tool. @@ -49,12 +50,12 @@ Authors: %prep %setup -q -%patch -p1 +%patch %patch1 -p1 %patch2 -p0 %patch3 -p0 %patch4 -p0 - +%patch5 %build # # Be sure that the tests for fillup are run in