[BACK]Return to file.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / file

Diff for /src/usr.bin/file/file.c between version 1.42 and 1.43

version 1.42, 2015/05/29 11:59:01 version 1.43, 2015/05/29 12:33:41
Line 405 
Line 405 
         size_t  used;          size_t  used;
   
         inf->size = inf->msg->sb.st_size;          inf->size = inf->msg->sb.st_size;
         if (inf->size > FILE_READ_SIZE)          if (inf->size == 0 && S_ISREG(inf->msg->sb.st_mode))
                   return (0); /* empty file */
           if (inf->size == 0 || inf->size > FILE_READ_SIZE)
                 inf->size = FILE_READ_SIZE;                  inf->size = FILE_READ_SIZE;
         if (inf->size == 0) {  
                 if (!S_ISREG(inf->msg->sb.st_mode))  
                         inf->size = FILE_READ_SIZE;  
                 else  
                         return (0);  
         }  
   
           if (!S_ISREG(inf->msg->sb.st_mode))
                   goto try_read;
   
         inf->base = mmap(NULL, inf->size, PROT_READ, MAP_PRIVATE, inf->fd, 0);          inf->base = mmap(NULL, inf->size, PROT_READ, MAP_PRIVATE, inf->fd, 0);
         if (inf->base == MAP_FAILED) {          if (inf->base == MAP_FAILED)
                 inf->base = fill_buffer(inf->fd, inf->size, &used);                  goto try_read;
                 if (inf->base == NULL) {          inf->mapped = 1;
                         xasprintf(&inf->result, "cannot read '%s' (%s)",          return (0);
                             inf->path, strerror(errno));  
                         return (1);  try_read:
                 }          inf->base = fill_buffer(inf->fd, inf->size, &used);
                 inf->size = used;          if (inf->base == NULL) {
         } else                  xasprintf(&inf->result, "cannot read '%s' (%s)", inf->path,
                 inf->mapped = 1;                      strerror(errno));
                   return (1);
           }
           inf->size = used;
         return (0);          return (0);
 }  }
   

Legend:
Removed from v.1.42  
changed lines
  Added in v.1.43