From: Marcio Barbosa Date: Sat, 11 Aug 2018 17:17:28 +0000 (-0400) Subject: vol: remove empty directories left by vos zap -force X-Git-Tag: upstream/1.8.6_pre1^2~21 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=518a42eea03b372c92794602a15b89cd5ab78668;p=packages%2Fo%2Fopenafs.git vol: remove empty directories left by vos zap -force The vos zap -force command does not remove the directories associated with the volume in question (AFS_NAMEI_ENV). When the vos zap -force command is executed, the volume server goes through the /vicep*/AFSIDat directories and removes the files associated with the volume id received as an argument. Unfortunately, the volume server does not remove the directories associated with this volume. As a result, empty directories are left behind. To fix this problem, remove the empty directories left behind when vos zap -force is executed. Reviewed-on: https://gerrit.openafs.org/12879 Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Michael Meffie Reviewed-by: Cheyenne Wills Reviewed-by: Benjamin Kaduk (cherry picked from commit 892045a9803ed471986569705d9d727165ca7ecf) Change-Id: I18b727a561785443f488d60b967182e3ddb9064e Reviewed-on: https://gerrit.openafs.org/13897 Reviewed-by: Andrew Deason Reviewed-by: Michael Meffie Reviewed-by: Cheyenne Wills Reviewed-by: Mark Vitale Reviewed-by: Marcio Brito Barbosa Tested-by: BuildBot Reviewed-by: Stephan Wiesand --- diff --git a/src/vol/namei_ops.c b/src/vol/namei_ops.c index ced434a50..d63793f4d 100644 --- a/src/vol/namei_ops.c +++ b/src/vol/namei_ops.c @@ -3367,4 +3367,37 @@ FreeZLCList(void) } #endif +/** + * Remove empty directories associated with the volume received + * as an argument. + * + * @param[in] pname vice partition path + * @param[in] vid volume id + * + * @return 0 on success + */ +int +namei_RemoveDirectories(char *pname, afs_int32 vid) +{ + IHandle_t dirIH; + namei_t name; + + memset(&dirIH, 0, sizeof(dirIH)); + + dirIH.ih_vid = vid; + +#ifdef AFS_NT40_ENV + dirIH.ih_dev = nt_DriveToDev(pname); +#else + dirIH.ih_dev = volutil_GetPartitionID(pname); +#endif + if (dirIH.ih_dev == -1) { + return -1; + } + + namei_HandleToVolDir(&name, &dirIH); + + return namei_RemoveDataDirectories(&name); +} + #endif /* AFS_NAMEI_ENV */ diff --git a/src/vol/namei_ops.h b/src/vol/namei_ops.h index cacb42fd6..f3de43299 100644 --- a/src/vol/namei_ops.h +++ b/src/vol/namei_ops.h @@ -88,6 +88,8 @@ int namei_replace_file_by_hardlink(IHandle_t *hLink, IHandle_t *hTarget); extern void namei_SetWorkQueue(struct afs_work_queue *wq); # endif +int namei_RemoveDirectories(char *pname, afs_int32 vid); + #endif /* AFS_NAMEI_ENV */ #endif /* _AFS_NAMEI_OPS_H_H_ */ diff --git a/src/vol/nuke.c b/src/vol/nuke.c index 3d520ff63..6b35db826 100644 --- a/src/vol/nuke.c +++ b/src/vol/nuke.c @@ -205,6 +205,13 @@ nuke(char *aname, VolumeId avolid) allInodes = NULL; +#ifdef AFS_NAMEI_ENV + if (namei_RemoveDirectories(aname, avolid)) { + Log("Nuke: Could not remove some empty directories associated with " + "volume %u\n", avolid); + } +#endif + /* at this point, we should try to remove the volume header file itself. * the volume header file is the file named VNNNNN.vol in the UFS file * system, and is a normal file. As such, it is not stamped with the