Coda File System

Re: Bug in 'backup'

From: Jan Harkes <jaharkes_at_cs.cmu.edu>
Date: Tue, 12 Oct 1999 17:21:41 -0400
On Tue, Oct 12, 1999 at 10:52:07PM +0200, Kurt Huwig wrote:
> in 'coda-src/volutil/backup.cc':
> 
>     if (dumpdir) {      /* User specified a dump directory! */
> 
> The last line should be replaced by
> 
>     if( dumpdir[ 0 ] ) {      /* User specified a dump directory! */
> 
> otherwise, it has no effect. I'm compiling it right now, but I upgraded
> to 5.3.2, so I have to rebuild everything...

Yup, currently it has the effect of always being true. So if the user
doesn't specify a dumpdir it will try to do chdir(""), which might
return an error, which results in the message "Set dump directory" and
backup exits.

I'm not sure what the preferred behaviour is in this case. Maybe the
code should read something like:

    if (dumpdir[0] = '\0') {
	perror("No dumpdirectory specified");
	exit(-1);
    }
    if (chdir(dumpdir) != 0) {
	fprintf(stderr, "Cannot chdir to %s:", dumpdir);
	perror("");
	exit(-1);
    }

    strftime(...) ; strcat(dumpdir, "/") ; strcat(dumpdir, today) ;
    if (mkdir(dumpdir) != 0) {
	fprintf(stderr, "Cannot create %s:", dumpdir);
	perror("");
	exit(-1);
    }
    chdir(dumpdir);

But I'll apply the fix you proposed, as the manpage lists dumpdir as an
optional argument...

Jan
Received on 1999-10-12 17:29:52