-/*
- * return data to the caller. Results unpredictable.
- */
-int random_read(__unused dev_t dev, struct uio *uio, __unused int ioflag)
-{
- int retCode = 0;
-
- if (gRandomError != 0)
- return (ENOTSUP);
-
- /* lock down the mutex */
- mutex_lock(gYarrowMutex);
-
- int bytes_remaining = uio_resid(uio);
- while (bytes_remaining > 0 && retCode == 0) {
- /* get the user's data */
- int bytes_to_read = 0;
-
- int bytes_available = kBSizeInBytes - g_bytes_used;
- if (bytes_available == 0)
- {
- random_block(g_random_data);
- g_bytes_used = 0;
- bytes_available = kBSizeInBytes;
- }
-
- bytes_to_read = min (bytes_remaining, bytes_available);
-
- retCode = uiomove(((u_int8_t*)g_random_data)+ g_bytes_used, bytes_to_read, uio);
- g_bytes_used += bytes_to_read;
-
- if (retCode != 0)
- goto error_exit;
-
- bytes_remaining = uio_resid(uio);
- }
-
- retCode = 0;
-
-error_exit:
- mutex_unlock(gYarrowMutex);
- return retCode;
-}