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>
26 #include <afs/cellconfig.h>
29 #include <afs/afsint.h>
32 #include <afs/tcdata.h>
37 #define SERVERNAME "server1"
40 struct tc_tapeSet ttapeSet;
41 char tdumpSetName[TC_MAXNAMELEN];
42 tc_dumpArray tdumps; /*defined by rxgen */
43 tc_restoreArray trestores; /*defined by rxgen */
45 struct tc_dumpStat tstatus;
48 struct rx_connection *
49 UV_Bind(aserver, port)
50 afs_int32 aserver, port;
52 register struct rx_connection *tc;
53 struct rx_securityClass *uvclass;
55 uvclass = rxnull_NewClientSecurityObject();
56 tc = rx_NewConnection(aserver, htons(port), TCSERVICE_ID, uvclass, 0);
61 /* return host address in network byte order */
66 register struct hostent *th;
69 register afs_int32 code;
71 code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
73 addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
74 return htonl(addr); /* convert to network order (128 in byte 0) */
76 th = gethostbyname(aname);
79 memcpy(&addr, th->h_addr, sizeof(addr));
86 register struct cmd_syndesc *as;
88 struct rx_connection *aconn;
91 struct tc_dumpDesc *ptr;
93 afs_int32 parentDumpID, dumpLevel;
95 server = GetServer(SERVERNAME);
97 printf("cant get server id \n");
102 strcpy(tdumpSetName, "Test");
104 ttapeSet.maxTapes = 10;
105 fp = fopen("dumpScr", "r");
106 fscanf(fp, "%u %u %u\n", &tdumps.tc_dumpArray_len, &ttapeSet.a,
108 strcpy(ttapeSet.format, "tapeName%u");
109 strcpy(ttapeSet.tapeServer, "diskTapes");
110 tdumps.tc_dumpArray_val =
112 *)(malloc(tdumps.tc_dumpArray_len * sizeof(struct tc_dumpDesc)));
113 ptr = tdumps.tc_dumpArray_val;
114 for (i = 0; i < tdumps.tc_dumpArray_len; i++) {
115 fscanf(fp, "%s\n", ptr->name);
116 fscanf(fp, "%s\n", ptr->hostAddr);
117 fscanf(fp, "%u %u %u\n", &ptr->vid, &ptr->partition, &ptr->date);
121 aconn = UV_Bind(server, TCPORT);
123 TC_PerformDump(aconn, tdumpSetName, &ttapeSet, &tdumps, parentDumpID,
124 dumpLevel, &tdumpID);
125 free(tdumps.tc_dumpArray_val);
127 printf("call to TC_PerformDump failed %u\n", code);
130 printf("dumpid returned %u\n", tdumpID);
135 register struct cmd_syndesc *as;
137 struct rx_connection *aconn;
141 struct tc_restoreDesc *ptr;
143 server = GetServer(SERVERNAME);
145 printf("cant get server id \n");
148 aconn = UV_Bind(server, TCPORT);
149 strcpy(tdumpSetName, "");
150 strcpy(tdumpSetName, "Test");
151 fp = fopen("restoreScr", "r");
152 fscanf(fp, "%u\n", &trestores.tc_restoreArray_len);
153 trestores.tc_restoreArray_val =
154 (struct tc_restoreDesc *)malloc(trestores.tc_restoreArray_len *
155 sizeof(struct tc_restoreDesc));
156 ptr = trestores.tc_restoreArray_val;
157 for (i = 0; i < trestores.tc_restoreArray_len; i++) {
158 fscanf(fp, "%s\n", ptr->oldName);
159 fscanf(fp, "%s\n", ptr->newName);
160 fscanf(fp, "%s\n", ptr->tapeName);
161 fscanf(fp, "%s\n", ptr->hostAddr);
162 fscanf(fp, "%u %u %u %u %d %u\n", &ptr->origVid, &ptr->vid,
163 &ptr->partition, &ptr->flags, &ptr->frag, &ptr->position);
167 code = TC_PerformRestore(aconn, tdumpSetName, &trestores, &tdumpID);
169 printf("call to TC_PerformRestore failed %u\n", code);
172 printf("dumpid returned %u\n", tdumpID);
177 register struct cmd_syndesc *as;
179 struct rx_connection *aconn;
181 server = GetServer(SERVERNAME);
183 printf("cant get server id \n");
186 tdumpID = atol(as->parms[0].items->data);
187 aconn = UV_Bind(server, TCPORT);
188 code = TC_CheckDump(aconn, tdumpID, &tstatus);
190 printf("call to TC_CheckDump failed %u\n", code);
197 register struct cmd_syndesc *as;
199 struct rx_connection *aconn;
201 server = GetServer(SERVERNAME);
203 printf("cant get server id \n");
206 tdumpID = atol(as->parms[0].items->data);
207 aconn = UV_Bind(server, TCPORT);
208 code = TC_AbortDump(aconn, tdumpID);
210 printf("call to TC_AbortDump failed %u\n", code);
217 register struct cmd_syndesc *as;
219 struct rx_connection *aconn;
221 server = GetServer(SERVERNAME);
223 printf("cant get server id \n");
226 tdumpID = atol(as->parms[0].items->data);
227 aconn = UV_Bind(server, TCPORT);
228 code = TC_WaitForDump(aconn, tdumpID);
230 printf("call to TC_WaitForDump failed %u\n", code);
237 register struct cmd_syndesc *as;
239 struct rx_connection *aconn;
241 server = GetServer(SERVERNAME);
243 printf("cant get server id \n");
246 tdumpID = atol(as->parms[0].items->data);
247 aconn = UV_Bind(server, TCPORT);
248 code = TC_EndDump(aconn, tdumpID);
250 printf("call to TC_EndDump failed %u\n", code);
256 MyBeforeProc(as, arock)
257 struct cmd_syndesc *as;
264 printf("Could not initialize rx.\n");
268 rx_SetRxDeadTime(50);
272 #include "AFS_component_version_number.c"
278 register afs_int32 code;
280 register struct cmd_syndesc *ts;
284 * The following signal action for AIX is necessary so that in case of a
285 * crash (i.e. core is generated) we can include the user's data section
286 * in the core dump. Unfortunately, by default, only a partial core is
287 * generated which, in many cases, isn't too useful.
289 struct sigaction nsa;
291 sigemptyset(&nsa.sa_mask);
292 nsa.sa_handler = SIG_DFL;
293 nsa.sa_flags = SA_FULLDUMP;
294 sigaction(SIGABRT, &nsa, NULL);
295 sigaction(SIGSEGV, &nsa, NULL);
297 cmd_SetBeforeProc(MyBeforeProc, NULL);
299 ts = cmd_CreateSyntax("dump", PerformDump, 0, "perform a dump");
301 ts = cmd_CreateSyntax("restore", PerformRestore, 0, "perform a restore");
303 ts = cmd_CreateSyntax("check", CheckDump, 0, "check a dump");
304 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "dump id");
306 ts = cmd_CreateSyntax("abort", AbortDump, 0, "abort a dump");
307 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "dump id");
309 ts = cmd_CreateSyntax("wait", WaitForDump, 0, "wait for a dump");
310 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "dump id");
312 ts = cmd_CreateSyntax("end", EndDump, 0, "end a dump");
313 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "dump id");
315 code = cmd_Dispatch(argc, argv);