From b56330de8eb15dd34fb002d1236f948c9922d6bb Mon Sep 17 00:00:00 2001 From: Pawel Dziepak Date: Thu, 11 Apr 2013 04:28:14 +0200 Subject: [PATCH] nfs4: let nfs4 use kernel utils for random numbers --- src/add-ons/kernel/file_systems/nfs4/Connection.cpp | 5 +++-- src/add-ons/kernel/file_systems/nfs4/FileSystem.cpp | 5 ++--- src/add-ons/kernel/file_systems/nfs4/RPCServer.cpp | 3 ++- src/add-ons/kernel/file_systems/nfs4/RequestBuilder.cpp | 5 +++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/add-ons/kernel/file_systems/nfs4/Connection.cpp b/src/add-ons/kernel/file_systems/nfs4/Connection.cpp index 5994b51eee..2fa044d3f7 100644 --- a/src/add-ons/kernel/file_systems/nfs4/Connection.cpp +++ b/src/add-ons/kernel/file_systems/nfs4/Connection.cpp @@ -16,8 +16,9 @@ #include #include -#include #include +#include +#include #define NFS4_PORT 2049 @@ -655,7 +656,7 @@ Connection::Connect() PeerAddress address(fPeerAddress.Family()); do { - port = rand() % (IPPORT_RESERVED - NFS_MIN_PORT); + port = get_random() % (IPPORT_RESERVED - NFS_MIN_PORT); port += NFS_MIN_PORT; if (attempt == 9) diff --git a/src/add-ons/kernel/file_systems/nfs4/FileSystem.cpp b/src/add-ons/kernel/file_systems/nfs4/FileSystem.cpp index c1a5a7b9ad..184e79a373 100644 --- a/src/add-ons/kernel/file_systems/nfs4/FileSystem.cpp +++ b/src/add-ons/kernel/file_systems/nfs4/FileSystem.cpp @@ -13,6 +13,7 @@ #include #include +#include #include "Request.h" #include "RootInode.h" @@ -32,9 +33,7 @@ FileSystem::FileSystem(const MountConfiguration& configuration) fId(1), fConfiguration(configuration) { - fOpenOwner = rand(); - fOpenOwner <<= 32; - fOpenOwner |= rand(); + fOpenOwner = get_random(); mutex_init(&fOpenOwnerLock, NULL); mutex_init(&fOpenLock, NULL); diff --git a/src/add-ons/kernel/file_systems/nfs4/RPCServer.cpp b/src/add-ons/kernel/file_systems/nfs4/RPCServer.cpp index 7190fee8db..fc5cb132a1 100644 --- a/src/add-ons/kernel/file_systems/nfs4/RPCServer.cpp +++ b/src/add-ons/kernel/file_systems/nfs4/RPCServer.cpp @@ -12,6 +12,7 @@ #include #include +#include #include "RPCCallbackServer.h" #include "RPCReply.h" @@ -83,7 +84,7 @@ Server::Server(Connection* connection, PeerAddress* address) fPrivateData(NULL), fCallback(NULL), fRepairCount(0), - fXID(rand() << 1) + fXID(get_random()) { ASSERT(connection != NULL); ASSERT(address != NULL); diff --git a/src/add-ons/kernel/file_systems/nfs4/RequestBuilder.cpp b/src/add-ons/kernel/file_systems/nfs4/RequestBuilder.cpp index f900b846ae..e518f86681 100644 --- a/src/add-ons/kernel/file_systems/nfs4/RequestBuilder.cpp +++ b/src/add-ons/kernel/file_systems/nfs4/RequestBuilder.cpp @@ -12,6 +12,8 @@ #include #include +#include + #include "Cookie.h" #include "OpenState.h" #include "RPCCallback.h" @@ -659,8 +661,7 @@ RequestBuilder::SetClientID(RPC::Server* server) return B_NO_MEMORY; fRequest->Stream().AddUInt(OpSetClientID); - uint64 verifier = rand(); - verifier = verifier << 32 | rand(); + uint64 verifier = get_random(); fRequest->Stream().AddUHyper(verifier); status_t result = _GenerateClientId(fRequest->Stream(), server);