#include <sys/ioctl.h>
#include <afs/venus.h>
#include <afs/cellconfig.h>
-#include <afs/afs.h>
+#include <afs/sys_prototypes.h>
+
+#include <afs/afs_const.h>
/*#include <rx/rxkad.h>*/
#include <rx/rx_null.h>
int code;
if (!strncmp(path, "@afs:", 5)) {
- char *pdup, *p, *host, *id;
+ char *pdup, *p;
struct hostent *he;
pdup = strdup(path);
struct rx_securityClass *sc;
extern int
-start_cb_server()
+start_cb_server(void)
{
struct rx_service *s;
{
char scell[MAXCELLCHARS], dcell[MAXCELLCHARS];
afs_uint32 ssrv, dsrv;
- char *databuffer, *srcf, *destd, *destf, *destpath;
+ char *databuffer, *srcf = NULL, *destd = NULL, *destf = NULL, *destpath = NULL;
struct stat statbuf;
struct AFSStoreStatus sst;
struct AFSCallBack scb, dcb;
struct AFSFid sf, dd, df;
- int filesz;
+ int filesz = 0;
int ch, blksize, bytesremaining, bytes;
struct timeval start, finish;
struct timezone tz;
struct rx_securityClass *ssc = 0, *dsc = 0;
int sscindex, dscindex;
- struct rx_connection *sconn, *dconn;
- struct rx_call *scall, *dcall;
- int code, fetchcode, storecode, printcallerrs;
- int slcl = 0, dlcl = 0;
- int sfd, dfd, unauth = 0;
+ struct rx_connection *sconn = NULL, *dconn = NULL;
+ struct rx_call *scall = NULL, *dcall = NULL;
+ int code = 0, fetchcode, storecode, printcallerrs = 0;
+ int slcl = 0, dlcl = 0, unlock = 0;
+ int sfd = 0, dfd = 0, unauth = 0;
struct AFSCBFids theFids;
struct AFSCBs theCBs;
blksize = 8 * 1024;
- while ((ch = getopt(argc, argv, "ioub:")) != -1) {
+ while ((ch = getopt(argc, argv, "iouUb:")) != -1) {
switch (ch) {
case 'b':
blksize = atoi(optarg);
case 'u':
unauth = 1;
break;
+ case 'U':
+ unlock = 1;
+ break;
default:
printf("Unknown option '%c'\n", ch);
exit(1);
}
- if (argc - optind < 2) {
+ if (argc - optind + unlock < 2) {
fprintf(stderr,
- "Usage: afscp [-i|-o]] [-b xfersz] [-u] source dest\n");
+ "Usage: afscp [-i|-o]] [-b xfersz] [-u] [-U] source [dest]\n");
fprintf(stderr, " -b Set block size\n");
fprintf(stderr, " -i Source is local (copy into AFS)\n");
fprintf(stderr, " -o Dest is local (copy out of AFS)\n");
fprintf(stderr, " -u Run unauthenticated\n");
+ fprintf(stderr, " -U Send an unlock request for source. (dest path not required)\n");
fprintf(stderr, "source and dest can be paths or specified as:\n");
fprintf(stderr, " @afs:cellname:servername:volume:vnode:uniq\n");
exit(1);
}
srcf = argv[optind++];
- destpath = argv[optind++];
- destd = strdup(destpath);
- if (!destd) {
- perror("strdup");
- exit(1);
- }
- if ((destf = strrchr(destd, '/'))) {
- *destf++ = 0;
- } else {
- destf = destd;
- destd = ".";
+ if (!unlock) {
+ destpath = argv[optind++];
+ destd = strdup(destpath);
+ if (!destd) {
+ perror("strdup");
+ exit(1);
+ }
+ if ((destf = strrchr(destd, '/'))) {
+ *destf++ = 0;
+ } else {
+ destf = destd;
+ destd = ".";
+ }
+ } else if (slcl) {
+ fprintf(stderr, "-i and -U cannot be used together\n");
}
-
if (!slcl && statfile(srcf, scell, &ssrv, &sf)) {
fprintf(stderr, "Cannot get attributes of %s\n", srcf);
exit(1);
}
- if (!dlcl && statfile(destd, dcell, &dsrv, &dd)) {
+ if (!unlock && !dlcl && statfile(destd, dcell, &dsrv, &dd)) {
fprintf(stderr, "Cannot get attributes of %s\n", destd);
exit(1);
}
}
}
- if (!dlcl) {
+ if (!dlcl && !unlock) {
if (!slcl && ssrv == dsrv) {
dconn = sconn;
dsc = NULL;
memset(&sst, 0, sizeof(struct AFSStoreStatus));
- if (dlcl) {
+ if (dlcl && !unlock) {
dfd = open(destpath, O_RDWR | O_CREAT | O_EXCL, 0666);
if (dfd < 0 && errno == EEXIST) {
printf("%s already exists, overwriting\n", destpath);
afs_error_message(errno));
goto Fail_dconn;
}
- } else {
+ } else if (!unlock) {
if ((code =
RXAFS_CreateFile(dconn, &dd, destf, &sst, &df, &fst, &dfst, &dcb,
&vs))) {
printcallerrs = 0;
fetchcode = 0;
storecode = 0;
- if (!slcl)
+ if (!slcl && !unlock)
scall = rx_NewCall(sconn);
- if (!dlcl)
+ if (!dlcl && !unlock)
dcall = rx_NewCall(dconn);
gettimeofday(&start, &tz);
+ if (unlock) {
+ if (fst.lockCount) {
+ printf("Sending 1 unlock for %s (%d locks)\n", srcf, fst.lockCount);
+ if ((code = RXAFS_ReleaseLock(sconn, &sf, &vs))) {
+ printf("Unable to unlock %s (%s)\n", srcf,
+ afs_error_message(code));
+ }
+ } else {
+ printf("No locks for %s\n", srcf);
+ }
+ fetchcode = code;
+ goto Finish;
+ }
if (!slcl) {
if ((code = StartRXAFS_FetchData(scall, &sf, 0, filesz))) {
if (dlcl) {
if (close(dfd) && !storecode)
storecode = errno;
- } else {
+ } else if (!unlock) {
storecode = rx_EndCall(dcall, storecode);
}
if (storecode && printcallerrs)
printf("Error returned from store: %s\n", afs_error_message(storecode));
-
+Finish:
gettimeofday(&finish, &tz);
if (!slcl) {
code = fetchcode;
Fail_dconn:
- if (!dlcl && (slcl || dconn != sconn))
+ if (!dlcl && !unlock && (slcl || dconn != sconn))
rx_DestroyConnection(dconn);
Fail_sconn:
if (!slcl)
rx_Finalize();
free(databuffer);
- if (printcallerrs) {
+ if (printcallerrs && !unlock) {
double rate, size, time;
if (finish.tv_sec == start.tv_sec) {
printf("Copied %d bytes in %d microseconds\n", filesz,
finish.tv_usec - start.tv_usec);
} else {
printf("Copied %d bytes in %d seconds\n", filesz,
- finish.tv_sec - start.tv_sec);
+ (int)(finish.tv_sec - start.tv_sec));
}
size = filesz / 1024.0;
#include <afs/param.h>
#include <afs/afscbint.h> /*Callback interface defs */
+#include <afs/afsutil.h>
+#include <afs/afsutil_prototypes.h>
int afs_cb_inited = 0;
struct interfaceAddr afs_cb_interface;
static int
-init_afs_cb()
+init_afs_cb(void)
{
int count;
afs_uuid_create(&afs_cb_interface.uuid);
- count = rx_getAllAddr(&afs_cb_interface.addr_in, AFS_MAX_INTERFACE_ADDR);
+ count = rx_getAllAddr((afs_uint32 *)&afs_cb_interface.addr_in, AFS_MAX_INTERFACE_ADDR);
if (count <= 0)
afs_cb_interface.numberOfInterfaces = 0;
else
}
afs_int32
-SRXAFSCB_CallBack(rxcall, Fids_Array, CallBack_Array)
- struct rx_call *rxcall;
- AFSCBFids *Fids_Array;
- AFSCBs *CallBack_Array;
-
+SRXAFSCB_CallBack(struct rx_call *rxcall, AFSCBFids *Fids_Array,
+ AFSCBs *CallBack_Array)
{ /*SRXAFSCB_CallBack */
return (0);
afs_int32
-SRXAFSCB_InitCallBackState(rxcall)
- struct rx_call *rxcall;
-
+SRXAFSCB_InitCallBackState(struct rx_call *rxcall)
{ /*SRXAFSCB_InitCallBackState */
return (0);
} /*SRXAFSCB_InitCallBackState */
afs_int32
-SRXAFSCB_Probe(rxcall)
- struct rx_call *rxcall;
-
+SRXAFSCB_Probe(struct rx_call *rxcall)
{ /*SRXAFSCB_Probe */
return (0);
} /*SRXAFSCB_Probe */
-
afs_int32
-SRXAFSCB_GetCE(rxcall, index, ce)
- struct rx_call *rxcall;
- afs_int32 index;
- AFSDBCacheEntry * ce;
+SRXAFSCB_GetCE(struct rx_call *rxcall, afs_int32 index, AFSDBCacheEntry * ce)
{ /*SRXAFSCB_GetCE */
return (0);
} /*SRXAFSCB_GetCE */
afs_int32
-SRXAFSCB_GetCE64(rxcall, index, ce)
- struct rx_call *rxcall;
- afs_int32 index;
- AFSDBCacheEntry64 *ce;
+SRXAFSCB_GetCE64(struct rx_call *rxcall, afs_int32 index, AFSDBCacheEntry64 *ce)
{ /*SRXAFSCB_GetCE64 */
return (0);
} /*SRXAFSCB_GetCE64 */
afs_int32
-SRXAFSCB_GetLock(rxcall, index, lock)
- struct rx_call *rxcall;
- afs_int32 index;
- AFSDBLock *lock;
+SRXAFSCB_GetLock(struct rx_call *rxcall, afs_int32 index, AFSDBLock *lock)
{ /*SRXAFSCB_GetLock */
return (0);
} /*SRXAFSCB_GetLock */
afs_int32
-SRXAFSCB_XStatsVersion(rxcall, v)
- struct rx_call *rxcall;
- afs_int32 *v;
+SRXAFSCB_XStatsVersion(struct rx_call *rxcall, afs_int32 *v)
{ /*SRXAFSCB_XStatsVersion */
return (0);
} /*SRXAFSCB_XStatsVersion */
afs_int32
-SRXAFSCB_GetXStats(rxcall, clientVersionNumber, collectionNumber, srvVersionNumberP, timeP, dataP)
- struct rx_call *rxcall;
- afs_int32 clientVersionNumber;
- afs_int32 collectionNumber;
- afs_int32 * srvVersionNumberP;
- afs_int32 * timeP;
- AFSCB_CollData * dataP;
+SRXAFSCB_GetXStats(struct rx_call *rxcall, afs_int32 clientVersionNumber,
+ afs_int32 collectionNumber, afs_int32 * srvVersionNumberP,
+ afs_int32 * timeP, AFSCB_CollData * dataP)
{ /*SRXAFSCB_GetXStats */
return (0);
} /*SRXAFSCB_GetXStats */
int
-SRXAFSCB_InitCallBackState2(rxcall, addr)
- struct rx_call *rxcall;
- struct interfaceAddr *addr;
+SRXAFSCB_InitCallBackState2(struct rx_call *rxcall, struct interfaceAddr *addr)
{
return RXGEN_OPCODE;
}
int
-SRXAFSCB_WhoAreYou(rxcall, addr)
- struct rx_call *rxcall;
- struct interfaceAddr *addr;
+SRXAFSCB_WhoAreYou(struct rx_call *rxcall, struct interfaceAddr *addr)
{
if (rxcall && addr) {
if (!afs_cb_inited)
}
int
-SRXAFSCB_InitCallBackState3(rxcall, uuidp)
- struct rx_call *rxcall;
- afsUUID *uuidp;
+SRXAFSCB_InitCallBackState3(struct rx_call *rxcall, afsUUID *uuidp)
{
return (0);
}
int
-SRXAFSCB_ProbeUuid(rxcall, uuidp)
- struct rx_call *rxcall;
- afsUUID *uuidp;
+SRXAFSCB_ProbeUuid(struct rx_call *rxcall, afsUUID *uuidp)
{
int code = 0;
if (!afs_cb_inited)
}
afs_int32
-SRXAFSCB_GetServerPrefs(rxcall, serverIndex, srvrAddr, srvrRank)
- struct rx_call *rxcall;
- afs_int32 serverIndex;
- afs_int32 *srvrAddr;
- afs_int32 *srvrRank;
+SRXAFSCB_GetServerPrefs(struct rx_call *rxcall, afs_int32 serverIndex,
+ afs_int32 *srvrAddr, afs_int32 *srvrRank)
{
return RXGEN_OPCODE;
}
afs_int32
-SRXAFSCB_GetCellServDB(rxcall, cellIndex, cellName, cellHosts)
- struct rx_call *rxcall;
- afs_int32 cellIndex;
- char **cellName;
- serverList *cellHosts;
+SRXAFSCB_GetCellServDB(struct rx_call *rxcall, afs_int32 cellIndex,
+ char **cellName, serverList *cellHosts)
{
return RXGEN_OPCODE;
}
afs_int32
-SRXAFSCB_GetLocalCell(rxcall, cellName)
- struct rx_call *rxcall;
- char **cellName;
+SRXAFSCB_GetLocalCell(struct rx_call *rxcall, char **cellName)
{
return RXGEN_OPCODE;
}
afs_int32
-SRXAFSCB_GetCacheConfig(rxcall, callerVersion, serverVersion, configCount,
- config)
- struct rx_call *rxcall;
- afs_uint32 callerVersion;
- afs_uint32 *serverVersion;
- afs_uint32 *configCount;
- cacheConfig *config;
+SRXAFSCB_GetCacheConfig(struct rx_call *rxcall, afs_uint32 callerVersion,
+ afs_uint32 *serverVersion, afs_uint32 *configCount,
+ cacheConfig *config)
{
return RXGEN_OPCODE;
}
afs_int32
-SRXAFSCB_GetCellByNum(rxcall, cellnum, cellname, cellhosts)
- struct rx_call *rxcall;
- afs_int32 cellnum;
- char **cellname;
- serverList *cellhosts;
+SRXAFSCB_GetCellByNum(struct rx_call *rxcall, afs_int32 cellnum,
+ char **cellname, serverList *cellhosts)
{
return RXGEN_OPCODE;
}
afs_int32
-SRXAFSCB_TellMeAboutYourself(rxcall, addr, cap)
- struct rx_call *rxcall;
- struct interfaceAddr *addr;
- Capabilities *cap;
+SRXAFSCB_TellMeAboutYourself(struct rx_call *rxcall,
+ struct interfaceAddr *addr, Capabilities *cap)
{
return RXGEN_OPCODE;
}