dir: check afs_dir_MakeDir return code in DirSalvage 99/13799/10
authorMark Vitale <mvitale@sinenomine.net>
Mon, 4 Mar 2019 01:51:45 +0000 (20:51 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 6 Nov 2020 15:07:04 +0000 (10:07 -0500)
Since the original IBM import, DirSalvage() has ignored the return code
from afs_dir_MakeDir() (f.k.a. MakeDir).  This has been safe because, as
the comment states, afs_dir_MakeDir returns no (non-zero) error code.

In preparation for a future commit, add a check for the return from
afs_dir_MakeDir and remove the comment.

Change-Id: Ibb259a7aaeeb21ef70a7794143a0dadb2a75725d
Reviewed-on: https://gerrit.openafs.org/13799
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/dir/salvage.c

index a720f95..463323e 100644 (file)
@@ -433,7 +433,6 @@ int
 DirSalvage(void *fromFile, void *toFile, afs_int32 vn, afs_int32 vu,
           afs_int32 pvn, afs_int32 pvu)
 {
-    /* First do a MakeDir on the target. */
     afs_int32 dot[3], dotdot[3], lfid[3], code, usedPages;
     char tname[256];
     int i;
@@ -444,6 +443,7 @@ DirSalvage(void *fromFile, void *toFile, afs_int32 vn, afs_int32 vu,
     int entry;
     int physerr;
 
+    /* First do a MakeDir on the target. */
     memset(dot, 0, sizeof(dot));
     memset(dotdot, 0, sizeof(dotdot));
     dot[1] = vn;
@@ -451,7 +451,11 @@ DirSalvage(void *fromFile, void *toFile, afs_int32 vn, afs_int32 vu,
     dotdot[1] = pvn;
     dotdot[2] = pvu;
 
-    afs_dir_MakeDir(toFile, dot, dotdot);      /* Returns no error code. */
+    code = afs_dir_MakeDir(toFile, dot, dotdot);
+    if (code) {
+       printf("Failed to create target directory\n");
+       return code;
+    }
 
     /* Find out how many pages are valid. */
     code = DReadWithErrno(fromFile, 0, &headerbuf, &physerr);