Subject: Fix build against libcephfs2.
From: Dominik George <natureshadow@debian.org>
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=915162
--- a/src/stored/backends/cephfs_device.c
+++ b/src/stored/backends/cephfs_device.c
@@ -152,12 +152,12 @@ int cephfs_device::d_open(const char *pa
     * See if we store in an explicit directory.
     */
    if (m_basedir) {
-      struct stat st;
+      struct ceph_statx st;
 
       /*
        * Make sure the dir exists if one is defined.
        */
-      status = ceph_stat(m_cmount, m_basedir, &st);
+      status = ceph_statx(m_cmount, m_basedir, &st, CEPH_STATX_MODE, 0);
       if (status < 0) {
          switch (status) {
          case -ENOENT:
@@ -172,7 +172,7 @@ int cephfs_device::d_open(const char *pa
             goto bail_out;
          }
       } else {
-         if (!S_ISDIR(st.st_mode)) {
+         if (!S_ISDIR(st.stx_mode)) {
             Mmsg1(errmsg, _("Specified CEPHFS direcory %s is not a directory.\n"), m_basedir);
             Emsg0(M_FATAL, 0, errmsg);
             goto bail_out;
@@ -271,7 +271,7 @@ boffset_t cephfs_device::d_lseek(DCR *dc
 bool cephfs_device::d_truncate(DCR *dcr)
 {
    int status;
-   struct stat st;
+   struct ceph_statx st;
 
    if (m_fd >= 0) {
       status = ceph_ftruncate(m_cmount, m_fd, 0);
@@ -291,7 +291,7 @@ bool cephfs_device::d_truncate(DCR *dcr)
        * 3. open new file with same mode
        * 4. change ownership to original
        */
-      status = ceph_fstat(m_cmount, m_fd, &st);
+      status = ceph_fstatx(m_cmount, m_fd, &st, CEPH_STATX_SIZE, 0);
       if (status < 0) {
          berrno be;
 
@@ -300,7 +300,7 @@ bool cephfs_device::d_truncate(DCR *dcr)
          return false;
       }
 
-      if (st.st_size != 0) {             /* ceph_ftruncate() didn't work */
+      if (st.stx_size != 0) {             /* ceph_ftruncate() didn't work */
          ceph_close(m_cmount, m_fd);
          ceph_unlink(m_cmount, m_virtual_filename);
 
@@ -308,7 +308,7 @@ bool cephfs_device::d_truncate(DCR *dcr)
           * Recreate the file -- of course, empty
           */
          oflags = O_CREAT | O_RDWR | O_BINARY;
-         m_fd = ceph_open(m_cmount, m_virtual_filename, oflags, st.st_mode);
+         m_fd = ceph_open(m_cmount, m_virtual_filename, oflags, st.stx_mode);
          if (m_fd < 0) {
             berrno be;
 
@@ -323,7 +323,7 @@ bool cephfs_device::d_truncate(DCR *dcr)
          /*
           * Reset proper owner
           */
-         ceph_chown(m_cmount, m_virtual_filename, st.st_uid, st.st_gid);
+         ceph_chown(m_cmount, m_virtual_filename, st.stx_uid, st.stx_gid);
       }
    }
 
--- a/src/plugins/filed/cephfs-fd.c
+++ b/src/plugins/filed/cephfs-fd.c
@@ -126,7 +126,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 */
-   struct stat statp;                 /* Stat struct for next file to save */
+   struct ceph_statx statp;                 /* Stat struct for next file to save */
    bool processing_xattr;             /* Set when we are processing a xattr list */
    char *next_xattr_name;             /* Next xattr name to process */
    POOLMEM *cwd;                      /* Current Working Directory */
@@ -168,7 +168,7 @@ static plugin_argument plugin_arguments[
  * a stack so we can pop it after we have processed the subdir.
  */
 struct dir_stack_entry {
-   struct stat statp;                 /* Stat struct of directory */
+   struct ceph_statx statp;                 /* Stat struct of directory */
    struct ceph_dir_result *cdir;      /* CEPHFS directory handle */
 };
 
@@ -462,17 +462,17 @@ static bRC get_next_file_to_backup(bpCon
     * Loop until we know what file is next or when we are done.
     */
    while (1) {
-      int stmask = 0;
+      unsigned int stmask = 0;
 
       memset(&p_ctx->statp, 0, sizeof(p_ctx->statp));
       memset(&p_ctx->de, 0, sizeof(p_ctx->de));
-      status = ceph_readdirplus_r(p_ctx->cmount, p_ctx->cdir, &p_ctx->de, &p_ctx->statp, &stmask);
+      status = ceph_readdirplus_r(p_ctx->cmount, p_ctx->cdir, &p_ctx->de, &p_ctx->statp, stmask, 0, NULL);
 
       /*
        * No more entries in this directory ?
        */
       if (status == 0) {
-         status = ceph_stat(p_ctx->cmount, p_ctx->cwd, &p_ctx->statp);
+         status = ceph_statx(p_ctx->cmount, p_ctx->cwd, &p_ctx->statp, 0, 0);
          if (status < 0) {
             berrno be;
 
@@ -514,7 +514,7 @@ static bRC get_next_file_to_backup(bpCon
       /*
        * Determine the FileType.
        */
-      switch (p_ctx->statp.st_mode & S_IFMT) {
+      switch (p_ctx->statp.stx_mode & S_IFMT) {
       case S_IFREG:
          p_ctx->type = FT_REG;
          break;
@@ -543,7 +543,7 @@ static bRC get_next_file_to_backup(bpCon
          break;
       default:
          Jmsg(ctx, M_FATAL, "cephfs-fd: Unknown filetype encountered %ld for %s\n",
-              p_ctx->statp.st_mode & S_IFMT, p_ctx->next_filename);
+              p_ctx->statp.stx_mode & S_IFMT, p_ctx->next_filename);
          return bRC_Error;
       }
 
@@ -753,8 +753,8 @@ static bRC endBackupFile(bpContext *ctx)
    if (bit_is_set(FO_NOATIME, p_ctx->flags)) {
       struct utimbuf times;
 
-      times.actime = p_ctx->statp.st_atime;
-      times.modtime = p_ctx->statp.st_mtime;
+      times.actime = p_ctx->statp.stx_atime.tv_sec;
+      times.modtime = p_ctx->statp.stx_mtime.tv_sec;
 
       ceph_utime(p_ctx->cmount, p_ctx->next_filename, &times);
    }
@@ -1154,7 +1154,7 @@ static bRC endRestoreFile(bpContext *ctx
 static inline bool cephfs_makedirs(plugin_ctx *p_ctx, const char *directory)
 {
    char *bp;
-   struct stat st;
+   struct ceph_statx st;
    bool retval = false;
    POOL_MEM new_directory(PM_FNAME);
 
@@ -1182,7 +1182,7 @@ static inline bool cephfs_makedirs(plugi
       } else {
          *bp = '\0';
 
-         if (ceph_lstat(p_ctx->cmount, new_directory.c_str(), &st) != 0) {
+         if (ceph_statx(p_ctx->cmount, new_directory.c_str(), &st, 0, AT_SYMLINK_NOFOLLOW) != 0) {
             switch (errno) {
             case ENOENT:
                /*
@@ -1228,7 +1228,7 @@ static bRC createFile(bpContext *ctx, st
 {
    int status;
    bool exists = false;
-   struct stat st;
+   struct ceph_statx st;
    plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext;
 
    if (!p_ctx) {
@@ -1239,20 +1239,20 @@ static bRC createFile(bpContext *ctx, st
     * See if the file already exists.
     */
    Dmsg(ctx, 400, "cephfs-fd: Replace=%c %d\n", (char)rp->replace, rp->replace);
-   status = ceph_lstat(p_ctx->cmount, rp->ofname, &st);
+   status = ceph_statx(p_ctx->cmount, rp->ofname, &st, 0, AT_SYMLINK_NOFOLLOW);
    if (status == 0) {
       exists = true;
 
       switch (rp->replace) {
       case REPLACE_IFNEWER:
-         if (rp->statp.st_mtime <= st.st_mtime) {
+         if (rp->statp.st_mtime <= st.stx_mtime.tv_sec) {
             Jmsg(ctx, M_INFO, 0, _("cephfs-fd: File skipped. Not newer: %s\n"), rp->ofname);
             rp->create_status = CF_SKIP;
             goto bail_out;
          }
          break;
       case REPLACE_IFOLDER:
-         if (rp->statp.st_mtime >= st.st_mtime) {
+         if (rp->statp.st_mtime >= st.stx_mtime.tv_sec) {
             Jmsg(ctx, M_INFO, 0, _("cephfs-fd: File skipped. Not older: %s\n"), rp->ofname);
             rp->create_status = CF_SKIP;
             goto bail_out;
