This is the mail archive of the libc-alpha@cygnus.com mailing list for the glibc project.


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

Re: libc/1068: [glibc] Possible erroneous return code from Linux __getdirentries


>>>>> Jamie Lokier writes:

>> > 	But perhaps __getdirentries should be returning -1 in this case,
>> > 	like the getdents system call it uses?
>> That's IMO the way to go.
>> 
>> > 	I'm not entirely sure this is required.  __getdirentries is not
>> > 	very well documented (only in the <dirent.h> header, not the
>> > 	manual).  And other targets, for example BSD, simply call __read
>> > 	to implement __getdirentries.  For all I know, _those_ calls
>> > 	may return zero when there isn't room.
>> 
>> The appended patch has been added to glibc and should fix this.
>> * sysdeps/unix/sysv/linux/getdents.c (__getdirentries): Return
>> directly if getdents returns with error set.
 
>> retval = INLINE_SYSCALL (getdents, 3, fd, (char *) kdp, red_nbytes);
>> 
>> +  if (retval == -1)
>> +    return -1;
>> +  
 
Jamie>  I'm not convinced.  Shouldn't *basep still be set in this case?
Jamie>  It was before.

*basep is set by the caller and since we return an error, we don't
have to modify it.  I don't see a problem with this.

Andreas
-- 
 Andreas Jaeger   aj@arthur.rhein-neckar.de    jaeger@informatik.uni-kl.de
  for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de


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