[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.33 and 1.34

version 1.33, 2015/04/26 19:53:50 version 1.34, 2015/04/26 22:51:32
Line 287 
Line 287 
 static int  static int
 load_file(struct input_file *inf)  load_file(struct input_file *inf)
 {  {
         int     available;  
   
         inf->size = inf->sb.st_size;          inf->size = inf->sb.st_size;
         if (inf->size > FILE_READ_SIZE)          if (inf->size > FILE_READ_SIZE)
                 inf->size = FILE_READ_SIZE;                  inf->size = FILE_READ_SIZE;
         if (S_ISFIFO(inf->sb.st_mode)) {          if (inf->size == 0) {
                 if (ioctl(inf->fd, FIONREAD, &available) == -1) {                  if (!S_ISREG(inf->sb.st_mode))
                         xasprintf(&inf->result,  "cannot read '%s' (%s)",                          inf->size = FILE_READ_SIZE;
                             inf->path, strerror(errno));                  else
                         return (1);                          return (0);
                 }          }
                 inf->size = available;  
         } else if (!S_ISREG(inf->sb.st_mode) && inf->size == 0)  
                 inf->size = FILE_READ_SIZE;  
         if (inf->size == 0)  
                 return (0);  
   
         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) {
Line 329 
Line 322 
                 switch (inf->sb.st_mode & S_IFMT) {                  switch (inf->sb.st_mode & S_IFMT) {
                 case S_IFBLK:                  case S_IFBLK:
                 case S_IFCHR:                  case S_IFCHR:
                 case S_IFIFO:  
                 case S_IFREG:                  case S_IFREG:
                         return (0);                          return (0);
                 }                  }

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.34