chromium/sql/sandboxed_vfs_file.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "sql/sandboxed_vfs_file.h"

#include <atomic>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <type_traits>
#include <utility>

#include "base/check.h"
#include "base/check_op.h"
#include "base/dcheck_is_on.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/notreached.h"
#include "build/build_config.h"
#include "sql/sandboxed_vfs.h"
#include "third_party/sqlite/sqlite3.h"

namespace sql {

namespace {

int SandboxedClose(sqlite3_file* file) {}
int SandboxedRead(sqlite3_file* file,
                  void* buffer,
                  int size,
                  sqlite3_int64 offset) {}
int SandboxedWrite(sqlite3_file* file,
                   const void* buffer,
                   int size,
                   sqlite3_int64 offset) {}
int SandboxedTruncate(sqlite3_file* file, sqlite3_int64 size) {}
int SandboxedSync(sqlite3_file* file, int flags) {}
int SandboxedFileSize(sqlite3_file* file, sqlite3_int64* result_size) {}
int SandboxedLock(sqlite3_file* file, int mode) {}
int SandboxedUnlock(sqlite3_file* file, int mode) {}
int SandboxedCheckReservedLock(sqlite3_file* file, int* has_reserved_lock) {}
int SandboxedFileControl(sqlite3_file* file, int opcode, void* data) {}
int SandboxedSectorSize(sqlite3_file* file) {}
int SandboxedDeviceCharacteristics(sqlite3_file* file) {}
int SandboxedShmMap(sqlite3_file* file,
                    int page_index,
                    int page_size,
                    int extend_file_if_needed,
                    void volatile** result) {}
int SandboxedShmLock(sqlite3_file* file, int offset, int size, int flags) {}
void SandboxedShmBarrier(sqlite3_file* file) {}
int SandboxedShmUnmap(sqlite3_file* file, int also_delete_file) {}
int SandboxedFetch(sqlite3_file* file,
                   sqlite3_int64 offset,
                   int size,
                   void** result) {}
int SandboxedUnfetch(sqlite3_file* file,
                     sqlite3_int64 offset,
                     void* fetch_result) {}

const sqlite3_io_methods* GetSqliteIoMethods() {}

}  // namespace

// static
void SandboxedVfsFile::Create(base::File file,
                              base::FilePath file_path,
#if DCHECK_IS_ON()
                              SandboxedVfsFileType file_type,
#endif  // DCHECK_IS_ON()
                              SandboxedVfs* vfs,
                              sqlite3_file& buffer) {}

// static
SandboxedVfsFile& SandboxedVfsFile::FromSqliteFile(sqlite3_file& sqlite_file) {}

int SandboxedVfsFile::Close() {}

int SandboxedVfsFile::Read(void* buffer, int size, sqlite3_int64 offset) {}

int SandboxedVfsFile::Write(const void* buffer,
                            int size,
                            sqlite3_int64 offset) {}

int SandboxedVfsFile::Truncate(sqlite3_int64 size) {}

int SandboxedVfsFile::Sync(int flags) {}

int SandboxedVfsFile::FileSize(sqlite3_int64* result_size) {}

namespace {

// True if our simplified implementation uses an exclusive lock for a mode.
bool IsExclusiveLockMode(int sqlite_lock_mode) {}

}  // namespace

int SandboxedVfsFile::Lock(int mode) {}

int SandboxedVfsFile::Unlock(int mode) {}

int SandboxedVfsFile::CheckReservedLock(int* has_reserved_lock) {}

int SandboxedVfsFile::FileControl(int opcode, void* data) {}

int SandboxedVfsFile::SectorSize() {}

int SandboxedVfsFile::DeviceCharacteristics() {}

int SandboxedVfsFile::ShmMap(int page_index,
                             int page_size,
                             int extend_file_if_needed,
                             void volatile** result) {}

int SandboxedVfsFile::ShmLock(int offset, int size, int flags) {}

void SandboxedVfsFile::ShmBarrier() {}

int SandboxedVfsFile::ShmUnmap(int also_delete_file) {}

int SandboxedVfsFile::Fetch(sqlite3_int64 offset, int size, void** result) {}

int SandboxedVfsFile::Unfetch(sqlite3_int64 offset, void* fetch_result) {}

SandboxedVfsFile::SandboxedVfsFile(base::File file,
                                   base::FilePath file_path,
#if DCHECK_IS_ON()
                                   SandboxedVfsFileType file_type,
#endif  // DCHECK_IS_ON()
                                   SandboxedVfs* vfs)
    :{}

SandboxedVfsFile::~SandboxedVfsFile() = default;

// static
SandboxedVfsFileSqliteBridge& SandboxedVfsFileSqliteBridge::FromSqliteFile(
    sqlite3_file& sqlite_file) {}

}  // namespace sql