mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-18 20:57:56 +00:00
faa0f392c5
Change the default 'rhizome.datastore_path' to "rhizome", ie, a sub-
directory of the instance directory.
Add a new erename() operation to "os.h".
Clean up the code around the fix 39f582cca
(two commits ago) for a bug
introduced in 2014: the 'rhizome.db' file was always being created in
the instance directory, regardless of the setting of the
'rhizome.datastore_path' config option.
Whenever the Rhizome database is opened (by the server or by a CLI
invocation), if the database file does not exist but there is a
'rhizome.db' file in the legacy location, then move that file (and any
accompanying "blob" and "hash" sub-directories) to the configured
location.
Update copyright notices.
78 lines
4.8 KiB
C
78 lines
4.8 KiB
C
/*
|
|
Serval DNA instance paths
|
|
Copyright (C) 2014-2015 Serval Project Inc.
|
|
Copyright (C) 2016-2018 Flinders University
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; either version 2
|
|
of the License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#ifndef __SERVAL_DNA__INSTANCE_H
|
|
#define __SERVAL_DNA__INSTANCE_H
|
|
|
|
#include "lang.h"
|
|
#include "whence.h"
|
|
#include "strbuf.h"
|
|
|
|
const char *instance_path(); // returns NULL if not using an instance path
|
|
|
|
void set_instance_path(const char *path);
|
|
|
|
int create_serval_instance_dir();
|
|
|
|
/* Macros for forming the absolute paths of various files into a given char*
|
|
* buffer. Evaluates to true if the pathname fits into the provided buffer,
|
|
* false (0) otherwise (after logging an error).
|
|
*
|
|
* The "legacy" path functions/macros are exclusively used to provide
|
|
* compatibility with earlier versions of Serval DNA, and may be deleted once
|
|
* no longer needed.
|
|
*/
|
|
int _formf_serval_etc_path(struct __sourceloc, char *buf, size_t bufsiz, const char *fmt, ...) __attribute__((__ATTRIBUTE_format(printf,4,5)));
|
|
int _formf_serval_run_path(struct __sourceloc, char *buf, size_t bufsiz, const char *fmt, ...) __attribute__((__ATTRIBUTE_format(printf,4,5)));
|
|
int _vformf_serval_run_path(struct __sourceloc, char *buf, size_t bufsiz, const char *fmt, va_list);
|
|
int _formf_serval_cache_path(struct __sourceloc, char *buf, size_t bufsiz, const char *fmt, ...) __attribute__((__ATTRIBUTE_format(printf,4,5)));
|
|
int _formf_serval_tmp_path(struct __sourceloc, char *buf, size_t bufsiz, const char *fmt, ...) __attribute__((__ATTRIBUTE_format(printf,4,5)));
|
|
int _formf_servald_proc_path(struct __sourceloc, char *buf, size_t bufsiz, const char *fmt, ...) __attribute__((__ATTRIBUTE_format(printf,4,5)));
|
|
int _formf_rhizome_store_path(struct __sourceloc, char *buf, size_t bufsiz, const char *fmt, ...) __attribute__((__ATTRIBUTE_format(printf,4,5)));
|
|
int _formf_rhizome_store_legacy_path(struct __sourceloc, char *buf, size_t bufsiz, const char *fmt, ...) __attribute__((__ATTRIBUTE_format(printf,4,5)));
|
|
|
|
#define formf_serval_etc_path(buf,bufsz,fmt,...) _formf_serval_etc_path(__WHENCE__, buf, bufsz, fmt, ##__VA_ARGS__)
|
|
#define formf_serval_run_path(buf,bufsz,fmt,...) _formf_serval_run_path(__WHENCE__, buf, bufsz, fmt, ##__VA_ARGS__)
|
|
#define vformf_serval_run_path(buf,bufsz,fmt,ap) _vformf_serval_run_path(__WHENCE__, buf, bufsz, fmt, ap)
|
|
#define formf_serval_cache_path(buf,bufsz,fmt,...) _formf_serval_cache_path(__WHENCE__, buf, bufsz, fmt, ##__VA_ARGS__)
|
|
#define formf_serval_tmp_path(buf,bufsz,fmt,...) _formf_serval_tmp_path(__WHENCE__, buf, bufsz, fmt, ##__VA_ARGS__)
|
|
#define formf_servald_proc_path(buf,bufsz,fmt,...) _formf_servald_proc_path(__WHENCE__, buf, bufsz, fmt, ##__VA_ARGS__)
|
|
#define formf_rhizome_store_path(buf,bufsz,fmt,...) _formf_rhizome_store_path(__WHENCE__, buf, bufsz, fmt, ##__VA_ARGS__)
|
|
#define formf_rhizome_store_legacy_path(buf,bufsz,fmt,...) _formf_rhizome_store_legacy_path(__WHENCE__, buf, bufsz, fmt, ##__VA_ARGS__)
|
|
|
|
/* Handy macros for forming the absolute paths of various files, using a char[]
|
|
* buffer whose declaration is in scope (so that sizeof(buf) will work).
|
|
* Evaluates to true if the pathname fits into the provided buffer, false (0)
|
|
* otherwise (after logging an error).
|
|
*/
|
|
#define FORMF_SERVAL_ETC_PATH(buf,fmt,...) formf_serval_etc_path(buf, sizeof(buf), fmt, ##__VA_ARGS__)
|
|
#define FORMF_SERVAL_RUN_PATH(buf,fmt,...) formf_serval_run_path(buf, sizeof(buf), fmt, ##__VA_ARGS__)
|
|
#define VFORMF_SERVAL_RUN_PATH(buf,fmt,ap) vformf_serval_run_path(buf, sizeof(buf), fmt, ap)
|
|
#define FORMF_SERVAL_CACHE_PATH(buf,fmt,...) formf_serval_cache_path(buf, sizeof(buf), fmt, ##__VA_ARGS__)
|
|
#define FORMF_SERVAL_TMP_PATH(buf,fmt,...) formf_serval_tmp_path(buf, sizeof(buf), fmt, ##__VA_ARGS__)
|
|
#define FORMF_SERVALD_PROC_PATH(buf,fmt,...) formf_servald_proc_path(buf, sizeof(buf), fmt, ##__VA_ARGS__)
|
|
#define FORMF_RHIZOME_STORE_PATH(buf,fmt,...) formf_rhizome_store_path(buf, sizeof(buf), fmt, ##__VA_ARGS__)
|
|
#define FORMF_RHIZOME_STORE_LEGACY_PATH(buf,fmt,...) formf_rhizome_store_legacy_path(buf, sizeof(buf), fmt, ##__VA_ARGS__)
|
|
|
|
strbuf strbuf_system_log_path(strbuf sb);
|
|
strbuf strbuf_serval_log_path(strbuf sb);
|
|
|
|
#endif // __SERVAL_DNA__INSTANCE_H
|