On 08/25/11 14:33, Manuel Giraud wrote:
> Hi,
> 
> This patch makes the following command working:
> 
> $ RSH=ssh dump -0au -f remote:dump.0 /
> 
> even if dump.0 doesn't already exists on remote. Note: i cannot test
> this patch on st(4) device.
> 
> Index: tape.c
> ===================================================================
> RCS file: /cvs/src/sbin/dump/tape.c,v
> retrieving revision 1.31
> diff -u -p -r1.31 tape.c
> --- tape.c      27 Oct 2009 23:59:32 -0000      1.31
> +++ tape.c      25 Aug 2011 12:31:36 -0000
> @@ -649,7 +649,7 @@ restore_check_point:
>                          msg("Dumping volume %d on %s\n", tapeno, tape);
>                  }
>   #ifdef RDUMP
> -               while ((tapefd = (host ? rmtopen(tape, 2) :
> +               while ((tapefd = (host ? rmtopen(tape, O_WRONLY|O_CREAT) :
>                          pipeout ? 1 : open(tape, O_WRONLY|O_CREAT, 0666)))<  
> 0)
>   #else
>                  while ((tapefd = (pipeout ? 1 :
> 

I like it. I see no reason for using different flags for local vs
remote files, and using magic numbers instead of the defined constants
is just plain wrong.

Updated diff w/ the same reasoning applied on restore(8).

Any OK's or objections?

/Alexander


Index: dump/tape.c
===================================================================
RCS file: /cvs/src/sbin/dump/tape.c,v
retrieving revision 1.31
diff -u -p -r1.31 tape.c
--- dump/tape.c 27 Oct 2009 23:59:32 -0000      1.31
+++ dump/tape.c 27 Sep 2011 20:05:05 -0000
@@ -649,7 +649,7 @@ restore_check_point:
                        msg("Dumping volume %d on %s\n", tapeno, tape);
                }
 #ifdef RDUMP
-               while ((tapefd = (host ? rmtopen(tape, 2) :
+               while ((tapefd = (host ? rmtopen(tape, O_WRONLY|O_CREAT) :
                        pipeout ? 1 : open(tape, O_WRONLY|O_CREAT, 0666))) < 0)
 #else
                while ((tapefd = (pipeout ? 1 :
Index: restore/tape.c
===================================================================
RCS file: /cvs/src/sbin/restore/tape.c,v
retrieving revision 1.39
diff -u -p -r1.39 tape.c
--- restore/tape.c      27 Jun 2011 23:40:57 -0000      1.39
+++ restore/tape.c      27 Sep 2011 20:05:05 -0000
@@ -195,7 +195,7 @@ setup(void)
        Vprintf(stdout, "Verify tape and initialize maps\n");
 #ifdef RRESTORE
        if (host)
-               mt = rmtopen(magtape, 0);
+               mt = rmtopen(magtape, O_RDONLY);
        else
 #endif
        if (pipein)
@@ -358,7 +358,7 @@ again:
 
 #ifdef RRESTORE
        if (host)
-               mt = rmtopen(magtape, 0);
+               mt = rmtopen(magtape, O_RDONLY);
        else
 #endif
                mt = open(magtape, O_RDONLY);

Reply via email to