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
12 * Implementation of the xstat_fs callback routines. These are the
13 * server-side functions that the File Server expects to invoke on
14 * the client machine via the afsint interface. In this case, the
15 * client process is acting as a callback listener, so it has to
16 * be prepared to answer these calls.
19 * The afsint server stubs expect the functions defined here to
20 * be provided. There is no .h file for this code, since the
21 * linker really does all the work for us, and these don't really
22 * need to be ``visible'' to anyone else.
23 *------------------------------------------------------------------------*/
25 #include <afsconfig.h>
26 #include <afs/param.h>
35 #include <afs/afscbint.h> /*Callback interface defs */
36 #include <afs/afsutil.h>
38 int afs_cb_inited
= 0;
39 struct interfaceAddr afs_cb_interface
;
41 #define XSTAT_FS_CALLBACK_VERBOSE 0
44 * Initialize the callback interface structure
52 UuidCreate((UUID
*)&afs_cb_interface
.uuid
);
54 afs_uuid_create(&afs_cb_interface
.uuid
);
56 count
= rx_getAllAddr((afs_uint32
*)afs_cb_interface
.addr_in
, AFS_MAX_INTERFACE_ADDR
);
58 afs_cb_interface
.numberOfInterfaces
= 0;
60 afs_cb_interface
.numberOfInterfaces
= count
;
65 #if XSTAT_FS_CALLBACK_VERBOSE
66 static char mn
[] = "xstat_fs_callback"; /*Module name */
69 /*------------------------------------------------------------------------
73 * Handle a set of callbacks from the File Server.
76 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
77 * AFSCBFids *Fids_Array : Ptr to the set of Fids.
78 * AFSCBs *CallBacks_Array : Ptr to the set of callbacks.
82 * Error value otherwise.
85 * Nothing interesting.
89 *------------------------------------------------------------------------*/
92 SRXAFSCB_CallBack(struct rx_call
*rxcall
, AFSCBFids
* Fids_Array
,
93 AFSCBs
* CallBack_Array
)
94 { /*SRXAFSCB_CallBack */
96 #if XSTAT_FS_CALLBACK_VERBOSE
97 static char rn
[] = "SRXAFSCB_CallBack"; /*Routine name */
98 char hostName
[256]; /*Host name buffer */
99 char *hostNameResult
; /*Ptr to static */
101 fprintf(stderr
, "[%s:%s] Called\n", mn
, rn
);
103 if (rxcall
!= (struct rx_call
*)0) {
105 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
106 strcpy(hostName
, hostNameResult
);
107 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
108 hostName
, rxcall
->conn
->peer
->port
);
109 } /*Valid rxcall param */
110 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
113 * Return successfully.
117 } /*SRXAFSCB_CallBack */
119 /*------------------------------------------------------------------------
120 * SRXAFSCB_InitCallBackState
123 * Initialize callback state on this ``Cache Manager''.
126 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
130 * Error value otherwise.
133 * This will definitely be called by the File Server (exactly once),
134 * since it will think we are another new ``Cache Manager''.
138 *------------------------------------------------------------------------*/
141 SRXAFSCB_InitCallBackState(struct rx_call
* rxcall
)
142 { /*SRXAFSCB_InitCallBackState */
144 #if XSTAT_FS_CALLBACK_VERBOSE
145 static char rn
[] = "SRXAFSCB_InitCallBackState"; /*Routine name */
146 char hostName
[256]; /*Host name buffer */
147 char *hostNameResult
; /*Ptr to static */
149 fprintf(stderr
, "[%s:%s] Called\n", mn
, rn
);
151 if (rxcall
!= (struct rx_call
*)0) {
153 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
154 strcpy(hostName
, hostNameResult
);
155 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
156 hostName
, rxcall
->conn
->peer
->port
);
157 } /*Valid rxcall param */
158 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
161 * Return successfully.
165 } /*SRXAFSCB_InitCallBackState */
167 /*------------------------------------------------------------------------
171 * Respond to a probe from the File Server. If a File Server
172 * doesn't hear from you every so often, it will send you a probe
173 * to make sure you're there, just like any other ``Cache Manager''
174 * it's keeping track of.
177 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
181 * Error value otherwise.
184 * This may be called by the File Server if we don't call it often
189 *------------------------------------------------------------------------*/
192 SRXAFSCB_Probe(struct rx_call
* rxcall
)
193 { /*SRXAFSCB_Probe */
195 #if XSTAT_FS_CALLBACK_VERBOSE
196 static char rn
[] = "SRXAFSCB_Probe"; /*Routine name */
197 char hostName
[256]; /*Host name buffer */
198 char *hostNameResult
; /*Ptr to static */
200 fprintf(stderr
, "[%s:%s] Called\n", mn
, rn
);
202 if (rxcall
!= (struct rx_call
*)0) {
204 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
205 strcpy(hostName
, hostNameResult
);
206 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
207 hostName
, rxcall
->conn
->peer
->port
);
208 } /*Valid rxcall param */
209 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
212 * Return successfully.
216 } /*SRXAFSCB_Probe */
219 /*------------------------------------------------------------------------
223 * Respond minimally to a request for returning the contents of
224 * a cache entry, since someone out there thinks you're a Cache
228 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
234 * Nothing interesting.
238 *------------------------------------------------------------------------*/
241 SRXAFSCB_GetCE64(struct rx_call
* rxcall
, afs_int32 index
,
242 AFSDBCacheEntry64
* ce
)
243 { /*SRXAFSCB_GetCE64 */
245 #if XSTAT_FS_CALLBACK_VERBOSE
246 static char rn
[] = "SRXAFSCB_GetCE64"; /*Routine name */
247 char hostName
[256]; /*Host name buffer */
248 char *hostNameResult
; /*Ptr to static */
250 if (rxcall
!= (struct rx_call
*)0) {
252 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
253 strcpy(hostName
, hostNameResult
);
254 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
255 hostName
, rxcall
->conn
->peer
->port
);
256 } /*Valid rxcall param */
257 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
261 } /*SRXAFSCB_GetCE64 */
264 SRXAFSCB_GetCE(struct rx_call
* rxcall
, afs_int32 index
, AFSDBCacheEntry
* ce
)
265 { /*SRXAFSCB_GetCE */
267 #if XSTAT_FS_CALLBACK_VERBOSE
268 static char rn
[] = "SRXAFSCB_GetCE"; /*Routine name */
269 char hostName
[256]; /*Host name buffer */
270 char *hostNameResult
; /*Ptr to static */
272 if (rxcall
!= (struct rx_call
*)0) {
274 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
275 strcpy(hostName
, hostNameResult
);
276 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
277 hostName
, rxcall
->conn
->peer
->port
);
278 } /*Valid rxcall param */
279 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
283 } /*SRXAFSCB_GetCE */
286 /*------------------------------------------------------------------------
290 * Respond minimally to a request for returning the contents of
291 * a cache lock, since someone out there thinks you're a Cache
295 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
301 * Nothing interesting.
305 *------------------------------------------------------------------------*/
308 SRXAFSCB_GetLock(struct rx_call
* rxcall
, afs_int32 index
, AFSDBLock
* lock
)
309 { /*SRXAFSCB_GetLock */
311 #if XSTAT_FS_CALLBACK_VERBOSE
312 static char rn
[] = "SRXAFSCB_GetLock"; /*Routine name */
313 char hostName
[256]; /*Host name buffer */
314 char *hostNameResult
; /*Ptr to static */
316 if (rxcall
!= (struct rx_call
*)0) {
318 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
319 strcpy(hostName
, hostNameResult
);
320 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
321 hostName
, rxcall
->conn
->peer
->port
);
322 } /*Valid rxcall param */
323 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
327 } /*SRXAFSCB_GetLock */
330 /*------------------------------------------------------------------------
331 * SRXAFSCB_XStatsVersion
334 * Respond minimally to a request for fetching the version of
335 * extended Cache Manager statistics offered, since someone out
336 * there thinks you're a Cache Manager.
339 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
345 * Nothing interesting.
349 *------------------------------------------------------------------------*/
352 SRXAFSCB_XStatsVersion(struct rx_call
* rxcall
, afs_int32
* versionNumberP
)
353 { /*SRXAFSCB_XStatsVersion */
355 #if XSTAT_FS_CALLBACK_VERBOSE
356 static char rn
[] = "SRXAFSCB_XStatsVersion"; /*Routine name */
357 char hostName
[256]; /*Host name buffer */
358 char *hostNameResult
; /*Ptr to static */
360 if (rxcall
!= (struct rx_call
*)0) {
362 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
363 strcpy(hostName
, hostNameResult
);
364 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
365 hostName
, rxcall
->conn
->peer
->port
);
366 } /*Valid rxcall param */
367 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
371 } /*SRXAFSCB_XStatsVersion */
374 /*------------------------------------------------------------------------
378 * Respond minimally to a request for returning extended
379 * statistics for a Cache Manager, since someone out there thinks
380 * you're a Cache Manager.
383 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
389 * Nothing interesting.
393 *------------------------------------------------------------------------*/
396 SRXAFSCB_GetXStats(struct rx_call
* rxcall
, afs_int32 clientVersionNumber
,
397 afs_int32 collectionNumber
, afs_int32
* srvVersionNumberP
,
398 afs_int32
* timeP
, AFSCB_CollData
* dataP
)
399 { /*SRXAFSCB_GetXStats */
401 #if XSTAT_FS_CALLBACK_VERBOSE
402 static char rn
[] = "SRXAFSCB_GetXStats"; /*Routine name */
403 char hostName
[256]; /*Host name buffer */
404 char *hostNameResult
; /*Ptr to static */
406 if (rxcall
!= (struct rx_call
*)0) {
408 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
409 strcpy(hostName
, hostNameResult
);
410 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
411 hostName
, rxcall
->conn
->peer
->port
);
412 } /*Valid rxcall param */
413 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
417 } /*SRXAFSCB_GetXStats */
419 /*------------------------------------------------------------------------
420 * EXPORTED SRXAFSCB_InitCallBackState2
423 * This routine was used in the AFS 3.5 beta release, but not anymore.
424 * It has since been replaced by SRXAFSCB_InitCallBackState3.
427 * rxcall : Ptr to Rx call on which this request came in.
430 * RXGEN_OPCODE (always).
433 * Nothing interesting.
437 *------------------------------------------------------------------------*/
440 SRXAFSCB_InitCallBackState2(struct rx_call
* rxcall
,
441 struct interfaceAddr
* addr
)
444 #if XSTAT_FS_CALLBACK_VERBOSE
445 static char rn
[] = "SRXAFSCB_InitCallBackState2"; /*Routine name */
446 char hostName
[256]; /*Host name buffer */
447 char *hostNameResult
; /*Ptr to static */
449 if (rxcall
!= (struct rx_call
*)0) {
451 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
452 strcpy(hostName
, hostNameResult
);
453 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
454 hostName
, rxcall
->conn
->peer
->port
);
455 } /*Valid rxcall param */
456 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
460 /*------------------------------------------------------------------------
461 * EXPORTED SRXAFSCB_WhoAreYou
464 * Routine called by the server-side callback RPC interface to
465 * obtain a unique identifier for the client. The server uses
466 * this identifier to figure out whether or not two RX connections
467 * are from the same client, and to find out which addresses go
468 * with which clients.
471 * rxcall : Ptr to Rx call on which this request came in.
472 * addr: Ptr to return the list of interfaces for this client.
478 * Nothing interesting.
482 *------------------------------------------------------------------------*/
485 SRXAFSCB_WhoAreYou(struct rx_call
* rxcall
, struct interfaceAddr
* addr
)
487 #if XSTAT_FS_CALLBACK_VERBOSE
488 static char rn
[] = "SRXAFSCB_WhoAreYou"; /*Routine name */
489 char hostName
[256]; /*Host name buffer */
490 char *hostNameResult
; /*Ptr to static */
492 if (rxcall
!= (struct rx_call
*)0) {
494 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
495 strcpy(hostName
, hostNameResult
);
496 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
497 hostName
, rxcall
->conn
->peer
->port
);
498 } /*Valid rxcall param */
499 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
501 if (rxcall
&& addr
) {
504 *addr
= afs_cb_interface
;
508 * Return successfully.
514 /*------------------------------------------------------------------------
515 * EXPORTED SRXAFSCB_InitCallBackState3
518 * Routine called by the server-side callback RPC interface to
519 * implement clearing all callbacks from this host.
522 * rxcall : Ptr to Rx call on which this request came in.
528 * Nothing interesting.
532 *------------------------------------------------------------------------*/
535 SRXAFSCB_InitCallBackState3(struct rx_call
* rxcall
, afsUUID
* uuidp
)
537 #if XSTAT_FS_CALLBACK_VERBOSE
538 static char rn
[] = "SRXAFSCB_InitCallBackState3"; /*Routine name */
539 char hostName
[256]; /*Host name buffer */
540 char *hostNameResult
; /*Ptr to static */
542 if (rxcall
!= (struct rx_call
*)0) {
544 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
545 strcpy(hostName
, hostNameResult
);
546 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
547 hostName
, rxcall
->conn
->peer
->port
);
548 } /*Valid rxcall param */
549 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
552 * Return successfully.
558 /*------------------------------------------------------------------------
559 * EXPORTED SRXAFSCB_ProbeUuid
562 * Routine called by the server-side callback RPC interface to
563 * implement ``probing'' the Cache Manager, just making sure it's
564 * still there is still the same client it used to be.
567 * rxcall : Ptr to Rx call on which this request came in.
568 * uuidp : Ptr to UUID that must match the client's UUID.
571 * 0 if uuidp matches the UUID for this client
575 * Nothing interesting.
579 *------------------------------------------------------------------------*/
582 SRXAFSCB_ProbeUuid(struct rx_call
* rxcall
, afsUUID
* uuidp
)
586 #if XSTAT_FS_CALLBACK_VERBOSE
587 static char rn
[] = "SRXAFSCB_ProbeUuid"; /*Routine name */
588 char hostName
[256]; /*Host name buffer */
589 char *hostNameResult
; /*Ptr to static */
591 if (rxcall
!= (struct rx_call
*)0) {
593 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
594 strcpy(hostName
, hostNameResult
);
595 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
596 hostName
, rxcall
->conn
->peer
->port
);
597 } /*Valid rxcall param */
598 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
602 if (!afs_uuid_equal(uuidp
, &afs_cb_interface
.uuid
))
603 code
= 1; /* failure */
607 /*------------------------------------------------------------------------
608 * EXPORTED SRXAFSCB_GetServerPrefs
611 * Routine to list server preferences used by this client.
614 * a_call : Ptr to Rx call on which this request came in.
615 * a_index : Input server index
616 * a_srvr_addr : Output server address (0xffffffff on last server)
617 * a_srvr_rank : Output server rank
620 * RXGEN_OPCODE (always)
623 * Nothing interesting.
627 *------------------------------------------------------------------------*/
630 SRXAFSCB_GetServerPrefs(struct rx_call
* a_call
, afs_int32 a_index
,
631 afs_int32
* a_srvr_addr
, afs_int32
* a_srvr_rank
)
636 /*------------------------------------------------------------------------
637 * EXPORTED SRXAFSCB_GetCellServDB
640 * Routine to list cells configured for this client
643 * a_call : Ptr to Rx call on which this request came in.
644 * a_index : Input cell index
645 * a_name : Output cell name ("" on last cell)
646 * a_hosts : Output cell database servers
652 * Nothing interesting.
656 *------------------------------------------------------------------------*/
659 SRXAFSCB_GetCellServDB(struct rx_call
* a_call
, afs_int32 a_index
,
660 char **a_name
, serverList
* a_hosts
)
667 SRXAFSCB_GetCellByNum(struct rx_call
* a_call
, afs_int32 a_cellnum
,
668 char **a_name
, serverList
* a_hosts
)
674 /*------------------------------------------------------------------------
675 * EXPORTED SRXAFSCB_GetLocalCell
678 * Routine to return name of client's local cell
681 * a_call : Ptr to Rx call on which this request came in.
682 * a_name : Output cell name
685 * RXGEN_OPCODE (always)
688 * Nothing interesting.
692 *------------------------------------------------------------------------*/
695 SRXAFSCB_GetLocalCell(struct rx_call
* a_call
, char **a_name
)
699 t_name
= malloc(AFSNAMEMAX
);
702 strcpy(t_name
, "This is xstat_fs");
708 /*------------------------------------------------------------------------
709 * EXPORTED SRXAFSCB_GetCacheConfig
712 * Routine to return parameters used to initialize client cache.
713 * Client may request any format version. Server may not return
714 * format version greater than version requested by client.
717 * a_call: Ptr to Rx call on which this request came in.
718 * callerVersion: Data format version desired by the client.
719 * serverVersion: Data format version of output data.
720 * configCount: Number bytes allocated for output data.
721 * config: Client cache configuration.
724 * RXGEN_OPCODE (always)
727 * Nothing interesting.
731 *------------------------------------------------------------------------*/
734 SRXAFSCB_GetCacheConfig(struct rx_call
* a_call
, afs_uint32 callerVersion
,
735 afs_uint32
* serverVersion
, afs_uint32
* configCount
,
736 cacheConfig
* config
)
742 SRXAFSCB_TellMeAboutYourself(struct rx_call
* rxcall
,
743 struct interfaceAddr
* addr
,
744 Capabilities
* capabilites
)
746 #if XSTAT_FS_CALLBACK_VERBOSE
747 static char rn
[] = "SRXAFSCB_TellMeAboutYourself"; /*Routine name */
748 char hostName
[256]; /*Host name buffer */
749 char *hostNameResult
; /*Ptr to static */
751 if (rxcall
!= (struct rx_call
*)0) {
753 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
754 strcpy(hostName
, hostNameResult
);
755 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
756 hostName
, rxcall
->conn
->peer
->port
);
757 } /*Valid rxcall param */
758 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
760 if (rxcall
&& addr
) {
763 *addr
= afs_cb_interface
;
767 * Return successfully.
772 int SRXAFSCB_GetDE(struct rx_call
*a_call
, afs_int32 a_index
, afs_int32 addr
,
773 afs_int32 inode
, afs_int32 flags
, afs_int32 time
,