Bug 25474

Summary: dump can't close fifo pipe correctly
Product: Base System Reporter: Alex Bakhtin <bakhtin>
Component: binAssignee: iedowse
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.2-STABLE   
Hardware: Any   
OS: Any   

Description Alex Bakhtin 2001-03-01 14:20:01 UTC
I'm trying to dump my filesystems to fifo pipe (created by mkfifo) and
have got a problem. If we use dump -f FILE and FILE is fifo, it dumps
fs fine, but after that it fails to close this file. Looking into dump sources
(tape.c file) I have found a problem: after closing the file it tries to
reopen it several times:
        while ((f = open(tape, 0)) < 0)
                sleep (10);
        (void) close(f);

	And because nobody is listening at the other end of this pipe,
we'll wait for a long time...

Fix: 

{bakhtin}/home/bakhtin/work/dump>diff tape.c /usr/src/sbin/dump/tape.c
46d45
< #include !<sys/stat.h!>
326d324
<       struct stat sp;
369d366
<       fstat(tapefd,&sp);
371d367
<       if(S_ISFIFO(sp.st_mode)) return;
How-To-Repeat: 
	mkfifo PIPE
	dd if=PIPE of=/dev/null&
	dump -0 -f PIPE /
Comment 1 dwmalone 2001-03-01 15:21:42 UTC
On Thu, Mar 01, 2001 at 05:13:14PM +0300, bakhtin@amt.ru wrote:
> >Description:
> 
> I'm trying to dump my filesystems to fifo pipe (created by mkfifo) and
> have got a problem. If we use dump -f FILE and FILE is fifo, it dumps
> fs fine, but after that it fails to close this file. Looking into dump sources
> (tape.c file) I have found a problem: after closing the file it tries to
> reopen it several times:
>         while ((f = open(tape, 0)) < 0)
>                 sleep (10);
>         (void) close(f);
> 
> 	And because nobody is listening at the other end of this pipe,
> we'll wait for a long time...

Using dump -f doesn't seem to work that well for anything but tapes
unless you specify stdout. I'd recommend that you try:

	dump -f - /usr > /my/fifo

The man page should probably indicate that this is the case.

	David.
Comment 2 Alex Bakhtin 2001-03-02 07:01:03 UTC
>>>>> "DM" == David Malone writes:
David,

>> I'm trying to dump my filesystems to fifo pipe (created by mkfifo) and
>> have got a problem. If we use dump -f FILE and FILE is fifo, it dumps
>> fs fine, but after that it fails to close this file. Looking into dump sources
>> (tape.c file) I have found a problem: after closing the file it tries to
>> reopen it several times:
>> while ((f = open(tape, 0)) < 0)
>> sleep (10);
>> (void) close(f);
>> 
>> And because nobody is listening at the other end of this pipe,
>> we'll wait for a long time...

DM> Using dump -f doesn't seem to work that well for anything but tapes
DM> unless you specify stdout. I'd recommend that you try:

DM> 	dump -f - /usr > /my/fifo

DM> The man page should probably indicate that this is the case.

	In this case it's impossible to split DUMP archive into
volumes. The problem with closing file is the only one with FIFO
pipes. 

==================
{bakhtin}/home/bakhtin>dump -B 1000 -f - / > /dev/null
  DUMP: Date of this level 0 dump: Fri Mar  2 09:52:52 2001
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/da0s1a (/) to standard output
  DUMP: mapping (Pass I) [regular files]
  DUMP: mapping (Pass II) [directories]
  DUMP: estimated 34303 tape blocks.
  DUMP: dumping (Pass III) [directories]
  DUMP: dumping (Pass IV) [regular files]
  DUMP: DUMP: 34317 tape blocks
  DUMP: finished in 31 seconds, throughput 1107 KBytes/sec
  DUMP: DUMP IS DONE
==================

	/ is only an example. I'll try to describe what I'm trying to
do. I'm trying to backup my filesystems to CDRW disks in my CDRW drive. I
have discovered that it is possible to do without making ISO9660 FS on CDRW
disk, I can just redirect all output from dump to cdrecord. But ALL my FSs
(except / ) are bigger than CDRW disk (650M), so I need to make
multi-volume backup. When DUMP is writing to STDOUT, it can't split file
into volumes. So, it seems that FIFO pipe is a good way to do such
backups.

-- 
Best regards, -- Alex Bakhtin.
AMT Group, Cisco Systems Gold Partner, http://www.amt.ru
Comment 3 Alex Bakhtin 2001-03-07 09:45:12 UTC
David,

	Have you received my explanation?

-- 
Best regards, -- Alex Bakhtin.
AMT Group, Cisco Systems Gold Partner, http://www.amt.ru
Comment 4 iedowse freebsd_committer freebsd_triage 2001-11-21 18:41:10 UTC
State Changed
From-To: open->feedback


Could you supply a patch using the "-u" option to diff? Without 
some context it's difficult to see what is being changed. Making 
dump work with FIFOs seems like a useful addition.
Comment 5 iedowse freebsd_committer freebsd_triage 2002-02-11 00:56:08 UTC
State Changed
From-To: feedback->suspended


Committed (with minor style adjustments), thanks! 


Comment 6 iedowse freebsd_committer freebsd_triage 2002-02-11 00:56:08 UTC
Responsible Changed
From-To: freebsd-bugs->iedowse

My MFC reminder.
Comment 7 iedowse freebsd_committer freebsd_triage 2002-02-20 00:05:48 UTC
State Changed
From-To: suspended->closed


Merged into -STABLE now too.