/*
* Copyright 2006, Sine Nomine Associates 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 <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#endif /* ITIMER_REAL */
#endif
+
+#include <roken.h>
+
#include <rx/xdr.h>
#include <afs/afsint.h>
-#include <afs/assert.h>
-
+#include <afs/afs_assert.h>
+#include <afs/dir.h>
#include <fcntl.h>
#include <afs/afsutil.h>
#include <afs/fileutil.h>
-#include "nfs.h"
-#include "lwp.h"
-#include "lock.h"
-#include "ihandle.h"
-#include "vnode.h"
-#include "volume.h"
-#include "partition.h"
-#include "daemon_com.h"
-#include "salvsync.h"
+#include <afs/nfs.h>
+#include <lwp.h>
+#include <lock.h>
+#include <afs/ihandle.h>
+#include <afs/vnode.h>
+#include <afs/volume.h>
+#include <afs/partition.h>
+#include <afs/daemon_com.h>
+#include <afs/salvsync.h>
#ifdef AFS_NT40_ENV
#include <pthread.h>
#endif
static char * response_code_to_string(afs_int32);
static char * command_code_to_string(afs_int32);
static char * reason_code_to_string(afs_int32);
-static char * program_type_to_string(afs_int32);
static char * state_code_to_string(afs_int32);
-static int OpStats(struct cmd_syndesc * as, char * rock);
-static int OpSalvage(struct cmd_syndesc * as, char * rock);
-static int OpCancel(struct cmd_syndesc * as, char * rock);
-static int OpCancelAll(struct cmd_syndesc * as, char * rock);
-static int OpRaisePrio(struct cmd_syndesc * as, char * rock);
-static int OpQuery(struct cmd_syndesc * as, char * rock);
+static int OpStats(struct cmd_syndesc * as, void * rock);
+static int OpSalvage(struct cmd_syndesc * as, void * rock);
+static int OpCancel(struct cmd_syndesc * as, void * rock);
+static int OpCancelAll(struct cmd_syndesc * as, void * rock);
+static int OpRaisePrio(struct cmd_syndesc * as, void * rock);
+static int OpQuery(struct cmd_syndesc * as, void * rock);
#ifndef AFS_NT40_ENV
{
struct cmd_syndesc *ts;
int err = 0;
- int i;
- extern char cml_version_number[];
/* Initialize directory paths */
if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
}
- ts = cmd_CreateSyntax("stats", OpStats, 0, "get salvageserver statistics (SALVSYNC_NOP opcode)");
+ ts = cmd_CreateSyntax("stats", OpStats, NULL, "get salvageserver statistics (SALVSYNC_NOP opcode)");
COMMON_PARMS_DECL(ts);
cmd_CreateAlias(ts, "nop");
- ts = cmd_CreateSyntax("salvage", OpSalvage, 0, "schedule a salvage (SALVSYNC_SALVAGE opcode)");
+ ts = cmd_CreateSyntax("salvage", OpSalvage, NULL, "schedule a salvage (SALVSYNC_SALVAGE opcode)");
SALV_PARMS_DECL(ts);
- ts = cmd_CreateSyntax("cancel", OpCancel, 0, "cancel a salvage (SALVSYNC_CANCEL opcode)");
+ ts = cmd_CreateSyntax("cancel", OpCancel, NULL, "cancel a salvage (SALVSYNC_CANCEL opcode)");
SALV_PARMS_DECL(ts);
- ts = cmd_CreateSyntax("raiseprio", OpRaisePrio, 0, "raise a salvage priority (SALVSYNC_RAISEPRIO opcode)");
+ ts = cmd_CreateSyntax("raiseprio", OpRaisePrio, NULL, "raise a salvage priority (SALVSYNC_RAISEPRIO opcode)");
SALV_PARMS_DECL(ts);
cmd_CreateAlias(ts, "rp");
- ts = cmd_CreateSyntax("query", OpQuery, 0, "query salvage status (SALVSYNC_QUERY opcode)");
+ ts = cmd_CreateSyntax("query", OpQuery, NULL, "query salvage status (SALVSYNC_QUERY opcode)");
SALV_PARMS_DECL(ts);
cmd_CreateAlias(ts, "qry");
- ts = cmd_CreateSyntax("kill", OpCancelAll, 0, "cancel all scheduled salvages (SALVSYNC_CANCELALL opcode)");
+ ts = cmd_CreateSyntax("kill", OpCancelAll, NULL, "cancel all scheduled salvages (SALVSYNC_CANCELALL opcode)");
COMMON_PARMS_DECL(ts);
err = cmd_Dispatch(argc, argv);
static int
common_prolog(struct cmd_syndesc * as, struct state * state)
{
- register struct cmd_item *ti;
+ struct cmd_item *ti;
+ VolumePackageOptions opts;
#ifdef AFS_NT40_ENV
if (afs_winsockInit() < 0) {
}
#endif
- VInitVolumePackage(debugUtility, 1, 1,
- DONT_CONNECT_FS, 0);
+ VOptDefaults(debugUtility, &opts);
+ if (VInitVolumePackage2(debugUtility, &opts)) {
+ /* VInitVolumePackage2 can fail on e.g. partition attachment errors,
+ * but we don't really care, since all we're doing is trying to use
+ * SALVSYNC */
+ fprintf(stderr, "errors encountered initializing volume package, but "
+ "trying to continue anyway\n");
+ }
DInit(1);
if ((ti = as->parms[COMMON_PARMS_OFFSET].items)) { /* -reason */
state->reason = atoi(ti->data);
+ } else {
+ state->reason = SALVSYNC_REASON_WHATEVER;
}
+
if ((ti = as->parms[COMMON_PARMS_OFFSET+1].items)) { /* -programtype */
if (!strcmp(ti->data, "fileServer")) {
programType = fileServer;
programType = salvager;
} else if (!strcmp(ti->data, "salvageServer")) {
programType = salvageServer;
+ } else if (!strcmp(ti->data, "volumeServer")) {
+ programType = volumeServer;
+ } else if (!strcmp(ti->data, "volumeSalvager")) {
+ programType = volumeSalvager;
} else {
programType = (ProgramType) atoi(ti->data);
}
static int
common_salv_prolog(struct cmd_syndesc * as, struct state * state)
{
- register struct cmd_item *ti;
- char pname[100], *temp;
+ struct cmd_item *ti;
state->sop = (struct salv_state *) calloc(1, sizeof(struct salv_state));
assert(state->sop != NULL);
hdr = (SALVSYNC_response_hdr *) res->payload.buf;
}
- fprintf(stderr, "calling SALVSYNC_SalvageVolume with command code %d (%s)\n",
+ fprintf(stderr, "calling SALVSYNC_SalvageVolume with command code %d (%s)\n",
command, command_code_to_string(command));
code = SALVSYNC_SalvageVolume(state->sop->volume,
}
fprintf(stderr, "SALVSYNC_SalvageVolume returned %d (%s)\n", code, response_code_to_string(code));
- fprintf(stderr, "protocol response code was %d (%s)\n",
+ fprintf(stderr, "protocol response code was %d (%s)\n",
res->hdr.response, response_code_to_string(res->hdr.response));
- fprintf(stderr, "protocol reason code was %d (%s)\n",
+ fprintf(stderr, "protocol reason code was %d (%s)\n",
res->hdr.reason, reason_code_to_string(res->hdr.reason));
printf("state = {\n");
printf("}\n");
VDisconnectSALV();
+
+ return 0;
}
static char *
}
}
+#if 0
static char *
program_type_to_string(afs_int32 type)
{
return "**UNKNOWN**";
}
}
+#endif
static char *
state_code_to_string(afs_int32 state)
}
static int
-OpStats(struct cmd_syndesc * as, char * rock)
+OpStats(struct cmd_syndesc * as, void * rock)
{
struct state state;
}
static int
-OpSalvage(struct cmd_syndesc * as, char * rock)
+OpSalvage(struct cmd_syndesc * as, void * rock)
{
struct state state;
}
static int
-OpCancel(struct cmd_syndesc * as, char * rock)
+OpCancel(struct cmd_syndesc * as, void * rock)
{
struct state state;
}
static int
-OpCancelAll(struct cmd_syndesc * as, char * rock)
+OpCancelAll(struct cmd_syndesc * as, void * rock)
{
struct state state;
}
static int
-OpRaisePrio(struct cmd_syndesc * as, char * rock)
+OpRaisePrio(struct cmd_syndesc * as, void * rock)
{
struct state state;
}
static int
-OpQuery(struct cmd_syndesc * as, char * rock)
+OpQuery(struct cmd_syndesc * as, void * rock)
{
struct state state;