static void list_sems(team_info *tinfo) { sem_info info; int32 cookie = 0; print_header(tinfo); while (get_next_sem_info(tinfo->team, &cookie, &info) == B_OK) print_sem_info(&info); printf("\n"); }
fssh_status_t _fssh_get_next_sem_info(fssh_team_id team, int32_t *cookie, struct fssh_sem_info *info, fssh_size_t infoSize) { sem_info systemInfo; status_t result = get_next_sem_info(team, (int32*)cookie, &systemInfo); if (result != B_OK) return result; copy_sem_info(info, &systemInfo); return FSSH_B_OK; }
status_t LocalDebuggerInterface::GetSemaphoreInfos(BObjectList<SemaphoreInfo>& infos) { // get the team's semaphores sem_info semInfo; int32 cookie = 0; while (get_next_sem_info(fTeamID, &cookie, &semInfo) == B_OK) { SemaphoreInfo* info = new(std::nothrow) SemaphoreInfo(fTeamID, semInfo.sem, semInfo.name, semInfo.count, semInfo.latest_holder); if (info == NULL || !infos.AddItem(info)) { delete info; return B_NO_MEMORY; } } return B_OK; }
/** * BeOS entropy poll */ void BeOS_EntropySource::poll(Entropy_Accumulator& accum) { system_info info_sys; get_system_info(&info_sys); accum.add(info_sys, BOTAN_ENTROPY_ESTIMATE_SYSTEM_DATA); key_info info_key; // current state of the keyboard get_key_info(&info_key); accum.add(info_key, BOTAN_ENTROPY_ESTIMATE_SYSTEM_DATA); team_info info_team; int32 cookie_team = 0; while(get_next_team_info(&cookie_team, &info_team) == B_OK) { accum.add(info_team, BOTAN_ENTROPY_ESTIMATE_SYSTEM_DATA); team_id id = info_team.team; int32 cookie = 0; thread_info info_thr; while(get_next_thread_info(id, &cookie, &info_thr) == B_OK) accum.add(info_thr, BOTAN_ENTROPY_ESTIMATE_SYSTEM_DATA); cookie = 0; image_info info_img; while(get_next_image_info(id, &cookie, &info_img) == B_OK) accum.add(info_img, BOTAN_ENTROPY_ESTIMATE_SYSTEM_DATA); cookie = 0; sem_info info_sem; while(get_next_sem_info(id, &cookie, &info_sem) == B_OK) accum.add(info_sem, BOTAN_ENTROPY_ESTIMATE_SYSTEM_DATA); cookie = 0; area_info info_area; while(get_next_area_info(id, &cookie, &info_area) == B_OK) accum.add(info_area, BOTAN_ENTROPY_ESTIMATE_SYSTEM_DATA); if(accum.polling_finished()) break; } }
void slowPoll( void ) { RANDOM_STATE randomState; BYTE buffer[ RANDOM_BUFSIZE + 8 ]; key_info keyInfo; team_info teami; thread_info threadi; area_info areai; port_info porti; sem_info semi; image_info imagei; double temperature; int32 devID, cookie; int fd, value; if( ( fd = open( "/dev/urandom", O_RDONLY ) ) >= 0 ) { MESSAGE_DATA msgData; BYTE buffer[ ( DEVRANDOM_BITS / 8 ) + 8 ]; static const int quality = 100; /* Read data from /dev/urandom, which won't block (although the quality of the noise is lesser). */ read( fd, buffer, DEVRANDOM_BITS / 8 ); setMessageData( &msgData, buffer, DEVRANDOM_BITS / 8 ); krnlSendMessage( SYSTEM_OBJECT_HANDLE, IMESSAGE_SETATTRIBUTE_S, &msgData, CRYPT_IATTRIBUTE_ENTROPY ); zeroise( buffer, DEVRANDOM_BITS / 8 ); close( fd ); krnlSendMessage( SYSTEM_OBJECT_HANDLE, IMESSAGE_SETATTRIBUTE, ( MESSAGE_CAST ) &quality, CRYPT_IATTRIBUTE_ENTROPY_QUALITY ); return; } initRandomData( randomState, buffer, RANDOM_BUFSIZE ); /* Get the state of all keys on the keyboard and various other system states */ #if 0 /* See comment at start */ if( get_key_info( &keyInfo ) == B_NO_ERROR ) addRandomData( randomState, &keyInfo, sizeof( key_info ) ); #endif /* 0 */ value = is_computer_on(); /* Returns 1 if computer is on */ addRandomValue( randomState, value ); temperature = is_computer_on_fire(); /* MB temp.if on fire */ addRandomData( randomState, &temperature, sizeof( double ) ); /* Get information on all running teams (thread groups, ie applications). This returns the team ID, number of threads, images, and areas, debugger port and thread ID, program args, and uid and gid */ cookie = 0; while( get_next_team_info( &cookie, &teami ) == B_NO_ERROR ) addRandomData( randomState, &teami, sizeof( teami ) ); /* Get information on all running threads. This returns the thread ID, team ID, thread name and state (eg running, suspended, asleep, blocked), the thread priority, elapsed user and kernel time, and thread stack information */ cookie = 0; while( get_next_thread_info( 0, &cookie, &threadi ) == B_NO_ERROR ) { addRandomValue( randomState, has_data( threadi.thread ) ); addRandomData( randomState, &threadi, sizeof( threadi ) ); } /* Get information on all memory areas (chunks of virtual memory). This returns the area ID, name, size, locking scheme and protection bits, ID of the owning team, start address, number of resident bytes, copy- on-write count, an number of pages swapped in and out */ cookie = 0; while( get_next_area_info( 0, &cookie, &areai ) == B_NO_ERROR ) addRandomData( randomState, &areai, sizeof( areai ) ); /* Get information on all message ports. This returns the port ID, ID of the owning team, message queue length, number of messages in the queue, and total number of messages processed */ cookie = 0; while( get_next_port_info( 0, &cookie, &porti ) == B_NO_ERROR ) addRandomData( randomState, &porti, sizeof( porti ) ); /* Get information on all semaphores. This returns the semaphore and owning team ID, the name, thread count, and the ID of the last thread which acquired the semaphore */ cookie = 0; while( get_next_sem_info( 0, &cookie, &semi ) == B_NO_ERROR ) addRandomData( randomState, &semi, sizeof( semi ) ); /* Get information on all images (code blocks, eg applications, shared libraries, and add-on images (DLL's on steroids). This returns the image ID and type (app, library, or add-on), the order in which the image was loaded compared to other images, the address of the init and shutdown routines, the device and node where the image lives, and the image text and data sizes) */ cookie = 0; while( get_next_image_info( 0, &cookie, &imagei ) == B_NO_ERROR ) addRandomData( randomState, &imagei, sizeof( imagei ) ); /* Get information on all storage devices. This returns the device number, root inode, various device parameters such as I/O block size, and the number of free and used blocks and inodes */ devID = 0; while( next_dev( &devID ) >= 0 ) { fs_info fsInfo; if( fs_stat_dev( devID, &fsInfo ) == B_NO_ERROR ) addRandomData( randomState, &fsInfo, sizeof( fs_info ) ); } /* Flush any remaining data through */ endRandomData( randomState, 100 ); }