#include <roken.h>
-#include <rx/xdr.h>
+#include <afs/opr.h>
#include <afs/afsint.h>
-#include <stdio.h>
-#include <afs/afs_assert.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#if defined(AFS_SUN5_ENV) || defined(AFS_NT40_ENV)
-#include <string.h>
-#else
-#include <strings.h>
-#endif
-#ifndef AFS_NT40_ENV
-#include <unistd.h>
-#endif
+#include <rx/rx_queue.h>
#include <afs/afsutil.h>
#include "fssync.h"
#include "common.h"
-#ifdef O_LARGEFILE
-#define afs_stat stat64
-#else /* !O_LARGEFILE */
-#define afs_stat stat
-#endif /* !O_LARGEFILE */
-
struct Lock localLock;
#define MAXATONCE 100
/* called with a structure specifying info about the inode, and our rock (which
* is the volume ID. Returns true if we should keep this inode, otherwise false.
- * Note that ainfo->u.param[0] is always the volume ID, for any vice inode.
*/
static int
-NukeProc(struct ViceInodeInfo *ainfo, afs_uint32 avolid, void *arock)
+NukeProc(struct ViceInodeInfo *ainfo, VolumeId avolid, void *arock)
{
struct ilist **allInodes = (struct ilist **)arock;
struct ilist *ti;
#endif /* !AFS_PTHREAD_ENV */
/* check if this is the volume we're looking for */
- if (ainfo->u.param[0] != avolid)
- return 0; /* don't want this one */
+ if (ainfo->u.vnode.vnodeNumber == INODESPECIAL) {
+ /* For special inodes, look at both the volume id and the parent id.
+ * If we were given an RW vol id to nuke, we should delete the special
+ * inodes for all volumes in the VG, since we're deleting all of the
+ * regular inodes, too. If we don't do this, on namei would be
+ * impossible to nuke the special inodes for a non-RW volume. */
+ if (ainfo->u.special.volumeId != avolid && ainfo->u.special.parentId != avolid) {
+ return 0;
+ }
+ } else {
+ if (ainfo->u.vnode.volumeId != avolid) {
+ return 0; /* don't want this one */
+ }
+ }
+
/* record the info */
if (!*allInodes || (*allInodes)->freePtr >= MAXATONCE) {
- ti = (struct ilist *)malloc(sizeof(struct ilist));
- memset(ti, 0, sizeof(*ti));
+ ti = calloc(1, sizeof(struct ilist));
ti->next = *allInodes;
*allInodes = ti;
} else
* indices will be gone.
*/
int
-nuke(char *aname, afs_int32 avolid)
+nuke(char *aname, VolumeId avolid)
{
/* first process the partition containing this junk */
- struct afs_stat tstat;
+ struct afs_stat_st tstat;
struct ilist *ti, *ni, *li=NULL;
afs_int32 code;
int i, forceSal;
strcpy(devName, tfile); /* save this from the static buffer */
}
/* aim lastDevComp at the 'foo' of '/dev/foo' */
- lastDevComp = strrchr(devName, '/');
+ lastDevComp = strrchr(devName, OS_DIRSEPC);
/* either points at slash, or there is no slash; adjust appropriately */
if (lastDevComp)
lastDevComp++;
* volume we're nuking.
*/
code =
- ListViceInodes(lastDevComp, aname, NULL, NukeProc, avolid, &forceSal,
+ ListViceInodes(lastDevComp, aname, INVALID_FD, NukeProc, avolid, &forceSal,
0, wpath, &allInodes);
if (code == 0) {
/* actually do the idecs now */
IH_RELEASE(fileH);
#endif /* AFS_NAMEI_ENV */
}
- ni = ti->next;
if (li) free(li);
li = ti;
}
if (li) free(li);
- code = 0; /* we really don't care about it except for debugging */
+
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