SHA256
1
0
forked from pool/fillup

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
This commit is contained in:
Dirk Mueller 2011-06-02 09:40:42 +00:00 committed by Git OBS Bridge
parent f05fe125e4
commit dda254d2ee
5 changed files with 112 additions and 26 deletions

20
fillup-1.42-cloexec.patch Normal file
View File

@ -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,

View File

@ -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 <ctype.h>
-
+#include <unistd.h>
#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 <stdio.h>
-
+#include <unistd.h>
#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 );
}
}

View File

@ -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

View File

@ -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

View File

@ -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