(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
* Functions to handle Extended Attributes for bacula.
*
* Extended Attributes are so OS specific we only restore Extended Attributes if
* Functions to handle Extended Attributes for bacula.
*
* Extended Attributes are so OS specific we only restore Extended Attributes if
* Currently we support the following OSes:
* - AIX (Extended Attributes)
* - Darwin (Extended Attributes)
* Currently we support the following OSes:
* - AIX (Extended Attributes)
* - Darwin (Extended Attributes)
* - IRIX (Extended Attributes)
* - Linux (Extended Attributes)
* - NetBSD (Extended Attributes)
* - IRIX (Extended Attributes)
* - Linux (Extended Attributes)
* - NetBSD (Extended Attributes)
* - OpenBSD (Extended Attributes)
* (As it seems either they never implemented xattr or they are removed
* the support as it stated it was in version 3.1 but the current syscall
* - OpenBSD (Extended Attributes)
* (As it seems either they never implemented xattr or they are removed
* the support as it stated it was in version 3.1 but the current syscall
* might eventually support xattr on OpenBSD when they implemented them using
* the same interface as FreeBSD and NetBSD.
* - Solaris (Extended Attributes and Extensible Attributes)
* might eventually support xattr on OpenBSD when they implemented them using
* the same interface as FreeBSD and NetBSD.
* - Solaris (Extended Attributes and Extensible Attributes)
* Entry points when compiled without support for XATTRs or on an unsupported platform.
*/
bxattr_exit_code build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt)
* Entry points when compiled without support for XATTRs or on an unsupported platform.
*/
bxattr_exit_code build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt)
* Send a XATTR stream to the SD.
*/
static bxattr_exit_code send_xattr_stream(JCR *jcr, int stream)
* Send a XATTR stream to the SD.
*/
static bxattr_exit_code send_xattr_stream(JCR *jcr, int stream)
* First some generic functions for OSes that use the same xattr encoding scheme.
* Currently for all OSes except for Solaris.
*/
* First some generic functions for OSes that use the same xattr encoding scheme.
* Currently for all OSes except for Solaris.
*/
* The xattr stream for OSX, FreeBSD, Linux and NetBSD is a serialized stream of bytes
* which encodes one or more xattr_t structures.
*
* The xattr stream for OSX, FreeBSD, Linux and NetBSD is a serialized stream of bytes
* which encodes one or more xattr_t structures.
*
* Parse the stream and call restore_xattr_on_file for each extended attribute.
*
* Start unserializing the data. We keep on looping while we have not
* Parse the stream and call restore_xattr_on_file for each extended attribute.
*
* Start unserializing the data. We keep on looping while we have not
* First make sure the magic is present. This way we can easily catch corruption.
* Any missing MAGIC is fatal we do NOT try to continue.
*/
* First make sure the magic is present. This way we can easily catch corruption.
* Any missing MAGIC is fatal we do NOT try to continue.
*/
current_xattr = (xattr_t *)malloc(sizeof(xattr_t));
unser_uint32(current_xattr->magic);
if (current_xattr->magic != XATTR_MAGIC) {
current_xattr = (xattr_t *)malloc(sizeof(xattr_t));
unser_uint32(current_xattr->magic);
if (current_xattr->magic != XATTR_MAGIC) {
/*
* Walk the list of extended attributes names and retrieve the data.
* We already count the bytes needed for serializing the stream later on.
/*
* Walk the list of extended attributes names and retrieve the data.
* We already count the bytes needed for serializing the stream later on.
for (cnt = 0; xattr_naming_spaces[cnt].name != NULL; cnt++) {
memset(cursor, 0, sizeof(attrlist_cursor_t));
while (1) {
for (cnt = 0; xattr_naming_spaces[cnt].name != NULL; cnt++) {
memset(cursor, 0, sizeof(attrlist_cursor_t));
while (1) {
* Walk the available attributes.
*/
for (cnt = 0; cnt < attrlist->al_count; cnt++) {
attrlist_ent = ATTR_ENTRY(xattrbuf, cnt);
* Walk the available attributes.
*/
for (cnt = 0; cnt < attrlist->al_count; cnt++) {
attrlist_ent = ATTR_ENTRY(xattrbuf, cnt);
* Each xattr valuepair starts with a magic so we can parse it easier.
*/
current_xattr = (xattr_t *)malloc(sizeof(xattr_t));
current_xattr->magic = XATTR_MAGIC;
expected_serialize_len += sizeof(current_xattr->magic);
* Each xattr valuepair starts with a magic so we can parse it easier.
*/
current_xattr = (xattr_t *)malloc(sizeof(xattr_t));
current_xattr->magic = XATTR_MAGIC;
expected_serialize_len += sizeof(current_xattr->magic);
current_xattr->value_length = attrlist_ent->a_valuelen;
current_xattr->value = (char *)malloc(current_xattr->value_length);
current_xattr->value_length = attrlist_ent->a_valuelen;
current_xattr->value = (char *)malloc(current_xattr->value_length);
* Retrieve the actual value of the xattr.
*/
if (attr_get(jcr->last_fname, attrlist_ent->a_name, current_xattr->value,
* Retrieve the actual value of the xattr.
*/
if (attr_get(jcr->last_fname, attrlist_ent->a_name, current_xattr->value,
* The buffer for the xattr isn't big enough. the value of
* current_xattr->value_length is updated with the actual size
* of the xattr. So we free the old buffer and create a new one
* The buffer for the xattr isn't big enough. the value of
* current_xattr->value_length is updated with the actual size
* of the xattr. So we free the old buffer and create a new one
* See if there are more attributes available for a next run of attr_list.
*/
if (attrlist->al_more == 0) {
* See if there are more attributes available for a next run of attr_list.
*/
if (attrlist->al_more == 0) {
*/
if (name_space_index == 0) {
Mmsg2(jcr->errmsg, _("Received illegal xattr named %s on file \"%s\"\n"),
*/
if (name_space_index == 0) {
Mmsg2(jcr->errmsg, _("Received illegal xattr named %s on file \"%s\"\n"),
* Restore the xattr first try to create the attribute from scratch.
*/
flags = xattr_naming_spaces[name_space_index].flags | ATTR_CREATE;
* Restore the xattr first try to create the attribute from scratch.
*/
flags = xattr_naming_spaces[name_space_index].flags | ATTR_CREATE;
* The xattr already exists we need to replace it.
*/
flags = xattr_naming_spaces[name_space_index].flags | ATTR_REPLACE;
* The xattr already exists we need to replace it.
*/
flags = xattr_naming_spaces[name_space_index].flags | ATTR_REPLACE;
/*
* Walk the list of extended attributes names and retrieve the data.
* We already count the bytes needed for serializing the stream later on.
*/
bp = xattr_list;
while ((bp - xattr_list) + 1 < xattr_list_len) {
/*
* Walk the list of extended attributes names and retrieve the data.
* We already count the bytes needed for serializing the stream later on.
*/
bp = xattr_list;
while ((bp - xattr_list) + 1 < xattr_list_len) {
- name_len = strlen(bp);
- if (skip_xattr || name_len == 0) {
+ name_length = strlen(bp);
+ if (skip_xattr || name_length == 0) {
+ Dmsg1(100, "Skipping xattr named %s\n", bp);
current_xattr->name = (char *)malloc(current_xattr->name_length);
memcpy((caddr_t)current_xattr->name, (caddr_t)bp, current_xattr->name_length);
current_xattr->name = (char *)malloc(current_xattr->name_length);
memcpy((caddr_t)current_xattr->name, (caddr_t)bp, current_xattr->name_length);
static bxattr_exit_code (*os_build_xattr_streams)(JCR *jcr, FF_PKT *ff_pkt) = bsd_build_xattr_streams;
static bxattr_exit_code (*os_parse_xattr_streams)(JCR *jcr, int stream) = bsd_parse_xattr_streams;
static bxattr_exit_code (*os_build_xattr_streams)(JCR *jcr, FF_PKT *ff_pkt) = bsd_build_xattr_streams;
static bxattr_exit_code (*os_parse_xattr_streams)(JCR *jcr, int stream) = bsd_parse_xattr_streams;
xattr_list_len = getproplist(jcr->last_fname, 1, &prop_args, xattrbuf_size,
xattrbuf, &xattrbuf_min_size);
xattr_list_len = getproplist(jcr->last_fname, 1, &prop_args, xattrbuf_size,
xattrbuf, &xattrbuf_min_size);
* The buffer isn't big enough to hold the xattr data, we now have
* a minimum buffersize so we resize the buffer and try again.
*/
* The buffer isn't big enough to hold the xattr data, we now have
* a minimum buffersize so we resize the buffer and try again.
*/
* This should never happen as we sized the buffer according to the minimumsize
* returned by a previous getproplist call. If it does happen things are fishy and
* we are better of forgetting this xattr as it seems its list is changing at this
* This should never happen as we sized the buffer according to the minimumsize
* returned by a previous getproplist call. If it does happen things are fishy and
* we are better of forgetting this xattr as it seems its list is changing at this
* Walk the list of extended attributes names and retrieve the data.
* We already count the bytes needed for serializing the stream later on.
*/
* Walk the list of extended attributes names and retrieve the data.
* We already count the bytes needed for serializing the stream later on.
*/
* Restore the list of extended attributes on the file.
*/
cnt = setproplist(jcr->last_fname, 1, xattrbuf_size, xattrbuf);
* Restore the list of extended attributes on the file.
*/
cnt = setproplist(jcr->last_fname, 1, xattrbuf_size, xattrbuf);