chromium/sql/vfs_wrapper.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "sql/vfs_wrapper.h"

#include <cstring>
#include <functional>
#include <memory>
#include <string_view>

#include "base/check.h"
#include "base/check_op.h"
#include "base/debug/leak_annotations.h"
#include "base/metrics/histogram_macros.h"
#include "build/build_config.h"
#include "third_party/sqlite/sqlite3.h"

#if BUILDFLAG(IS_APPLE)
#include "base/apple/backup_util.h"
#include "base/files/file_util.h"
#endif

#if BUILDFLAG(IS_FUCHSIA)
#include "sql/vfs_wrapper_fuchsia.h"
#endif

namespace sql {
namespace {

// https://www.sqlite.org/vfs.html - documents the overall VFS system.
//
// https://www.sqlite.org/c3ref/vfs.html - VFS methods.  This code tucks the
// wrapped VFS pointer into the wrapper's pAppData pointer.
//
// https://www.sqlite.org/c3ref/file.html - instance of an open file.  This code
// allocates a VfsFile for this, which contains a pointer to the wrapped file.
// Idiomatic SQLite would take the wrapped VFS szOsFile and increase it to store
// additional data as a prefix.

sqlite3_vfs* GetWrappedVfs(sqlite3_vfs* wrapped_vfs) {}

VfsFile* AsVfsFile(sqlite3_file* wrapper_file) {}

sqlite3_file* GetWrappedFile(sqlite3_file* wrapper_file) {}

int Close(sqlite3_file* sqlite_file) {}

int Read(sqlite3_file* sqlite_file, void* buf, int amt, sqlite3_int64 ofs)
{}

int Write(sqlite3_file* sqlite_file, const void* buf, int amt,
          sqlite3_int64 ofs)
{}

int Truncate(sqlite3_file* sqlite_file, sqlite3_int64 size)
{}

int Sync(sqlite3_file* sqlite_file, int flags)
{}

int FileSize(sqlite3_file* sqlite_file, sqlite3_int64* size)
{}

#if !BUILDFLAG(IS_FUCHSIA)

int Lock(sqlite3_file* sqlite_file, int file_lock)
{}

int Unlock(sqlite3_file* sqlite_file, int file_lock)
{}

int CheckReservedLock(sqlite3_file* sqlite_file, int* result)
{}

#endif  // !BUILDFLAG(IS_FUCHSIA)
// Else these functions are imported via vfs_wrapper_fuchsia.h.

int FileControl(sqlite3_file* sqlite_file, int op, void* arg)
{}

int SectorSize(sqlite3_file* sqlite_file)
{}

int DeviceCharacteristics(sqlite3_file* sqlite_file)
{}

int ShmMap(sqlite3_file *sqlite_file, int region, int size,
           int extend, void volatile **pp) {}

int ShmLock(sqlite3_file *sqlite_file, int ofst, int n, int flags) {}

void ShmBarrier(sqlite3_file *sqlite_file) {}

int ShmUnmap(sqlite3_file *sqlite_file, int del) {}

int Fetch(sqlite3_file *sqlite_file, sqlite3_int64 off, int amt, void **pp) {}

int Unfetch(sqlite3_file *sqlite_file, sqlite3_int64 off, void *p) {}

int Open(sqlite3_vfs* vfs, const char* file_name, sqlite3_file* wrapper_file,
         int desired_flags, int* used_flags) {}

int Delete(sqlite3_vfs* vfs, const char* file_name, int sync_dir) {}

int Access(sqlite3_vfs* vfs, const char* file_name, int flag, int* res) {}

int FullPathname(sqlite3_vfs* vfs, const char* relative_path,
                 int buf_size, char* absolute_path) {}

int Randomness(sqlite3_vfs* vfs, int buf_size, char* buffer) {}

int Sleep(sqlite3_vfs* vfs, int microseconds) {}

int GetLastError(sqlite3_vfs* vfs, int e, char* s) {}

int CurrentTimeInt64(sqlite3_vfs* vfs, sqlite3_int64* now) {}

}  // namespace

void EnsureVfsWrapper() {}

}  // namespace sql