1 $DragonFly: src/usr.bin/bzip2/Attic/bzip2.c.patch,v 1.1 2005/06/29 23:03:22 corecode Exp $
3 ===================================================================
4 RCS file: /cvs/src/contrib/bzip2-1.0/bzip2.c,v
5 retrieving revision 1.1
7 --- bzip2.c 29 Jun 2005 22:38:10 -0000 1.1
8 +++ bzip2.c 29 Jun 2005 22:50:59 -0000
11 static void copyFileName ( Char*, Char* );
12 static void* myMalloc ( Int32 );
13 +static int applySavedFileAttrToOutputFile ( int fd );
18 ret = fflush ( zStream );
19 if (ret == EOF) goto errhandler_io;
20 if (zStream != stdout) {
21 + int fd = fileno ( zStream );
22 + if (fd < 0) goto errhandler_io;
23 + ret = applySavedFileAttrToOutputFile ( fd );
24 + if (ret != 0) goto errhandler_io;
25 ret = fclose ( zStream );
26 outputHandleJustInCase = NULL;
27 if (ret == EOF) goto errhandler_io;
31 if (ferror(zStream)) goto errhandler_io;
32 + if ( stream != stdout) {
33 + int fd = fileno ( stream );
34 + if (fd < 0) goto errhandler_io;
35 + ret = applySavedFileAttrToOutputFile ( fd );
36 + if (ret != 0) goto errhandler_io;
38 ret = fclose ( zStream );
39 if (ret == EOF) goto errhandler_io;
45 -void applySavedMetaInfoToOutputFile ( Char *dstName )
46 +void applySavedTimeInfoToOutputFile ( Char *dstName )
50 @@ -1138,16 +1149,26 @@
51 uTimBuf.actime = fileMetaInfo.st_atime;
52 uTimBuf.modtime = fileMetaInfo.st_mtime;
54 - retVal = chmod ( dstName, fileMetaInfo.st_mode );
55 - ERROR_IF_NOT_ZERO ( retVal );
57 retVal = utime ( dstName, &uTimBuf );
58 ERROR_IF_NOT_ZERO ( retVal );
63 +int applySavedFileAttrToOutputFile ( int fd )
68 + retVal = fchmod ( fd, fileMetaInfo.st_mode );
72 - retVal = chown ( dstName, fileMetaInfo.st_uid, fileMetaInfo.st_gid );
73 + (void) fchown ( fd, fileMetaInfo.st_uid, fileMetaInfo.st_gid );
74 /* chown() will in many cases return with EPERM, which can
83 /*--- If there was an I/O error, we won't get here. ---*/
84 if ( srcMode == SM_F2F ) {
85 - applySavedMetaInfoToOutputFile ( outName );
86 + applySavedTimeInfoToOutputFile ( outName );
87 deleteOutputOnInterrupt = False;
88 if ( !keepInputFiles ) {
89 IntNative retVal = remove ( inName );
91 /*--- If there was an I/O error, we won't get here. ---*/
92 if ( magicNumberOK ) {
93 if ( srcMode == SM_F2F ) {
94 - applySavedMetaInfoToOutputFile ( outName );
95 + applySavedTimeInfoToOutputFile ( outName );
96 deleteOutputOnInterrupt = False;
97 if ( !keepInputFiles ) {
98 IntNative retVal = remove ( inName );