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 <sys/types.h>
14 #include <sys/statfs.h>
17 #include <sys/errno.h>
19 #include <netinet/in.h>
22 #include <rx/rx_globals.h>
24 #include <afs/vlserver.h>
25 #include <afs/cellconfig.h>
28 #include <afs/afsint.h>
31 #include <afs/tcdata.h>
36 #define SERVERNAME "server1"
39 struct tc_tapeSet ttapeSet;
40 char tdumpSetName[TC_MAXNAMELEN];
41 tc_dumpArray tdumps; /*defined by rxgen */
42 tc_restoreArray trestores; /*defined by rxgen */
44 struct tc_dumpStat tstatus;
47 struct rx_connection *
48 UV_Bind(aserver, port)
49 afs_int32 aserver, port;
51 register struct rx_connection *tc;
52 struct rx_securityClass *uvclass;
54 uvclass = rxnull_NewClientSecurityObject();
55 tc = rx_NewConnection(aserver, htons(port), TCSERVICE_ID, uvclass, 0);
60 /* return host address in network byte order */
65 register struct hostent *th;
68 register afs_int32 code;
70 code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
72 addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
73 return htonl(addr); /* convert to network order (128 in byte 0) */
75 th = gethostbyname(aname);
78 memcpy(&addr, th->h_addr, sizeof(addr));
85 register struct cmd_syndesc *as;
87 struct rx_connection *aconn;
90 struct tc_dumpDesc *ptr;
92 afs_int32 parentDumpID, dumpLevel;
94 server = GetServer(SERVERNAME);
96 printf("cant get server id \n");
101 strcpy(tdumpSetName, "Test");
103 ttapeSet.maxTapes = 10;
104 fp = fopen("dumpScr", "r");
105 fscanf(fp, "%u %u %u\n", &tdumps.tc_dumpArray_len, &ttapeSet.a,
107 strcpy(ttapeSet.format, "tapeName%u");
108 strcpy(ttapeSet.tapeServer, "diskTapes");
109 tdumps.tc_dumpArray_val =
111 *)(malloc(tdumps.tc_dumpArray_len * sizeof(struct tc_dumpDesc)));
112 ptr = tdumps.tc_dumpArray_val;
113 for (i = 0; i < tdumps.tc_dumpArray_len; i++) {
114 fscanf(fp, "%s\n", ptr->name);
115 fscanf(fp, "%s\n", ptr->hostAddr);
116 fscanf(fp, "%u %u %u\n", &ptr->vid, &ptr->partition, &ptr->date);
120 aconn = UV_Bind(server, TCPORT);
122 TC_PerformDump(aconn, tdumpSetName, &ttapeSet, &tdumps, parentDumpID,
123 dumpLevel, &tdumpID);
124 free(tdumps.tc_dumpArray_val);
126 printf("call to TC_PerformDump failed %u\n", code);
129 printf("dumpid returned %u\n", tdumpID);
134 register struct cmd_syndesc *as;
136 struct rx_connection *aconn;
140 struct tc_restoreDesc *ptr;
142 server = GetServer(SERVERNAME);
144 printf("cant get server id \n");
147 aconn = UV_Bind(server, TCPORT);
148 strcpy(tdumpSetName, "");
149 strcpy(tdumpSetName, "Test");
150 fp = fopen("restoreScr", "r");
151 fscanf(fp, "%u\n", &trestores.tc_restoreArray_len);
152 trestores.tc_restoreArray_val =
153 (struct tc_restoreDesc *)malloc(trestores.tc_restoreArray_len *
154 sizeof(struct tc_restoreDesc));
155 ptr = trestores.tc_restoreArray_val;
156 for (i = 0; i < trestores.tc_restoreArray_len; i++) {
157 fscanf(fp, "%s\n", ptr->oldName);
158 fscanf(fp, "%s\n", ptr->newName);
159 fscanf(fp, "%s\n", ptr->tapeName);
160 fscanf(fp, "%s\n", ptr->hostAddr);
161 fscanf(fp, "%u %u %u %u %d %u\n", &ptr->origVid, &ptr->vid,
162 &ptr->partition, &ptr->flags, &ptr->frag, &ptr->position);
166 code = TC_PerformRestore(aconn, tdumpSetName, &trestores, &tdumpID);
168 printf("call to TC_PerformRestore failed %u\n", code);
171 printf("dumpid returned %u\n", tdumpID);
176 register struct cmd_syndesc *as;
178 struct rx_connection *aconn;
180 server = GetServer(SERVERNAME);
182 printf("cant get server id \n");
185 tdumpID = atol(as->parms[0].items->data);
186 aconn = UV_Bind(server, TCPORT);
187 code = TC_CheckDump(aconn, tdumpID, &tstatus);
189 printf("call to TC_CheckDump failed %u\n", code);
196 register struct cmd_syndesc *as;
198 struct rx_connection *aconn;
200 server = GetServer(SERVERNAME);
202 printf("cant get server id \n");
205 tdumpID = atol(as->parms[0].items->data);
206 aconn = UV_Bind(server, TCPORT);
207 code = TC_AbortDump(aconn, tdumpID);
209 printf("call to TC_AbortDump failed %u\n", code);
216 register struct cmd_syndesc *as;
218 struct rx_connection *aconn;
220 server = GetServer(SERVERNAME);
222 printf("cant get server id \n");
225 tdumpID = atol(as->parms[0].items->data);
226 aconn = UV_Bind(server, TCPORT);
227 code = TC_WaitForDump(aconn, tdumpID);
229 printf("call to TC_WaitForDump failed %u\n", code);
236 register struct cmd_syndesc *as;
238 struct rx_connection *aconn;
240 server = GetServer(SERVERNAME);
242 printf("cant get server id \n");
245 tdumpID = atol(as->parms[0].items->data);
246 aconn = UV_Bind(server, TCPORT);
247 code = TC_EndDump(aconn, tdumpID);
249 printf("call to TC_EndDump failed %u\n", code);
255 MyBeforeProc(as, arock)
256 struct cmd_syndesc *as;
263 printf("Could not initialize rx.\n");
267 rx_SetRxDeadTime(50);
271 #include "AFS_component_version_number.c"
277 register afs_int32 code;
279 register struct cmd_syndesc *ts;
283 * The following signal action for AIX is necessary so that in case of a
284 * crash (i.e. core is generated) we can include the user's data section
285 * in the core dump. Unfortunately, by default, only a partial core is
286 * generated which, in many cases, isn't too useful.
288 struct sigaction nsa;
290 sigemptyset(&nsa.sa_mask);
291 nsa.sa_handler = SIG_DFL;
292 nsa.sa_flags = SA_FULLDUMP;
293 sigaction(SIGABRT, &nsa, NULL);
294 sigaction(SIGSEGV, &nsa, NULL);
296 cmd_SetBeforeProc(MyBeforeProc, NULL);
298 ts = cmd_CreateSyntax("dump", PerformDump, 0, "perform a dump");
300 ts = cmd_CreateSyntax("restore", PerformRestore, 0, "perform a restore");
302 ts = cmd_CreateSyntax("check", CheckDump, 0, "check a dump");
303 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "dump id");
305 ts = cmd_CreateSyntax("abort", AbortDump, 0, "abort a dump");
306 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "dump id");
308 ts = cmd_CreateSyntax("wait", WaitForDump, 0, "wait for a dump");
309 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "dump id");
311 ts = cmd_CreateSyntax("end", EndDump, 0, "end a dump");
312 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "dump id");
314 code = cmd_Dispatch(argc, argv);