Skip to content

Commit

Permalink
Merge pull request #569 from bareos/dev/pstorz/master/new-distris
Browse files Browse the repository at this point in the history
fix build problems on new distributions
  • Loading branch information
pstorz committed Aug 11, 2020
2 parents fd13940 + 410b8b3 commit f23c2c9
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 39 deletions.
11 changes: 9 additions & 2 deletions core/cmake/BareosCheckIncludes.cmake
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2019 Bareos GmbH & Co. KG
# Copyright (C) 2017-2020 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -60,7 +60,14 @@ check_include_files(sys/ea.h HAVE_SYS_EA_H)
check_include_files(sys/proplist.h HAVE_SYS_PROPLIST_H)
check_include_files(sys/xattr.h HAVE_SYS_XATTR_H)

check_include_files("sys/stat.h;cephfs/ceph_statx.h" HAVE_CEPHFS_CEPH_STATX_H)

include(CheckSymbolExists)
include(CMakePushCheckState)
cmake_push_check_state()
set(CMAKE_REQUIRED_LIBRARIES cephfs)
check_symbol_exists(ceph_statx "sys/stat.h;cephfs/libcephfs.h" HAVE_CEPH_STATX)
cmake_pop_check_state()

check_include_files(rados/librados.h HAVE_RADOS_LIBRADOS_H)
check_include_files(radosstriper/libradosstriper.h
HAVE_RADOSSTRIPER_LIBRADOSSTRIPER_H)
Expand Down
12 changes: 6 additions & 6 deletions core/platforms/packaging/bareos.spec
Expand Up @@ -234,7 +234,6 @@ BuildRequires: python-devel >= 2.6
BuildRequires: distribution-release
BuildRequires: pwdutils
BuildRequires: tcpd-devel
BuildRequires: termcap
BuildRequires: update-desktop-files

%if 0%{?suse_version} > 1010
Expand All @@ -247,7 +246,6 @@ BuildRequires: lsb-release
%else
# non suse

BuildRequires: libtermcap-devel
BuildRequires: passwd

# Some magic to be able to determine what platform we are running on.
Expand Down Expand Up @@ -1352,7 +1350,8 @@ mkdir -p %{?buildroot}/%{_libdir}/bareos/plugins/vmware_plugin
%attr(0640, %{storage_daemon_user}, %{daemon_group}) %{_sysconfdir}/%{name}/bareos-sd.d/device/RadosStorage.conf.example
%endif

%endif # not client_only
# not client_only
%endif

%files filedaemon
# fd package (bareos-fd, plugins)
Expand Down Expand Up @@ -1533,8 +1532,8 @@ mkdir -p %{?buildroot}/%{_libdir}/bareos/plugins/vmware_plugin
/usr/share/pixmaps/bareos-tray-monitor.png
%endif


%endif # client_only
# client_only
%endif

%files devel
%defattr(-, root, root)
Expand Down Expand Up @@ -1598,7 +1597,8 @@ mkdir -p %{?buildroot}/%{_libdir}/bareos/plugins/vmware_plugin
%{plugin_dir}/BareosSdWrapper.py*
%{plugin_dir}/bareos-sd-class-plugin.py*

%endif # python_plugins
# python_plugins
%endif

%if 0%{?glusterfs}
%files filedaemon-glusterfs-plugin
Expand Down
2 changes: 1 addition & 1 deletion core/src/include/config.h.in
Expand Up @@ -114,7 +114,7 @@ extern char win_os[];
#cmakedefine HAVE_CEPHFS @HAVE_CEPHFS@

// Define to 1 if you have cephfs/ceph_stat_x.h header
#cmakedefine HAVE_CEPHFS_CEPH_STATX_H @HAVE_CEPHFS_CEPH_STATX_H@
#cmakedefine HAVE_CEPH_STATX @HAVE_CEPH_STATX@

// Define to 1 if you have the `chflags' function
#cmakedefine HAVE_CHFLAGS @HAVE_CHFLAGS@
Expand Down
38 changes: 19 additions & 19 deletions core/src/plugins/filed/cephfs-fd.cc
Expand Up @@ -2,7 +2,7 @@
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2014-2015 Planets Communications B.V.
Copyright (C) 2014-2015 Bareos GmbH & Co. KG
Copyright (C) 2014-2020 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -113,7 +113,7 @@ struct plugin_ctx {
char* basedir; /* Basedir to start backup in */
char flags[FOPTS_BYTES]; /* Bareos internal flags */
int32_t type; /* FT_xx for this file */
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
struct ceph_statx statx; /* Stat struct for next file to save */
#else
struct stat statp; /* Stat struct for next file to save */
Expand Down Expand Up @@ -160,7 +160,7 @@ static plugin_argument plugin_arguments[] = {
* a stack so we can pop it after we have processed the subdir.
*/
struct dir_stack_entry {
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
struct ceph_statx statx; /* Stat struct of directory */
#else
struct stat statp; /* Stat struct of directory */
Expand Down Expand Up @@ -423,7 +423,7 @@ static bRC get_next_file_to_backup(bpContext* ctx)
* Pop the previous directory handle and continue processing that.
*/
entry = (struct dir_stack_entry*)p_ctx->dir_stack->pop();
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
memcpy(&p_ctx->statx, &entry->statx, sizeof(p_ctx->statx));
#else
memcpy(&p_ctx->statp, &entry->statp, sizeof(p_ctx->statp));
Expand All @@ -444,7 +444,7 @@ static bRC get_next_file_to_backup(bpContext* ctx)
* Loop until we know what file is next or when we are done.
*/
while (1) {
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
unsigned int stmask = 0;
memset(&p_ctx->statx, 0, sizeof(p_ctx->statx));
status =
Expand All @@ -463,7 +463,7 @@ static bRC get_next_file_to_backup(bpContext* ctx)
* No more entries in this directory ?
*/
if (status == 0) {
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
status = ceph_statx(p_ctx->cmount, p_ctx->cwd, &p_ctx->statx,
CEPH_STATX_MODE, 0);
#else
Expand Down Expand Up @@ -514,7 +514,7 @@ static bRC get_next_file_to_backup(bpContext* ctx)
/*
* Determine the FileType.
*/
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
switch (p_ctx->statx.stx_mode & S_IFMT) {
#else
switch (p_ctx->statp.st_mode & S_IFMT) {
Expand Down Expand Up @@ -548,7 +548,7 @@ static bRC get_next_file_to_backup(bpContext* ctx)
p_ctx->type = FT_SPEC;
break;
default:
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
Jmsg(ctx, M_FATAL,
"cephfs-fd: Unknown filetype encountered %ld for %s\n",
p_ctx->statx.stx_mode & S_IFMT, p_ctx->next_filename);
Expand All @@ -568,7 +568,7 @@ static bRC get_next_file_to_backup(bpContext* ctx)
sp.pkt_end = sizeof(sp);
sp.fname = p_ctx->next_filename;
sp.type = p_ctx->type;
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
memcpy(&sp.statp, &p_ctx->statx, sizeof(sp.statp));
#else
memcpy(&sp.statp, &p_ctx->statp, sizeof(sp.statp));
Expand Down Expand Up @@ -637,7 +637,7 @@ static bRC startBackupFile(bpContext* ctx, struct save_pkt* sp)

new_entry =
(struct dir_stack_entry*)malloc(sizeof(struct dir_stack_entry));
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
memcpy(&new_entry->statx, &p_ctx->statx, sizeof(new_entry->statx));
#else
memcpy(&new_entry->statp, &p_ctx->statp, sizeof(new_entry->statp));
Expand All @@ -664,7 +664,7 @@ static bRC startBackupFile(bpContext* ctx, struct save_pkt* sp)
struct dir_stack_entry* entry;

entry = (struct dir_stack_entry*)p_ctx->dir_stack->pop();
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
memcpy(&p_ctx->statx, &entry->statx, sizeof(p_ctx->statx));
#else
memcpy(&p_ctx->statp, &entry->statp, sizeof(p_ctx->statp));
Expand Down Expand Up @@ -734,7 +734,7 @@ static bRC startBackupFile(bpContext* ctx, struct save_pkt* sp)

sp->fname = p_ctx->next_filename;
sp->type = p_ctx->type;
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
memcpy(&sp->statp, &p_ctx->statx, sizeof(sp->statp));
#else
memcpy(&sp->statp, &p_ctx->statp, sizeof(sp->statp));
Expand Down Expand Up @@ -786,7 +786,7 @@ static bRC endBackupFile(bpContext* ctx)
if (BitIsSet(FO_NOATIME, p_ctx->flags)) {
struct utimbuf times;

#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
times.actime = p_ctx->statx.stx_atime.tv_sec;
times.modtime = p_ctx->statx.stx_mtime.tv_sec;
#else
Expand Down Expand Up @@ -1224,7 +1224,7 @@ static bRC endRestoreFile(bpContext* ctx) { return bRC_OK; }
static inline bool CephfsMakedirs(plugin_ctx* p_ctx, const char* directory)
{
char* bp;
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
struct ceph_statx stx;
#else
struct stat st;
Expand Down Expand Up @@ -1254,7 +1254,7 @@ static inline bool CephfsMakedirs(plugin_ctx* p_ctx, const char* directory)
} else {
*bp = '\0';

#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
if (ceph_statx(p_ctx->cmount, new_directory.c_str(), &stx,
CEPH_STATX_SIZE, AT_SYMLINK_NOFOLLOW) != 0) {
#else
Expand Down Expand Up @@ -1302,7 +1302,7 @@ static bRC createFile(bpContext* ctx, struct restore_pkt* rp)
{
int status;
bool exists = false;
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
struct ceph_statx stx;
#else
struct stat st;
Expand All @@ -1315,7 +1315,7 @@ static bRC createFile(bpContext* ctx, struct restore_pkt* rp)
* See if the file already exists.
*/
Dmsg(ctx, 400, "cephfs-fd: Replace=%c %d\n", (char)rp->replace, rp->replace);
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
status = ceph_statx(p_ctx->cmount, rp->ofname, &stx, CEPH_STATX_SIZE,
AT_SYMLINK_NOFOLLOW);
#else
Expand All @@ -1326,7 +1326,7 @@ static bRC createFile(bpContext* ctx, struct restore_pkt* rp)

switch (rp->replace) {
case REPLACE_IFNEWER:
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
if (rp->statp.st_mtime <= stx.stx_mtime.tv_sec) {
#else
if (rp->statp.st_mtime <= st.st_mtime) {
Expand All @@ -1338,7 +1338,7 @@ static bRC createFile(bpContext* ctx, struct restore_pkt* rp)
}
break;
case REPLACE_IFOLDER:
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
if (rp->statp.st_mtime >= stx.stx_mtime.tv_sec) {
#else
if (rp->statp.st_mtime >= st.st_mtime) {
Expand Down
21 changes: 10 additions & 11 deletions core/src/stored/backends/cephfs_device.cc
Expand Up @@ -159,7 +159,7 @@ int cephfs_device::d_open(const char* pathname, int flags, int mode)
* See if we store in an explicit directory.
*/
if (basedir_) {
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
struct ceph_statx stx;
#else
struct stat st;
Expand All @@ -168,7 +168,7 @@ int cephfs_device::d_open(const char* pathname, int flags, int mode)
/*
* Make sure the dir exists if one is defined.
*/
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
status = ceph_statx(cmount_, basedir_, &stx, CEPH_STATX_SIZE,
AT_SYMLINK_NOFOLLOW);
#else
Expand All @@ -190,7 +190,7 @@ int cephfs_device::d_open(const char* pathname, int flags, int mode)
goto bail_out;
}
} else {
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
if (!S_ISDIR(stx.stx_mode)) {
#else
if (!S_ISDIR(st.st_mode)) {
Expand Down Expand Up @@ -291,7 +291,7 @@ boffset_t cephfs_device::d_lseek(DeviceControlRecord* dcr,
bool cephfs_device::d_truncate(DeviceControlRecord* dcr)
{
int status;
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
struct ceph_statx stx;
#else
struct stat st;
Expand All @@ -317,15 +317,15 @@ bool cephfs_device::d_truncate(DeviceControlRecord* dcr)
* 3. open new file with same mode
* 4. change ownership to original
*/
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
status = ceph_fstatx(cmount_, fd_, &stx, CEPH_STATX_MODE, 0);
#else
status = ceph_fstat(cmount_, fd_, &st);
#endif
if (status < 0) {
BErrNo be;

#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
Mmsg2(errmsg, _("Unable to ceph_statx device %s. ERR=%s\n"), prt_name,
be.bstrerror(-status));
#else
Expand All @@ -336,7 +336,7 @@ bool cephfs_device::d_truncate(DeviceControlRecord* dcr)
return false;
}

#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
if (stx.stx_size != 0) { /* ceph_ftruncate() didn't work */
#else
if (st.st_size != 0) { /* ceph_ftruncate() didn't work */
Expand All @@ -348,7 +348,7 @@ bool cephfs_device::d_truncate(DeviceControlRecord* dcr)
* Recreate the file -- of course, empty
*/
oflags = O_CREAT | O_RDWR | O_BINARY;
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
fd_ = ceph_open(cmount_, virtual_filename_, oflags, stx.stx_mode);
#else
fd_ = ceph_open(cmount_, virtual_filename_, oflags, st.st_mode);
Expand All @@ -369,7 +369,7 @@ bool cephfs_device::d_truncate(DeviceControlRecord* dcr)
/*
* Reset proper owner
*/
#if HAVE_CEPHFS_CEPH_STATX_H
#if HAVE_CEPH_STATX
ceph_chown(cmount_, virtual_filename_, stx.stx_uid, stx.stx_gid);
#else
ceph_chown(cmount_, virtual_filename_, st.st_uid, st.st_gid);
Expand Down Expand Up @@ -411,8 +411,7 @@ cephfs_device::cephfs_device()

class Backend : public BackendInterface {
public:
Device* GetDevice(JobControlRecord* jcr,
DeviceType device_type) override
Device* GetDevice(JobControlRecord* jcr, DeviceType device_type) override
{
switch (device_type) {
case DeviceType::B_CEPHFS_DEV:
Expand Down

0 comments on commit f23c2c9

Please sign in to comment.