This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Gas vs irregular files


Hi Guys,

> As far as I can tell, the original reporter didn't like the fact
> that the error message said ``No such file or directory.''  I'm
> pointing out a better way to fix that particular problem.

Right - there are a couple of issues here.

The first is that one of the other purposes of this patch was to make
the assembler behave in a consistent way when compared with the other
binary utilities.  Hence if we apply a patch to gas/input-file.c we
should also update get_file_size() in binutils/bucomm.c and probably a
couple of other functions as well.

Secondly I still think that GAS should complain if it is asked to
assemble a directory as opposed to a file.  I do not think that the
idea that it should open the directory and search it for files to
assemble is a good one.  I would like to propose this alternative
patch:

Index: gas/input-file.c
===================================================================
RCS file: /cvs/src/src/gas/input-file.c,v
retrieving revision 1.13
diff -c -3 -p -r1.13 input-file.c
*** gas/input-file.c	24 Nov 2003 03:37:58 -0000	1.13
--- gas/input-file.c	17 Dec 2003 16:47:59 -0000
*************** input_file_open (char *filename, /* "" m
*** 142,150 ****
  	  as_bad (_("%s: No such file"), filename);
  	  return;
  	}
!       else if (! S_ISREG (statbuf.st_mode))
  	{
! 	  as_bad (_("'%s' is not an ordinary file"), filename);
  	  return;
  	}
  
--- 142,150 ----
  	  as_bad (_("%s: No such file"), filename);
  	  return;
  	}
!       else if (S_ISDIR (statbuf.st_mode))
  	{
! 	  as_bad (_("'%s' is a directory"), filename);
  	  return;
  	}
  
Which would allow special files (such as /dev/null) to work, as well
as symbolic links and so on.  I realise that this means that we still
have the call to stat() present, but I am not sure how else we can
determine if the input file is a directory.  fopen() will not fail on
it, nor will fread().

Cheers
        Nick
        


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]