/* * EvGetEventClassName() finds the class name string associated with an event * class ID. This function works only locally because all event classes * should be known locally. * * If the event group cound not be found -EEXIST will be returned. If * the class identified by className is not registered the -ESRCH will * be returned. Else "class" will be filled with the unique class * ID assiged to className and a zero will be returned to indicates * success. */ int EvGetEventClassName(EvGroupID_t groupID, EvClassID_t classID, char *className) { EvGroupInfo_t *EGroup; EvClassInfo_t *HashBase; unsigned long Flags; int RetVal; /* Get the group info pointer and return with it locked. */ if ((RetVal = EvLockAndGetGroup(groupID, EV_ACCESS_IGNORE, EAC_NONE, &Flags, EV_LOCK_GROUP_READ, &EGroup))) { return RetVal; } HashBase = EvGetHashBase(EGroup, classID); while (HashBase->EciNext) { if (HashBase->EciClass == classID) { strncpy(className, HashBase->EciName, 16); read_unlock_irqrestore(&EGroup->EgiLock, Flags); return EV_NOERR; } HashBase = HashBase->EciNext; } read_unlock_irqrestore(&EGroup->EgiLock, Flags); return -EV_ERROR_CLASS_EXISTS; }
/* * EvUnRegisterEventClass() removes an event class from the list * of known event classes. If this is a local event group then * it is removed only locally. If this is a member of an event * group then a notices is sent to the master to remove the event * class. If the master indicates it is OK then the class is removed * locally. * * If this is an event master and every thing is OK locally then * the event class is removes locally and the members are informed * to remove it also. */ int EvUnRegisterEventClass(EvGroupID_t groupID, EvClassID_t classID, EvAccess_t accessCode) { EvGroupInfo_t *EGroup; unsigned long Flags; int RetVal; /* Get the group info pointer and return with it locked. */ if ((RetVal = EvLockAndGetGroup(groupID, EV_ACCESS_IGNORE, EAC_NONE, &Flags, EV_LOCK_GROUP_WRITE, &EGroup))) { return RetVal; } /* If this is a Member send remove request to master. */ if (EGroup->EgiType == EG_MEMBER) { if ((RetVal = EvSendUnRegEventClass(EGroup, accessCode, classID, &Flags)) < 0) { write_unlock_irqrestore(&EGroup->EgiLock, Flags); return RetVal; } } RetVal = EvInternalUnRegisterEventClass(EGroup, classID, accessCode); write_unlock_irqrestore(&EGroup->EgiLock, Flags); return RetVal; }
int EvSyncToMember(EvGroupID_t groupID, EvAccess_t accessCode, EvGroupID_t memberID) { EvGroupInfo_t *EGroup; EvClassInfo_t *HashBase; unsigned long Flags; int Hash; int RetVal; /* Get the group info pointer and return with it locked. */ if ((RetVal = EvLockAndGetGroup(groupID, EV_ACCESS_CHECK, accessCode, &Flags, EV_LOCK_GROUP_READ, &EGroup))) { return RetVal; } /* If this a remote gen to the master then echo it back to * all members. */ if (EGroup->EgiType != EG_MASTER) { read_unlock_irqrestore(&EGroup->EgiLock, Flags); return EV_ERROR_GROUP_TYPE; } for (Hash = 0; Hash < EGroup->EgiHashSize; Hash++) { HashBase = &EGroup->EgiClassHash[Hash]; while (HashBase->EciNext != NULL) { if (HashBase->EciClass == EV_CONTROL_CLASS_ID) { HashBase = HashBase->EciNext; continue; } RetVal = EvGroupSendEvent(0, 0, EGroup->EgiID, memberID, -1, EV_CONTROL_CLASS_ID, EV_MASTER_REG_EVENT_CLASS, accessCode, HashBase->EciAccessCode, HashBase->EciClass, 0, &EGroup->EgiGroupDest, strlen(HashBase->EciName) + 1, HashBase->EciName); if (RetVal) { read_unlock_irqrestore(&EGroup->EgiLock, Flags); return RetVal; } HashBase = HashBase->EciNext; } } read_unlock_irqrestore(&EGroup->EgiLock, Flags); return EV_NOERR; }
/* * EvGetEventClassID() finds the ID associated with an event class name * passed in className. This function works only locally because * all event classes should be known locally. * * If the event group cound not be found -EEXIST will be returned. If * the class identified by className is not registered the -ESRCH will * be returned. Else "class" will be filled with the unique class * ID assiged to className and a zero will be returned to indicates * success. */ int EvGetEventClassID(EvGroupID_t groupID, char *className, EvClassID_t *classID) { EvGroupInfo_t *EGroup; unsigned long Flags; int RetVal; /* Get the group info pointer and return with it locked. */ if ((RetVal = EvLockAndGetGroup(groupID, EV_ACCESS_IGNORE, EAC_NONE, &Flags, EV_LOCK_GROUP_READ, &EGroup))) { return RetVal; } RetVal = EvCheckEventClass(EGroup, className, classID); read_unlock_irqrestore(&EGroup->EgiLock, Flags); return RetVal; }
/* * EvGetUserID() returns the user ID associated with the name string * passed into the register user function. * * If the group ID identifies a group of events that are local or this * system is the master controler or the member ID is this system then it * searches the local systems users for the specified name. Otherwise * a request for the information is sent to the remote system. * * If groupID does not specify a known group then -EEXIST is returned. IF * userName is not found in the correct list the -ESRCH is returned. * Otherwise a 0 is returned and userID contains the associated unique * user ID. */ int EvGetUserID(EvGroupID_t groupID, EvGroupID_t memberID, char *userName, EvUserID_t *userID) { EvKernelInfo_t *TmpUser; EvGroupInfo_t *EGroup; unsigned long Flags; int RetVal; /* Get the group info pointer and return with it locked. */ if ((RetVal = EvLockAndGetGroup(groupID, EV_ACCESS_IGNORE, EAC_NONE, &Flags, EV_LOCK_GROUP_WRITE, &EGroup))) { return RetVal; } /* If the memberID passed in does not match this system then send * a message to the master to retieve and return it. */ if ((EGroup->EgiType != EG_LOCAL)&&(EGroup->EgiMemberID != memberID)) { RetVal = EvSendGetUserID(groupID, memberID, userName, userID); write_unlock_irqrestore(&EGroup->EgiLock, Flags); return RetVal; } /* Get the user ID from this system. */ read_lock(&EvUsersLock); write_unlock(&EGroup->EgiLock); TmpUser = EvUsersHead; while (TmpUser) { if (!strcmp(TmpUser->EkiName, userName)) { *userID = TmpUser->EkiID; read_unlock_irqrestore(&EvUsersLock, Flags); return EV_NOERR; } TmpUser = TmpUser->EkiNext; } read_unlock_irqrestore(&EvUsersLock, Flags); return -EV_ERROR_USER_EXISTS; }
/* * EventGetUserName() returns the user name string associated with the * Ruser ID returned from the register user function. * * If the group ID identifies a group of events that are local or this * system is the master controler or the member ID is this system then it * searches the local systems users for the specified ID. Otherwise * a request for the information is sent to the remote system. * * If groupID does not specify a known group then -EEXIST is returned. IF * userName is not found in the correct list the -ESRCH is returned. * Otherwise a 0 is returned and userID contains the associated unique * user ID. */ int EvGetUserName(EvGroupID_t groupID, EvGroupID_t memberID, EvUserID_t userID, char *userName) { EvGroupInfo_t *EGroup; EvKernelInfo_t *TmpUser; unsigned long Flags; int RetVal; /* Get the group info pointer and return with it locked. */ if ((RetVal = EvLockAndGetGroup(groupID, EV_ACCESS_IGNORE, EAC_NONE, &Flags, EV_LOCK_GROUP_WRITE, &EGroup))) { return RetVal; } if ((EGroup->EgiType == EG_MEMBER)&&(EGroup->EgiMemberID != memberID)) { RetVal = EvSendGetUserName(EGroup, memberID, userID, userName, &Flags); write_unlock_irqrestore(&EGroup->EgiLock, Flags); return RetVal; } read_lock(&EvUsersLock); write_unlock(&EGroup->EgiLock); TmpUser = EvUsersHead; while (TmpUser) { if (TmpUser->EkiID == userID) { strncpy(userName, TmpUser->EkiName, 16); read_unlock_irqrestore(&EvUsersLock, Flags); return 0; } TmpUser = TmpUser->EkiNext; } read_unlock_irqrestore(&EvUsersLock, Flags); return -EV_ERROR_USER_EXISTS; }
/* * The EvRegisterEventClass() function registers the className string as the * identifier of an event class and returns a unique token to identify that * class. The class is created as a part of an event group. * * If the event group is local then the event class is created as a part * of the local events and can be used only on the registering system. If * this system is the master for an event group then a local identity is * created on this system and notification is sent to remote systems to * inidcate this event has been created. If this event group is a member * on this system then the master is told to register this event class and * return the class ID and then a local copy of the registeration is made. * * If the event group defined by groupID does not exist then -EEXIST is * returned and no class is registered. If the event class defined by * className already exists -EBUSY is returned and not class is registered. * returned. If the kernel could not allocate enough memory for the * controling data structures -ENOSPC is returned and not class is * registered. Otherwise the class identified by className is registered, * a unique ID is allocated and placed in the class parameter and a * zero is returned to indicate success. */ int EvRegisterEventClass(EvGroupID_t groupID, char *className, EvAccess_t groupAccessCode, EvAccess_t classAccessCode, EvClassID_t *classID) { EvGroupInfo_t *EGroup; EvClassInfo_t *HashBase; unsigned long Flags; int RetVal; /* Get the group info pointer and return with it locked. */ if ((RetVal = EvLockAndGetGroup(groupID, EV_ACCESS_CHECK, groupAccessCode, &Flags, EV_LOCK_GROUP_WRITE, &EGroup))) { return RetVal; } /* Check to see if the class already exists */ if (EvCheckEventClass(EGroup, className, classID) > -1) { write_unlock_irqrestore(&EGroup->EgiLock, Flags); return -EV_ERROR_CLASS_EXISTS; } /* If the event class is not a local one then send a register to * the remote master. The remote master returns the class ID. */ if ((EGroup->EgiType == EG_MEMBER) && EGroup->EgiNextClass) { if ((RetVal = EvSendRegEventClass(EGroup, className, groupAccessCode, classAccessCode, classID, &Flags)) < 0) { write_unlock_irqrestore(&EGroup->EgiLock, Flags); return RetVal; } } else { /* Class is locally assigned */ *classID = EGroup->EgiNextClass++; /* If this is an event master then send class create event. */ if (EGroup->EgiType == EG_MASTER) { if ((RetVal = EvSendRegClassToMembers(EGroup, className, groupAccessCode, classAccessCode, *classID))) { write_unlock_irqrestore(&EGroup->EgiLock, Flags); return RetVal; } } } HashBase = EvGetHashBase(EGroup, *classID); while (HashBase->EciNext != NULL) { HashBase = HashBase->EciNext; } RetVal=EvFillInHashInfo(HashBase, classAccessCode, className, classID); EGroup->EgiUseCount++; write_unlock_irqrestore(&EGroup->EgiLock, Flags); return RetVal; }
int EvSendGetUserID(EvGroupID_t groupID, EvGroupID_t memberID, char *userName, EvUserID_t *userID) { EvGroupInfo_t *EGroup; EvPendRem_t *Pend; unsigned long Flags; int RetVal; /* Get the group info pointer and return with it locked. */ if ((RetVal = EvLockAndGetGroup(groupID, EV_ACCESS_IGNORE, EAC_NONE, &Flags, EV_LOCK_GROUP_WRITE, &EGroup))) { return RetVal; } /* Check to see if there is a remote control entity registered. */ if (EGroup->EgiGroupDest.EdID == 0) { write_unlock_irqrestore(&EGroup->EgiLock, Flags); return -EV_ERROR_NO_REMOTE; } /* Allocate an entry to pend on while remote request is processed. */ if ((Pend = EvGetPendEntry(EGroup, EV_REM_GET_USER_ID, memberID, 0, 0, 0, strlen(userName) + 1, userName)) == NULL) { write_unlock_irqrestore(&EGroup->EgiLock, Flags); return -EV_ERROR_MEM_ALLOC; } /* Send the reqest to the waiting control agent. */ RetVal = EvGroupSendEvent(0, 0, EGroup->EgiID, EGroup->EgiMemberID, -1, EV_CONTROL_CLASS_ID, EV_REM_GET_USER_ID, memberID, 0, 0, 0, &EGroup->EgiGroupDest, strlen(userName) + 1, userName); if (RetVal) { EvDelPendEntry(EGroup, Pend); write_unlock_irqrestore(&EGroup->EgiLock, Flags); return RetVal; } /* Make sure group cannont be removed and Wait for information * to be returned. */ EGroup->EgiUseCount++; write_unlock_irqrestore(&EGroup->EgiLock, Flags); interruptible_sleep_on(&Pend->PrWaitQ); /* Reaquire the load and releas the group use count to allow other * group activities. */ write_lock_irqsave(&EGroup->EgiLock, Flags); EGroup->EgiUseCount--; /* If an error has been indicated then return it. */ RetVal = Pend->PrRetInfo.EpInfo[0]; if (RetVal) { /* Free the Pend data structure. */ EvDelPendEntry(EGroup, Pend); write_unlock_irqrestore(&EGroup->EgiLock, Flags); return -RetVal; } /* Fill in user userID information. */ *userID = Pend->PrRetInfo.EpInfo[1]; /* Free the Pend data structure. */ EvDelPendEntry(EGroup, Pend); write_unlock_irqrestore(&EGroup->EgiLock, Flags); return EV_NOERR; }