galeb

Једноставна статичка дистрибуција заснована на musl-у
git clone https://git.sr.ht/~strahinja/galeb
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

0002-Improve-file-access.patch (1425B)


      1 From db0737d1c6954370ac9e872e0d6d30c90479e804 Mon Sep 17 00:00:00 2001
      2 From: Arjan van de Ven <arjan@linux.intel.com>
      3 Date: Sat, 26 Mar 2016 19:28:57 -0700
      4 Subject: [PATCH 2/2] Improve file access
      5 
      6 1) Don't open a file to find out if it exists. Use access(2).
      7 2) use the "m" flag to glibc's fopen(3), to use mmap(2).
      8 ---
      9  bzip2.c | 9 +++------
     10  1 file changed, 3 insertions(+), 6 deletions(-)
     11 
     12 diff --git a/bzip2.c b/bzip2.c
     13 index d95d280..8156f1a 100644
     14 --- a/bzip2.c
     15 +++ b/bzip2.c
     16 @@ -939,10 +939,7 @@ void copyFileName ( Char* to, Char* from )
     17  static 
     18  Bool fileExists ( Char* name )
     19  {
     20 -   FILE *tmp   = fopen ( name, "rb" );
     21 -   Bool exists = (tmp != NULL);
     22 -   if (tmp != NULL) fclose ( tmp );
     23 -   return exists;
     24 +   return (access(name, R_OK) == 0) ;
     25  }
     26  
     27  
     28 @@ -1425,7 +1422,7 @@ void uncompress ( Char *name )
     29           break;
     30  
     31        case SM_F2O:
     32 -         inStr = fopen ( inName, "rb" );
     33 +         inStr = fopen ( inName, "rbm" );
     34           outStr = stdout;
     35           if ( inStr == NULL ) {
     36              fprintf ( stderr, "%s: Can't open input file %s:%s.\n",
     37 @@ -1437,7 +1434,7 @@ void uncompress ( Char *name )
     38           break;
     39  
     40        case SM_F2F:
     41 -         inStr = fopen ( inName, "rb" );
     42 +         inStr = fopen ( inName, "rbm" );
     43           outStr = fopen_output_safely ( outName, "wb" );
     44           if ( outStr == NULL) {
     45              fprintf ( stderr, "%s: Can't create output file %s: %s.\n",
     46 -- 
     47 2.23.0
     48