/* * This class is intended to be the interface to the sqlite DB. It can be created once in the * applicationm, and can then be used in all threads, as sqlite claims to be thread-safe in * "serialized" mode (which is the default, http://sqlite.org/threadsafe.html). */ #ifndef FSCKDB_H_ #define FSCKDB_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include class FsckDBDentryTable; class FsckDBFileInodesTable; class FsckDBDirInodesTable; class FsckDBChunksTable; class FsckDBContDirsTable; class FsckDBFsIDsTable; class FsckDBUsedTargetIDsTable; class FsckDBModificationEventsTable; class FsckDBDentryErrorTable; class FsckDBDirInodeErrorTable; class FsckDBFsIDErrorTable; class FsckDBFileInodeErrorTable; class FsckDBChunkErrorTable; class FsckDBContDirErrorTable; class FsckDBStripeTargetErrorTable; namespace checks { struct InodeAttribs { uint64_t size; uint64_t nlinks; }; struct OptionalInodeAttribs { boost::optional size; boost::optional nlinks; void reset() { size.reset(); nlinks.reset(); } }; typedef std::pair> DuplicatedInode; } class FsckDB { friend class TestDatabase; public: // FsckDB.cpp FsckDB(const std::string& databasePath, size_t fragmentSize, size_t nameCacheLimit, bool allowCreate); void clear(); // FsckDBChecks.cpp Cursor findDuplicateInodeIDs(); Cursor > findDuplicateChunks(); Cursor> findDuplicateContDirs(); Cursor findMismirroredDentries(); Cursor findMismirroredDirectories(); Cursor findMismirroredFiles(); Cursor findDanglingDirEntries(); Cursor findDirEntriesWithBrokenByIDFile(); Cursor findOrphanedFsIDFiles(); Cursor findInodesWithWrongOwner(); Cursor > findDirEntriesWithWrongOwner(); Cursor findOrphanedDirInodes(); Cursor findOrphanedFileInodes(); Cursor findOrphanedChunks(); Cursor findInodesWithoutContDir(); Cursor findOrphanedContDirs(); Cursor > findWrongInodeFileAttribs(); Cursor > findWrongInodeDirAttribs(); Cursor findFilesWithMissingStripeTargets(TargetMapper* targetMapper, MirrorBuddyGroupMapper* buddyGroupMapper); Cursor > findChunksWithWrongPermissions(); Cursor > findChunksInWrongPath(); Cursor findFilesWithMultipleHardlinks(); private: LogContext log; std::string databasePath; boost::scoped_ptr dentryTable; boost::scoped_ptr fileInodesTable; boost::scoped_ptr dirInodesTable; boost::scoped_ptr chunksTable; boost::scoped_ptr contDirsTable; boost::scoped_ptr fsIDsTable; boost::scoped_ptr usedTargetIDsTable; boost::scoped_ptr modificationEventsTable; DiskList malformedChunks; public: FsckDBDentryTable* getDentryTable() { return this->dentryTable.get(); } FsckDBFileInodesTable* getFileInodesTable() { return this->fileInodesTable.get(); } FsckDBDirInodesTable* getDirInodesTable() { return this->dirInodesTable.get(); } FsckDBChunksTable* getChunksTable() { return this->chunksTable.get(); } FsckDBContDirsTable* getContDirsTable() { return this->contDirsTable.get(); } FsckDBFsIDsTable* getFsIDsTable() { return this->fsIDsTable.get(); } FsckDBUsedTargetIDsTable* getUsedTargetIDsTable() { return this->usedTargetIDsTable.get(); } FsckDBModificationEventsTable* getModificationEventsTable() { return this->modificationEventsTable.get(); } DiskList* getMalformedChunksList() { return &malformedChunks; } }; #endif /* FSCKDB_H_ */