/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
#include <afsconfig.h>
#include <afs/param.h>
-RCSID
- ("$Header$");
#include <rx/xdr.h>
#include <afs/afsint.h>
#include <stdio.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
-#include <afs/assert.h>
-#endif /* AFS_PTHREAD_ENV */
+#include <afs/afs_assert.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#else
#include <strings.h>
#endif
+#ifndef AFS_NT40_ENV
+#include <unistd.h>
+#endif
+
+#include <afs/afsutil.h>
-#include <afs/assert.h>
#include "nfs.h"
#include "lwp.h"
#include "lock.h"
#include "partition.h"
#include "viceinode.h"
#include "salvage.h"
+#include "daemon_com.h"
#include "fssync.h"
+#include "common.h"
#ifdef O_LARGEFILE
#define afs_stat stat64
#define afs_stat stat
#endif /* !O_LARGEFILE */
-/*@printflike@*/ extern void Log(const char *format, ...);
-
-
struct Lock localLock;
-char *vol_DevName();
#define MAXATONCE 100
/* structure containing neatly packed set of inodes and the # of times we'll have
* Note that ainfo->u.param[0] is always the volume ID, for any vice inode.
*/
static int
-NukeProc(struct ViceInodeInfo *ainfo, afs_int32 avolid, struct ilist *allInodes)
+NukeProc(struct ViceInodeInfo *ainfo, afs_uint32 avolid, void *arock)
{
+ struct ilist **allInodes = (struct ilist **)arock;
struct ilist *ti;
- register afs_int32 i;
+ afs_int32 i;
#ifndef AFS_PTHREAD_ENV
IOMGR_Poll(); /* poll so we don't kill the RPC connection */
if (ainfo->u.param[0] != avolid)
return 0; /* don't want this one */
/* record the info */
- if (!allInodes || allInodes->freePtr >= MAXATONCE) {
+ if (!*allInodes || (*allInodes)->freePtr >= MAXATONCE) {
ti = (struct ilist *)malloc(sizeof(struct ilist));
memset(ti, 0, sizeof(*ti));
- ti->next = allInodes;
- allInodes = ti;
+ ti->next = *allInodes;
+ *allInodes = ti;
} else
- ti = allInodes; /* use the one with space */
+ ti = *allInodes; /* use the one with space */
i = ti->freePtr++; /* find our slot in this mess */
ti->inode[i] = ainfo->inodeNumber;
ti->count[i] = ainfo->linkCount;
/* first process the partition containing this junk */
struct afs_stat tstat;
struct ilist *ti, *ni, *li=NULL;
- register afs_int32 code;
+ afs_int32 code;
int i, forceSal;
- char devName[64], wpath[100];
+ char wpath[100];
char *lastDevComp;
+ struct DiskPartition64 *dp;
#ifdef AFS_NAMEI_ENV
-#ifdef AFS_NT40_ENV
- char path[MAX_PATH];
-#else
char *path;
+
namei_t ufs_name;
-#endif
#endif /* AFS_NAMEI_ENV */
+#ifndef AFS_NAMEI_ENV
+ char devName[64];
+#endif /* !AFS_NAMEI_ENV */
IHandle_t *fileH;
struct ilist *allInodes = 0;
if (avolid == 0)
return EINVAL;
code = afs_stat(aname, &tstat);
- if (code) {
+ if (code || (dp = VGetPartition(aname, 0)) == NULL) {
printf("volnuke: partition %s does not exist.\n", aname);
+ if (!code) {
+ code = EINVAL;
+ }
return code;
}
/* get the device name for the partition */
* all we need to do to call ListViceInodes is find the inodes for the
* volume we're nuking.
*/
-#ifdef AFS_NAMEI_ENV
code =
ListViceInodes(lastDevComp, aname, NULL, NukeProc, avolid, &forceSal,
- 0, wpath, allInodes);
-#else
- code =
- ListViceInodes(lastDevComp, aname, "/tmp/vNukeXX", NukeProc, avolid,
- &forceSal, 0, wpath, allInodes);
- unlink("/tmp/vNukeXX"); /* clean it up now */
-#endif
+ 0, wpath, &allInodes);
if (code == 0) {
/* actually do the idecs now */
for (ti = allInodes; ti; ti = ti->next) {
#ifdef AFS_NT40_ENV
IH_INIT(fileH, (int)(*lastDevComp - 'A'), avolid,
ti->inode[i]);
- nt_HandleToName(path, fileH);
#else
IH_INIT(fileH, (int)volutil_GetPartitionID(aname), avolid,
ti->inode[i]);
+#endif /* AFS_NT40_ENV */
namei_HandleToName(&ufs_name, fileH);
path = ufs_name.n_path;
-#endif /* AFS_NT40_ENV */
IH_RELEASE(fileH);
- if (unlink(path) < 0) {
+ if (OS_UNLINK(path) < 0) {
Log("Nuke: Failed to remove %s\n", path);
}
#else /* AFS_NAMEI_ENV */
* system, and is a normal file. As such, it is not stamped with the
* volume's ID in its inode, and has to be removed explicitly.
*/
- /* reuse devName buffer now */
-#ifdef AFS_NT40_ENV
- afs_snprintf(devName, sizeof devName, "%c:\\%s", *lastDevComp,
- VolumeExternalName(avolid));
-#else
- afs_snprintf(devName, sizeof devName, "%s/%s", aname,
- VolumeExternalName(avolid));
-#endif /* AFS_NT40_ENV */
- code = unlink(devName);
- if (code)
- code = errno;
+ code = VDestroyVolumeDiskHeader(dp, avolid, 0);
} else {
/* just free things */
for (ti = allInodes; ti; ti = ni) {