On Wed 12. of December 2007 13:53:20 Radek Brich wrote: > On Wed 12. of December 2007 12:08:43 Jim Meyering wrote: > > Radek Brich <[EMAIL PROTECTED]> wrote: > > > On Tue 11. of December 2007 13:55:53 you wrote: > > >> Radek Brich <[EMAIL PROTECTED]> ha escrit: > > >> > Although it'd need some cleaning, I'd like to hear what > > >> > you think about the idea? > > >> > > >> Generally speaking, looks nice, except that fstat may fail (e.g. if > > >> stdout is closed) in which case st_stdout would contain garbage. > > > > ... > > > > > + struct stat st_buf; > > > + ino_t stdout_ino = fstat(STDOUT_FILENO, &st_buf) == -1 ? > > > + 0 : st_buf.st_ino; > > > + ino_t archive_ino = stat(archive_name_array[0], &st_buf) == -1 ? > > > + 0 : st_buf.st_ino; > > > + bool archive_is_stdout = (archive_ino != 0 && archive_ino == > > > stdout_ino); > > > > You'll want to compare st_dev, as well. > > Otherwise, there's a small risk of a false positive with > > a file on a different partition, but with the same inode number. > > > > You can use the SAME_INODE macro from gnulib's lib/same-inode.h, > > since tar already has that file. > > Yes, thanks, you are right. > > I also tried to make it look less alien in the rest of the code.
Oh, and the 'archive_is_stdout' variable can now be avoided as it'll never be
tested more than once...
--
Radek Brich
/__\ Base OS/core services
~~~~~~~~ Red Hat, Brno, Czech Rep.
signature.asc
Description: This is a digitally signed message part.
