Botan  1.11.15
src/lib/entropy/proc_walk/proc_walk.h
Go to the documentation of this file.
00001 /*
00002 * File Tree Walking EntropySource
00003 * (C) 1999-2008 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_ENTROPY_SRC_PROC_WALK_H__
00009 #define BOTAN_ENTROPY_SRC_PROC_WALK_H__
00010 
00011 #include <botan/entropy_src.h>
00012 #include <mutex>
00013 
00014 namespace Botan {
00015 
00016 class File_Descriptor_Source
00017    {
00018    public:
00019       virtual int next_fd() = 0;
00020       virtual ~File_Descriptor_Source() {}
00021    };
00022 
00023 /**
00024 * File Tree Walking Entropy Source
00025 */
00026 class ProcWalking_EntropySource : public EntropySource
00027    {
00028    public:
00029       std::string name() const { return "Proc Walker"; }
00030 
00031       void poll(Entropy_Accumulator& accum);
00032 
00033       ProcWalking_EntropySource(const std::string& root_dir) :
00034          m_path(root_dir), m_dir(nullptr) {}
00035 
00036    private:
00037       const std::string m_path;
00038       std::mutex m_mutex;
00039       std::unique_ptr<File_Descriptor_Source> m_dir;
00040    };
00041 
00042 }
00043 
00044 #endif