Move conffile and storagedir to lib/fs

This commit is contained in:
Nick Mathewson 2018-06-28 09:38:17 -04:00
parent 38fd3e0df0
commit a1f3ece16d
7 changed files with 39 additions and 19 deletions

View File

@ -28,10 +28,8 @@ LIBOR_A_SRC = \
src/common/buffers.c \ src/common/buffers.c \
src/common/compat.c \ src/common/compat.c \
src/common/compat_time.c \ src/common/compat_time.c \
src/common/conffile.c \
src/common/util.c \ src/common/util.c \
src/common/util_process.c \ src/common/util_process.c \
src/common/storagedir.c \
src/common/token_bucket.c \ src/common/token_bucket.c \
src/common/workqueue.c \ src/common/workqueue.c \
$(libor_extra_source) \ $(libor_extra_source) \
@ -68,10 +66,8 @@ COMMONHEADERS = \
src/common/compat.h \ src/common/compat.h \
src/common/compat_libevent.h \ src/common/compat_libevent.h \
src/common/compat_time.h \ src/common/compat_time.h \
src/common/conffile.h \
src/common/handles.h \ src/common/handles.h \
src/common/procmon.h \ src/common/procmon.h \
src/common/storagedir.h \
src/common/timers.h \ src/common/timers.h \
src/common/token_bucket.h \ src/common/token_bucket.h \
src/common/util.h \ src/common/util.h \

View File

@ -1,11 +1,13 @@
orconfig.h orconfig.h
lib/cc/*.h lib/cc/*.h
lib/container/*.h lib/container/*.h
lib/encoding/*.h
lib/err/*.h lib/err/*.h
lib/fdio/*.h lib/fdio/*.h
lib/malloc/*.h
lib/fs/*.h lib/fs/*.h
lib/log/*.h
lib/malloc/*.h
lib/memarea/*.h
lib/sandbox/*.h lib/sandbox/*.h
lib/string/*.h lib/string/*.h
lib/testsupport/testsupport.h lib/testsupport/testsupport.h
lib/log/*.h

View File

@ -4,12 +4,16 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */ * Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */ /* See LICENSE for licensing information */
#include "common/compat.h" #include "lib/fs/conffile.h"
#include "lib/encoding/confline.h"
#include "common/conffile.h"
#include "lib/log/torlog.h"
#include "common/util.h"
#include "lib/container/smartlist.h" #include "lib/container/smartlist.h"
#include "lib/encoding/confline.h"
#include "lib/fs/dir.h"
#include "lib/fs/files.h"
#include "lib/fs/path.h"
#include "lib/log/torlog.h"
#include "lib/malloc/util_malloc.h"
#include "lib/string/printf.h"
static smartlist_t *config_get_file_list(const char *path, static smartlist_t *config_get_file_list(const char *path,
smartlist_t *opened_files); smartlist_t *opened_files);

View File

@ -6,10 +6,12 @@ noinst_LIBRARIES += src/lib/libtor-fs-testing.a
endif endif
src_lib_libtor_fs_a_SOURCES = \ src_lib_libtor_fs_a_SOURCES = \
src/lib/fs/conffile.c \
src/lib/fs/dir.c \ src/lib/fs/dir.c \
src/lib/fs/files.c \ src/lib/fs/files.c \
src/lib/fs/mmap.c \ src/lib/fs/mmap.c \
src/lib/fs/path.c \ src/lib/fs/path.c \
src/lib/fs/storagedir.c \
src/lib/fs/userdb.c src/lib/fs/userdb.c
src_lib_libtor_fs_testing_a_SOURCES = \ src_lib_libtor_fs_testing_a_SOURCES = \
@ -18,8 +20,10 @@ src_lib_libtor_fs_testing_a_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
src_lib_libtor_fs_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS) src_lib_libtor_fs_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
noinst_HEADERS += \ noinst_HEADERS += \
src/lib/fs/conffile.h \
src/lib/fs/dir.h \ src/lib/fs/dir.h \
src/lib/fs/files.h \ src/lib/fs/files.h \
src/lib/fs/mmap.h \ src/lib/fs/mmap.h \
src/lib/fs/path.h \ src/lib/fs/path.h \
src/lib/fs/storagedir.h \
src/lib/fs/userdb.h src/lib/fs/userdb.h

View File

@ -1,14 +1,21 @@
/* Copyright (c) 2017-2018, The Tor Project, Inc. */ /* Copyright (c) 2017-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */ /* See LICENSE for licensing information */
#include "lib/fs/storagedir.h"
#include "lib/container/smartlist.h" #include "lib/container/smartlist.h"
#include "common/compat.h"
#include "lib/encoding/confline.h" #include "lib/encoding/confline.h"
#include "lib/fs/dir.h"
#include "lib/fs/files.h"
#include "lib/fs/mmap.h"
#include "lib/log/escape.h"
#include "lib/log/torlog.h"
#include "lib/log/util_bug.h"
#include "lib/malloc/util_malloc.h"
#include "lib/memarea/memarea.h" #include "lib/memarea/memarea.h"
#include "lib/sandbox/sandbox.h" #include "lib/sandbox/sandbox.h"
#include "common/storagedir.h" #include "lib/string/printf.h"
#include "lib/log/torlog.h" #include "lib/string/util_string.h"
#include "common/util.h"
#ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
@ -19,6 +26,9 @@
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#define FNAME_MIN_NUM 1000 #define FNAME_MIN_NUM 1000

View File

@ -4,9 +4,14 @@
#ifndef TOR_STORAGEDIR_H #ifndef TOR_STORAGEDIR_H
#define TOR_STORAGEDIR_H #define TOR_STORAGEDIR_H
#include "lib/cc/torint.h"
#include <stddef.h>
typedef struct storage_dir_t storage_dir_t; typedef struct storage_dir_t storage_dir_t;
struct config_line_t; struct config_line_t;
struct sandbox_cfg_elem; struct sandbox_cfg_elem;
struct tor_mmap_t;
struct smartlist_t;
storage_dir_t * storage_dir_new(const char *dirname, int n_files); storage_dir_t * storage_dir_new(const char *dirname, int n_files);
void storage_dir_free_(storage_dir_t *d); void storage_dir_free_(storage_dir_t *d);
@ -15,9 +20,9 @@ void storage_dir_free_(storage_dir_t *d);
int storage_dir_register_with_sandbox(storage_dir_t *d, int storage_dir_register_with_sandbox(storage_dir_t *d,
struct sandbox_cfg_elem **cfg); struct sandbox_cfg_elem **cfg);
const smartlist_t *storage_dir_list(storage_dir_t *d); const struct smartlist_t *storage_dir_list(storage_dir_t *d);
uint64_t storage_dir_get_usage(storage_dir_t *d); uint64_t storage_dir_get_usage(storage_dir_t *d);
tor_mmap_t *storage_dir_map(storage_dir_t *d, const char *fname); struct tor_mmap_t *storage_dir_map(storage_dir_t *d, const char *fname);
uint8_t *storage_dir_read(storage_dir_t *d, const char *fname, int bin, uint8_t *storage_dir_read(storage_dir_t *d, const char *fname, int bin,
size_t *sz_out); size_t *sz_out);
int storage_dir_save_bytes_to_file(storage_dir_t *d, int storage_dir_save_bytes_to_file(storage_dir_t *d,
@ -34,7 +39,7 @@ int storage_dir_save_labeled_to_file(storage_dir_t *d,
const uint8_t *data, const uint8_t *data,
size_t length, size_t length,
char **fname_out); char **fname_out);
tor_mmap_t *storage_dir_map_labeled(storage_dir_t *dir, struct tor_mmap_t *storage_dir_map_labeled(storage_dir_t *dir,
const char *fname, const char *fname,
struct config_line_t **labels_out, struct config_line_t **labels_out,
const uint8_t **data_out, const uint8_t **data_out,
@ -51,4 +56,3 @@ int storage_dir_remove_all(storage_dir_t *d);
int storage_dir_get_max_files(storage_dir_t *d); int storage_dir_get_max_files(storage_dir_t *d);
#endif /* !defined(TOR_STORAGEDIR_H) */ #endif /* !defined(TOR_STORAGEDIR_H) */