AFS
view release on metacpan or search on metacpan
/***********************************************************************
*
* AFS.xs - AFS extensions for Perl
*
* RCS-Id: @(#)$RCS-Id: src/AFS.xs 73757dc Thu Oct 23 12:46:20 2014 +0200 Norbert E Gruener$
*
* Copyright (c) 2003, International Business Machines Corporation and others.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the IBM-LICENSE file in the LICENCES
* directory or online at http://www.openafs.org/dl/license10.html
*
* Contributors
* 2004-2014: Norbert E. Gruener <nog@MPA-Garching.MPG.de>
* 2003: Alf Wachsmann <alfw@slac.stanford.edu>
* Venkata Phani Kiran Achanta <neo_phani@hotmail.com>, and
* Norbert E. Gruener <nog@MPA-Garching.MPG.de>
* 2001-2002: Norbert E. Gruener <nog@MPA-Garching.MPG.de>
*
* The original library was written by Roland Schemers <schemers@slapshot.stanford.edu>
* and is covered by the following copyright:
*
* Copyright (c) 1994 Board of Trustees, Leland Stanford Jr. University
* For conditions of distribution and use, see the copyright notice in
* the Stanford-LICENCE file.
*
* The code for the original library were mainly taken from the AFS
* source distribution, which comes with this message:
*
* Copyright (C) 1989-1994 Transarc Corporation - All rights reserved
* P_R_P_Q_# (C) COPYRIGHT IBM CORPORATION 1987, 1988, 1989
*
***********************************************************************/
#include "EXTERN.h"
#ifdef __sgi /* needed to get a clean compile */
#include <setjmp.h>
#endif
#include "perl.h"
#include "XSUB.h"
#define NEED_newRV_noinc
#define NEED_sv_2pv_flags
#include "ppport.h"
#include <afs/param.h>
/* tired of seeing messages about TRUE/FALSE being redefined in rx/xdr.h */
#undef TRUE
#undef FALSE
#include <rx/xdr.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netdb.h>
#include <errno.h>
#include <stdio.h>
#include <netinet/in.h>
#include <sys/stat.h>
#undef INIT
#include <afs/stds.h>
#include <afs/afs.h>
#include <afs/vice.h>
#include <afs/venus.h>
#undef VIRTUE
#undef VICE
#include <afs/prs_fs.h>
#include <afs/afsint.h>
#include <afs/auth.h>
#include <afs/cellconfig.h>
#if defined(AFS_3_4)
#else
#include <afs/dirpath.h>
#endif
#include <ubik.h>
#include <rx/rxkad.h>
#include <afs/vldbint.h>
#include <afs/volser.h>
#ifndef RV_RDONLY
#define RV_FULLRST 0x000001
#define RV_OFFLINE 0x000002
#define RV_CRDUMP 0x000010
#define RV_CRKEEP 0x000020
#define RV_CRNEW 0x000040
#define RV_LUDUMP 0x000100
#define RV_LUKEEP 0x000200
#define RV_LUNEW 0x000400
code = UV_SyncVldb(tserver, pname, flags, 0 /*unused */ );
}
if (code) {
char buffer[256];
set_errbuff(buffer, code);
VSETCODE(code, buffer);
#PrintDiagnostics("syncvldb", code);
#SETCODE(code);
goto done;
}
else
SETCODE(0);
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
int32
vldb__changeaddr(cstruct, oldip, newip, remove=0)
AFS::VLDB cstruct
char *oldip
char *newip
int32 remove
PREINIT:
int32 ip1, ip2, vcode;
CODE:
{
RETVAL = 0;
ip1 = GetServer(oldip);
if (!ip1) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: invalid host address\n");
VSETCODE(EINVAL, buffer);
goto done;
}
if ((newip && (strlen(newip)) && remove) || (!newip && !remove)) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: Must specify either 'NEWADDR <addr>' or 'REMOVE' flag\n");
VSETCODE(EINVAL, buffer);
goto done;
}
if (newip && (strlen(newip)) != 0) {
ip2 = GetServer(newip);
if (!ip2) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: invalid host address\n");
VSETCODE(EINVAL, buffer);
goto done;
}
}
else {
/* Play a trick here. If we are removing an address, ip1 will be -1
* and ip2 will be the original address. This switch prevents an
* older revision vlserver from removing the IP address.
*/
remove = 1;
ip2 = ip1;
ip1 = 0xffffffff;
}
vcode = ubik_Call_New(VL_ChangeAddr, cstruct, 0, ntohl(ip1), ntohl(ip2));
if (vcode) {
char buffer[256];
if (remove) {
char buff[80];
sprintf(buff, "Could not remove server %s from the VLDB", oldip);
if (vcode == VL_NOENT) {
sprintf(buffer, "%s\nvlserver does not support the REMOVE flag or VLDB: no such entry", buff);
}
else {
sprintf(buffer, "%s\n", buff);
}
}
else {
sprintf(buffer, "Could not change server %s to server %s\n", oldip, newip);
}
VSETCODE(vcode, buffer);
goto done;
}
if (remove) {
fprintf(STDOUT, "Removed server %s from the VLDB\n", oldip);
}
else {
fprintf(STDOUT, "Changed server %s to server %s\n", oldip, newip);
}
SETCODE(0);
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
int32
vldb_remsite(cstruct,server,partition,name)
AFS::VLDB cstruct
char *server
char *partition
char *name
PREINIT:
afs_int32 avolid, aserver, apart, code = 1, err;
char avolname[VOLSER_MAXVOLNAME + 1];
CODE:
{
RETVAL = 0;
#ifdef OpenAFS_1_4
vsu_ExtractName(avolname, name);
#else
strcpy(avolname, name);
#endif
( run in 0.745 second using v1.01-cache-2.11-cpan-39bf76dae61 )