Make dump's behaviour more sensible when the output file is a fifo.

Normally trewind() performs a close-open-close cycle to rewind the
tape when closing the device, but this is not ideal for fifos. We
now skip the final open-close if the output descriptor is a fifo.

PR:		bin/25474
Submitted by:	Alex Bakhtin <bakhtin@amt.ru>
MFC after:	1 week
This commit is contained in:
Ian Dowse 2002-02-11 00:50:50 +00:00
parent 364efeccb0
commit ff5e109e47
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=90496

View File

@ -43,6 +43,7 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
@ -314,6 +315,7 @@ flushtape()
void
trewind()
{
struct stat sb;
int f;
int got;
@ -358,6 +360,10 @@ trewind()
return;
}
#endif
if (fstat(tapefd, &sb) == 0 && S_ISFIFO(sb.st_mode)) {
(void)close(tapefd);
return;
}
(void) close(tapefd);
while ((f = open(tape, 0)) < 0)
sleep (10);