From c4a1aeaf8c09979d9ff845681cc4530df872e5a1 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Thu, 6 Mar 2003 15:43:56 +0000 Subject: [PATCH] initial-error-translation-implementation-20030306 client still needs to "untranslate", and the error tables themselves need to be defined and the server-side array populated --- src/viced/afsfileprocs.c | 81 ++++++++++++++++++++++-------------- src/viced/host.c | 32 +++++++++++++- src/viced/host.h | 1 + src/viced/viced.c | 1 + src/viced/viced_prototypes.h | 7 ++++ 5 files changed, 89 insertions(+), 33 deletions(-) diff --git a/src/viced/afsfileprocs.c b/src/viced/afsfileprocs.c index beaea59a2..ce89d8b4b 100644 --- a/src/viced/afsfileprocs.c +++ b/src/viced/afsfileprocs.c @@ -261,7 +261,6 @@ afs_int32 SpareComp(Volume *avolp) } /*SpareComp*/ - /* * Set the volume synchronization parameter for this volume. If it changes, * the Cache Manager knows that the volume must be purged from the stat cache. @@ -375,18 +374,22 @@ retry: } /*CallPreamble*/ -static void CallPostamble(register struct rx_connection *aconn) +static afs_int32 CallPostamble(register struct rx_connection *aconn, + afs_int32 ret) { struct host *thost; struct client *tclient; + int translate = 0; H_LOCK tclient = h_FindClient_r(aconn); thost = tclient->host; + if (thost->hostFlags & HERRORTRANS) translate = 1; h_ReleaseClient_r(tclient); h_Release_r(thost); H_UNLOCK + return (translate ? sys_error_to_et(ret) : ret); } /*CallPostamble*/ /* @@ -2228,7 +2231,7 @@ Bad_FetchData: /* Update and store volume/vnode and parent vnodes back */ PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *)0, volptr); ViceLog(2, ("SRXAFS_FetchData returns %d\n", errorCode)); - CallPostamble(tcon); + errorCode = CallPostamble(tcon, errorCode); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -2385,7 +2388,7 @@ Bad_FetchACL: PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *)0, volptr); ViceLog(2, ("SAFS_FetchACL returns %d (ACL=%s)\n", errorCode, AccessList->AFSOpaque_val)); - CallPostamble(tcon); + errorCode = CallPostamble(tcon, errorCode); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -2599,7 +2602,7 @@ afs_int32 SRXAFS_BulkStatus(struct rx_call *acall, Bad_BulkStatus: /* Update and store volume/vnode and parent vnodes back */ PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *)0, volptr); - CallPostamble(tcon); + errorCode = CallPostamble(tcon, errorCode); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -2755,7 +2758,7 @@ afs_int32 SRXAFS_InlineBulkStatus(struct rx_call *acall, Bad_InlineBulkStatus: /* Update and store volume/vnode and parent vnodes back */ PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *)0, volptr); - CallPostamble(tcon); + errorCode = CallPostamble(tcon, errorCode); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -2815,7 +2818,7 @@ afs_int32 SRXAFS_FetchStatus (struct rx_call *acall, code = SAFSS_FetchStatus (acall, Fid, OutStatus, CallBack, Sync); Bad_FetchStatus: - CallPostamble(tcon); + code = CallPostamble(tcon, code); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -3067,7 +3070,7 @@ Bad_StoreData: PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *)0, volptr); ViceLog(2, ("SAFS_StoreData returns %d\n", errorCode)); - CallPostamble(tcon); + errorCode = CallPostamble(tcon, errorCode); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -3231,7 +3234,7 @@ Bad_StoreACL: /* Update and store volume/vnode and parent vnodes back */ PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *)0, volptr); ViceLog(2, ("SAFS_StoreACL returns %d\n", errorCode)); - CallPostamble(tcon); + errorCode = CallPostamble(tcon, errorCode); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -3371,7 +3374,7 @@ afs_int32 SRXAFS_StoreStatus (struct rx_call *acall, code = SAFSS_StoreStatus (acall, Fid, InStatus, OutStatus, Sync); Bad_StoreStatus: - CallPostamble(tcon); + code = CallPostamble(tcon, code); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -3529,7 +3532,7 @@ afs_int32 SRXAFS_RemoveFile (struct rx_call *acall, code = SAFSS_RemoveFile (acall, DirFid, Name, OutDirStatus, Sync); Bad_RemoveFile: - CallPostamble(tcon); + code = CallPostamble(tcon, code); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -3695,7 +3698,7 @@ afs_int32 SRXAFS_CreateFile (struct rx_call *acall, OutFidStatus, OutDirStatus, CallBack, Sync); Bad_CreateFile: - CallPostamble(tcon); + code = CallPostamble(tcon, code); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -4166,7 +4169,7 @@ afs_int32 SRXAFS_Rename (struct rx_call *acall, OutOldDirStatus, OutNewDirStatus, Sync); Bad_Rename: - CallPostamble(tcon); + code = CallPostamble(tcon, code); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -4365,7 +4368,7 @@ afs_int32 SRXAFS_Symlink (acall, DirFid, Name, LinkContents, InStatus, OutFid, O OutFidStatus, OutDirStatus, Sync); Bad_Symlink: - CallPostamble(tcon); + code = CallPostamble(tcon, code); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -4564,7 +4567,7 @@ afs_int32 SRXAFS_Link (struct rx_call *acall, OutDirStatus, Sync); Bad_Link: - CallPostamble(tcon); + code = CallPostamble(tcon, code); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -4761,7 +4764,7 @@ afs_int32 SRXAFS_MakeDir (struct rx_call *acall, OutFidStatus, OutDirStatus, CallBack, Sync); Bad_MakeDir: - CallPostamble(tcon); + code = CallPostamble(tcon, code); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -4918,7 +4921,7 @@ afs_int32 SRXAFS_RemoveDir (struct rx_call *acall, code = SAFSS_RemoveDir (acall, DirFid, Name, OutDirStatus, Sync); Bad_RemoveDir: - CallPostamble(tcon); + code = CallPostamble(tcon, code); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -5049,7 +5052,7 @@ afs_int32 SRXAFS_SetLock (struct rx_call *acall, code = SAFSS_SetLock (acall, Fid, type, Sync); Bad_SetLock: - CallPostamble(tcon); + code = CallPostamble(tcon, code); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -5171,7 +5174,7 @@ afs_int32 SRXAFS_ExtendLock (struct rx_call *acall, code = SAFSS_ExtendLock (acall, Fid, Sync); Bad_ExtendLock: - CallPostamble(tcon); + code = CallPostamble(tcon, code); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -5303,7 +5306,7 @@ afs_int32 SRXAFS_ReleaseLock (struct rx_call *acall, code = SAFSS_ReleaseLock (acall, Fid, Sync); Bad_ReleaseLock: - CallPostamble(tcon); + code = CallPostamble(tcon, code); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -5430,7 +5433,7 @@ afs_int32 SRXAFS_GetStatistics (struct rx_call *acall, SetSystemStats((struct AFSStatistics *)Statistics); Bad_GetStatistics: - CallPostamble(tcon); + code = CallPostamble(tcon, code); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -5789,7 +5792,7 @@ afs_int32 SRXAFS_GetXStats(struct rx_call *a_call, */ dataBytes = sizeof(struct afs_PerfStats); - dataBuffP = (afs_int32 *)osi_Alloc(dataBytes); + dataBuffP = (afs_int32 *)malloc(dataBytes); memcpy(dataBuffP, &afs_perfstats, dataBytes); a_dataP->AFS_CollData_len = dataBytes>>2; a_dataP->AFS_CollData_val = dataBuffP; @@ -5816,7 +5819,7 @@ afs_int32 SRXAFS_GetXStats(struct rx_call *a_call, */ dataBytes = sizeof(struct fs_stats_FullPerfStats); - dataBuffP = (afs_int32 *)osi_Alloc(dataBytes); + dataBuffP = (afs_int32 *)malloc(dataBytes); memcpy(dataBuffP, &afs_FullPerfStats, dataBytes); a_dataP->AFS_CollData_len = dataBytes>>2; a_dataP->AFS_CollData_val = dataBuffP; @@ -5915,7 +5918,7 @@ static afs_int32 common_GiveUpCallBacks (struct rx_call *acall, } Bad_GiveUpCallBacks: - CallPostamble(tcon); + errorCode = CallPostamble(tcon, errorCode); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -5986,10 +5989,12 @@ afs_int32 SRXAFS_GetCapabilities(struct rx_call *acall, afs_int32 *dataBuffP; afs_int32 dataBytes; + dataBytes = (((CAPABILITY_BITS-1)>>5)+1) * sizeof(afs_int32); dataBuffP = (afs_int32 *)malloc(dataBytes); - memcpy((char *)dataBuffP, "1", dataBytes); + dataBytes = CAPABILITY_ERRORTRANS; capabilities->Capabilities_len = dataBytes/sizeof(afs_int32); capabilities->Capabilities_val = dataBuffP; + return 0; } @@ -6202,7 +6207,7 @@ afs_int32 SRXAFS_GetVolumeInfo (struct rx_call *acall, avolinfo->Type4 = 0xabcd9999; /* tell us to try new vldb */ Bad_GetVolumeInfo: - CallPostamble(tcon); + code = CallPostamble(tcon, code); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -6292,7 +6297,7 @@ Bad_GetVolumeStatus: if (*Name == 0) {*Name = (char *) malloc(1); **Name = 0;} if (*Motd == 0) {*Motd = (char *) malloc(1); **Motd = 0;} if (*OfflineMsg == 0) {*OfflineMsg = (char *) malloc(1); **OfflineMsg = 0;} - CallPostamble(tcon); + errorCode = CallPostamble(tcon, errorCode); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -6383,7 +6388,7 @@ afs_int32 SRXAFS_SetVolumeStatus (struct rx_call *acall, Bad_SetVolumeStatus: PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *)0, volptr); ViceLog(2,("SAFS_SetVolumeStatus returns %d\n",errorCode)); - CallPostamble(tcon); + errorCode = CallPostamble(tcon, errorCode); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -6467,7 +6472,7 @@ afs_int32 SRXAFS_GetRootVolume (struct rx_call *acall, char **VolumeName) *VolumeName = temp; /* freed by rx server-side stub */ Bad_GetRootVolume: - CallPostamble(tcon); + errorCode = CallPostamble(tcon, errorCode); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -6523,7 +6528,7 @@ afs_int32 SRXAFS_CheckToken (struct rx_call *acall, code = FSERR_ECONNREFUSED; Bad_CheckToken: - CallPostamble(tcon); + code = CallPostamble(tcon, code); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -6586,7 +6591,7 @@ afs_int32 SRXAFS_GetTime (struct rx_call *acall, ViceLog(2, ("SAFS_GetTime returns %d, %d\n", *Seconds, *USeconds)); Bad_GetTime: - CallPostamble(tcon); + code = CallPostamble(tcon, code); #if FS_STATS_DETAILED TM_GetTimeOfDay(&opStopTime, 0); @@ -7119,4 +7124,18 @@ StoreData_RXStyle(Volume *volptr, } /*StoreData_RXStyle*/ +static int sys2et[512]; +void init_sys_error_to_et(void) { + int uae = 49733376L; + int uaf = 49733632L; + memset(&sys2et, 0, sizeof(sys2et)); + sys2et[EPERM] = 1 + uae; + sys2et[EEXIST] = 17 + uae; + sys2et[ENOTEMPTY] = 39 + uae; +} + +afs_int32 sys_error_to_et(afs_int32 in) { + if (sys2et[in] != 0) return sys2et[in]; + return in; +} diff --git a/src/viced/host.c b/src/viced/host.c index f85783e67..0c954b4a2 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -930,10 +930,18 @@ struct host *h_GetHost_r(struct rx_connection *tcon) afs_int32 hport; int i, j, count; char hoststr[16], hoststr2[16]; + Capabilities caps; + + caps.Capabilities_val = NULL; haddr = rxr_HostOf(tcon); hport = rxr_PortOf(tcon); retry: + if (caps.Capabilities_val) + free(caps.Capabilities_val); + caps.Capabilities_val = NULL; + caps.Capabilities_len = 0; + code = 0; identP = (struct Identity *)rx_GetSpecific(tcon, rxcon_ident_key); host = h_Lookup_r(haddr, hport, &held); @@ -954,7 +962,10 @@ retry: } host->hostFlags &= ~ALTADDR; H_UNLOCK - code = RXAFSCB_WhoAreYou(host->callback_rxcon, &interf); + code = RXAFSCB_TellMeAboutYourself(host->callback_rxcon, &interf, + &caps); + if ( code == RXGEN_OPCODE ) + code = RXAFSCB_WhoAreYou(host->callback_rxcon, &interf); H_LOCK if ( code == RXGEN_OPCODE ) { identP = (struct Identity *)malloc(sizeof(struct Identity)); @@ -1008,6 +1019,11 @@ retry: hoststr, ntohs(host->port), code)); host->hostFlags |= VENUSDOWN; } + if (caps.Capabilities_val && + (caps.Capabilities_val[0] & CAPABILITY_ERRORTRANS)) + host->hostFlags |= HERRORTRANS; + else + host->hostFlags &= ~(HERRORTRANS); host->hostFlags |= ALTADDR; h_Unlock_r(host); } else if (host) { @@ -1055,7 +1071,10 @@ retry: if (!(host->Console&1)) { if (!identP || !interfValid) { H_UNLOCK - code = RXAFSCB_WhoAreYou(host->callback_rxcon, &interf); + code = RXAFSCB_TellMeAboutYourself(host->callback_rxcon, + &interf, &caps); + if ( code == RXGEN_OPCODE ) + code = RXAFSCB_WhoAreYou(host->callback_rxcon, &interf); H_LOCK if ( code == RXGEN_OPCODE ) { identP = (struct Identity *)malloc(sizeof(struct Identity)); @@ -1129,9 +1148,18 @@ retry: host->hostFlags |= RESETDONE; } + if (caps.Capabilities_val && + (caps.Capabilities_val[0] & CAPABILITY_ERRORTRANS)) + host->hostFlags |= HERRORTRANS; + else + host->hostFlags &= ~(HERRORTRANS); host->hostFlags |= ALTADDR;/* host structure iniatilisation complete */ h_Unlock_r(host); } + if (caps.Capabilities_val) + free(caps.Capabilities_val); + caps.Capabilities_val = NULL; + caps.Capabilities_len = 0; return host; } /*h_GetHost_r*/ diff --git a/src/viced/host.h b/src/viced/host.h index 2c4278fb2..57ff1fc24 100644 --- a/src/viced/host.h +++ b/src/viced/host.h @@ -222,3 +222,4 @@ struct host *(hosttableptrs[h_MAXHOSTTABLES]); /* Used by h_itoh */ #define CLIENTDELETED 0x20 /* client deleted */ #define RESETDONE 0x40 /* callback reset done */ #define HFE_LATER 0x80 /* host has FE_LATER callbacks */ +#define HERRORTRANS 0x100 /* do error translation */ diff --git a/src/viced/viced.c b/src/viced/viced.c index 1bdad874a..f9581a2eb 100644 --- a/src/viced/viced.c +++ b/src/viced/viced.c @@ -1578,6 +1578,7 @@ main(int argc, char * argv[]) if (eventlog) rxevent_debugFile = debugFile; } + init_sys_error_to_et(); /* Set up error table translation */ h_InitHostPackage(); /* set up local cellname and realmname */ InitCallBack(numberofcbs); ClearXStatValues(); diff --git a/src/viced/viced_prototypes.h b/src/viced/viced_prototypes.h index c44475478..d42648017 100644 --- a/src/viced/viced_prototypes.h +++ b/src/viced/viced_prototypes.h @@ -1 +1,8 @@ extern int sendBufSize; +afs_int32 sys_error_to_et(afs_int32 in); +void init_sys_error_to_et(void); + +/* First 32 bits of capabilities */ +#define CAPABILITY_ERRORTRANS (1<<1) + +#define CAPABILITY_BITS 1 -- 2.39.5