From 0a678346195bad620ef4696bbe0d78ccc787c979 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Fri, 16 Sep 2011 17:13:48 +0200 Subject: [PATCH] On restore we don't have a full FF_PKT so we lstat the file. --- bacula/src/filed/acl.c | 28 ++++++++++++++++++++++++---- bacula/src/filed/xattr.c | 29 ++++++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/bacula/src/filed/acl.c b/bacula/src/filed/acl.c index 3f50cba90e..27696fdc52 100644 --- a/bacula/src/filed/acl.c +++ b/bacula/src/filed/acl.c @@ -1850,15 +1850,35 @@ bacl_exit_code build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) bacl_exit_code parse_acl_streams(JCR *jcr, int stream) { + int ret; + berrno be; + struct stat st; unsigned int cnt; /* * See if we are changing from one device to an other. * We save the current device we are restoring to and compare * it with the current st_dev in the last stat performed on - * the file we are currently storing. + * the file we are currently restoring. */ - if (jcr->acl_data->current_dev != ff_pkt->statp.st_dev) { + ret = lstat(jcr->last_fname, &st); + switch (ret) { + case -1: + switch (errno) { + case ENOENT: + return bacl_exit_ok; + default: + Mmsg2(jcr->errmsg, _("Unable to stat file \"%s\": ERR=%s\n"), + jcr->last_fname, be.bstrerror()); + Dmsg2(100, "Unable to stat file \"%s\": ERR=%s\n", + jcr->last_fname, be.bstrerror()); + return bacl_exit_error; + } + break; + case 0: + break; + } + if (jcr->acl_data->current_dev != st.st_dev) { /* * Reset the acl save flags. */ @@ -1866,9 +1886,9 @@ bacl_exit_code parse_acl_streams(JCR *jcr, int stream) jcr->acl_data->flags |= BACL_FLAG_RESTORE_NATIVE; /* - * Save that we started retoring to a new filesystem. + * Save that we started restoring to a new filesystem. */ - jcr->acl_data->current_dev = ff_pkt->statp.st_dev; + jcr->acl_data->current_dev = st.st_dev; } switch (stream) { diff --git a/bacula/src/filed/xattr.c b/bacula/src/filed/xattr.c index b1f19fc980..ac364dd10f 100644 --- a/bacula/src/filed/xattr.c +++ b/bacula/src/filed/xattr.c @@ -3361,15 +3361,35 @@ bxattr_exit_code build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) bxattr_exit_code parse_xattr_streams(JCR *jcr, int stream) { + int ret; + berrno be; + struct stat st; unsigned int cnt; /* * See if we are changing from one device to an other. * We save the current device we are restoring to and compare * it with the current st_dev in the last stat performed on - * the file we are currently storing. + * the file we are currently restoring. */ - if (jcr->xattr_data->current_dev != ff_pkt->statp.st_dev) { + ret = lstat(jcr->last_fname, &st); + switch (ret) { + case -1: + switch (errno) { + case ENOENT: + return bxattr_exit_ok; + default: + Mmsg2(jcr->errmsg, _("Unable to stat file \"%s\": ERR=%s\n"), + jcr->last_fname, be.bstrerror()); + Dmsg2(100, "Unable to stat file \"%s\": ERR=%s\n", + jcr->last_fname, be.bstrerror()); + return bxattr_exit_error; + } + break; + case 0: + break; + } + if (jcr->xattr_data->current_dev != st.st_dev) { /* * Reset the acl save flags. */ @@ -3379,9 +3399,12 @@ bxattr_exit_code parse_xattr_streams(JCR *jcr, int stream) /* * Save that we started restoring to a new filesystem. */ - jcr->xattr_data->current_dev = ff_pkt->statp.st_dev; + jcr->xattr_data->current_dev = st.st_dev; } + /* + * See if we are still restoring native xattr to this filesystem. + */ if ((jcr->xattr_data->flags & BXATTR_FLAG_RESTORE_NATIVE) && os_parse_xattr_streams) { /* * See if we can parse this stream, and ifso give it a try. -- 2.39.5