2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afs/param.h>
15 #include <sys/statfs.h>
21 #include <rx/rx_globals.h>
23 #include <afs/vlserver.h>
24 #include <afs/cellconfig.h>
27 #include <afs/afsint.h>
30 #include <afs/tcdata.h>
32 #define SERVERNAME "server1"
35 struct tc_tapeSet ttapeSet;
36 char tdumpSetName[TC_MAXNAMELEN];
37 tc_dumpArray tdumps; /*defined by rxgen */
38 tc_restoreArray trestores; /*defined by rxgen */
40 struct tc_dumpStat tstatus;
43 struct rx_connection *
44 UV_Bind(aserver, port)
48 struct rx_connection *tc;
49 struct rx_securityClass *uvclass;
51 uvclass = rxnull_NewClientSecurityObject();
52 tc = rx_NewConnection(aserver, htons(port), TCSERVICE_ID, uvclass, 0);
57 /* return host address in network byte order */
67 code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
69 addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
70 return htonl(addr); /* convert to network order (128 in byte 0) */
72 th = gethostbyname(aname);
75 memcpy(&addr, th->h_addr, sizeof(addr));
81 PerformDump(struct cmd_syndesc *as, void *arock)
83 struct rx_connection *aconn;
86 struct tc_dumpDesc *ptr;
88 afs_int32 parentDumpID, dumpLevel;
90 server = GetServer(SERVERNAME);
92 printf("cant get server id \n");
97 strcpy(tdumpSetName, "Test");
99 ttapeSet.maxTapes = 10;
100 fp = fopen("dumpScr", "r");
101 fscanf(fp, "%u %u %u\n", &tdumps.tc_dumpArray_len, &ttapeSet.a,
103 strcpy(ttapeSet.format, "tapeName%u");
104 strcpy(ttapeSet.tapeServer, "diskTapes");
105 tdumps.tc_dumpArray_val =
106 malloc(tdumps.tc_dumpArray_len * sizeof(struct tc_dumpDesc));
107 ptr = tdumps.tc_dumpArray_val;
108 for (i = 0; i < tdumps.tc_dumpArray_len; i++) {
109 fscanf(fp, "%s\n", ptr->name);
110 fscanf(fp, "%s\n", ptr->hostAddr);
111 fscanf(fp, "%u %u %u\n", &ptr->vid, &ptr->partition, &ptr->date);
115 aconn = UV_Bind(server, TCPORT);
117 TC_PerformDump(aconn, tdumpSetName, &ttapeSet, &tdumps, parentDumpID,
118 dumpLevel, &tdumpID);
119 free(tdumps.tc_dumpArray_val);
121 printf("call to TC_PerformDump failed %u\n", code);
124 printf("dumpid returned %u\n", tdumpID);
130 PerformRestore(struct cmd_syndesc *as, void *arock)
132 struct rx_connection *aconn;
136 struct tc_restoreDesc *ptr;
138 server = GetServer(SERVERNAME);
140 printf("cant get server id \n");
143 aconn = UV_Bind(server, TCPORT);
144 strcpy(tdumpSetName, "");
145 strcpy(tdumpSetName, "Test");
146 fp = fopen("restoreScr", "r");
147 fscanf(fp, "%u\n", &trestores.tc_restoreArray_len);
148 trestores.tc_restoreArray_val
149 = malloc(trestores.tc_restoreArray_len *
150 sizeof(struct tc_restoreDesc));
151 ptr = trestores.tc_restoreArray_val;
152 for (i = 0; i < trestores.tc_restoreArray_len; i++) {
153 fscanf(fp, "%s\n", ptr->oldName);
154 fscanf(fp, "%s\n", ptr->newName);
155 fscanf(fp, "%s\n", ptr->tapeName);
156 fscanf(fp, "%s\n", ptr->hostAddr);
157 fscanf(fp, "%u %u %u %u %d %u\n", &ptr->origVid, &ptr->vid,
158 &ptr->partition, &ptr->flags, &ptr->frag, &ptr->position);
162 code = TC_PerformRestore(aconn, tdumpSetName, &trestores, &tdumpID);
164 printf("call to TC_PerformRestore failed %u\n", code);
167 printf("dumpid returned %u\n", tdumpID);
172 CheckDump(struct cmd_syndesc *as, void *arock)
174 struct rx_connection *aconn;
176 server = GetServer(SERVERNAME);
178 printf("cant get server id \n");
181 tdumpID = atol(as->parms[0].items->data);
182 aconn = UV_Bind(server, TCPORT);
183 code = TC_CheckDump(aconn, tdumpID, &tstatus);
185 printf("call to TC_CheckDump failed %u\n", code);
192 AbortDump(struct cmd_syndesc *as, void *arock)
194 struct rx_connection *aconn;
196 server = GetServer(SERVERNAME);
198 printf("cant get server id \n");
201 tdumpID = atol(as->parms[0].items->data);
202 aconn = UV_Bind(server, TCPORT);
203 code = TC_AbortDump(aconn, tdumpID);
205 printf("call to TC_AbortDump failed %u\n", code);
212 WaitForDump(struct cmd_syndesc *as, void *arock)
214 struct rx_connection *aconn;
216 server = GetServer(SERVERNAME);
218 printf("cant get server id \n");
221 tdumpID = atol(as->parms[0].items->data);
222 aconn = UV_Bind(server, TCPORT);
223 code = TC_WaitForDump(aconn, tdumpID);
225 printf("call to TC_WaitForDump failed %u\n", code);
232 EndDump(struct cmd_syndesc *as, void *arock)
234 struct rx_connection *aconn;
236 server = GetServer(SERVERNAME);
238 printf("cant get server id \n");
241 tdumpID = atol(as->parms[0].items->data);
242 aconn = UV_Bind(server, TCPORT);
243 code = TC_EndDump(aconn, tdumpID);
245 printf("call to TC_EndDump failed %u\n", code);
252 MyBeforeProc(struct cmd_syndesc *as, void *arock)
258 printf("Could not initialize rx.\n");
262 rx_SetRxDeadTime(50);
266 #include "AFS_component_version_number.c"
274 struct cmd_syndesc *ts;
278 * The following signal action for AIX is necessary so that in case of a
279 * crash (i.e. core is generated) we can include the user's data section
280 * in the core dump. Unfortunately, by default, only a partial core is
281 * generated which, in many cases, isn't too useful.
283 struct sigaction nsa;
285 sigemptyset(&nsa.sa_mask);
286 nsa.sa_handler = SIG_DFL;
287 nsa.sa_flags = SA_FULLDUMP;
288 sigaction(SIGABRT, &nsa, NULL);
289 sigaction(SIGSEGV, &nsa, NULL);
291 cmd_SetBeforeProc(MyBeforeProc, NULL);
293 ts = cmd_CreateSyntax("dump", PerformDump, NULL, 0, "perform a dump");
295 ts = cmd_CreateSyntax("restore", PerformRestore, NULL, 0, "perform a restore");
297 ts = cmd_CreateSyntax("check", CheckDump, NULL, 0, "check a dump");
298 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "dump id");
300 ts = cmd_CreateSyntax("abort", AbortDump, NULL, 0, "abort a dump");
301 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "dump id");
303 ts = cmd_CreateSyntax("wait", WaitForDump, NULL, 0, "wait for a dump");
304 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "dump id");
306 ts = cmd_CreateSyntax("end", EndDump, NULL, 0, "end a dump");
307 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "dump id");
309 code = cmd_Dispatch(argc, argv);