/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
-/*
+/**
* General header file configurations that apply to
* all daemons. System dependent stuff goes here.
*
- * Version $Id$
*/
#define B_DEV_BSIZE 512
#endif
-/*
+/**
* Set to time limit for other end to respond to
* authentication. Normally 10 minutes is *way*
* more than enough. The idea is to keep the Director
*/
#define DEFAULT_NETWORK_BUFFER_SIZE (64 * 1024)
-/*
+/**
* Stream definitions. Once defined these must NEVER
* change as they go on the storage media.
* Note, the following streams are passed from the SD to the DIR
#define STREAM_PLUGIN_NAME 26 /* Plugin "file" string */
#define STREAM_PLUGIN_DATA 27 /* Plugin specific data */
-/*
+/**
* Additional Stream definitions. Once defined these must NEVER
* change as they go on the storage media.
*
#define STREAM_XATTR_LINUX 1998 /* Linux specific extended attributes */
#define STREAM_XATTR_NETBSD 1999 /* NetBSD specific extended attributes */
-/*
+/**
* File type (Bacula defined).
* NOTE!!! These are saved in the Attributes record on the tape, so
* do not change them. If need be, add to them.
#define FT_NOOPEN 15 /* Could not open directory */
#define FT_RAW 16 /* Raw block device */
#define FT_FIFO 17 /* Raw fifo device */
-/* The DIRBEGIN packet is sent to the FD file processing routine so
+/**
+ * The DIRBEGIN packet is sent to the FD file processing routine so
* that it can filter packets, but otherwise, it is not used
* or saved */
#define FT_DIRBEGIN 18 /* Directory at beginning (not saved) */
/* Definitions for upper part of type word (see above). */
#define AR_DATA_STREAM (1<<16) /* Data stream id present */
-/*
+/**
* Tape label types -- stored in catalog
*/
#define B_BACULA_LABEL 0
#define B_ANSI_LABEL 1
#define B_IBM_LABEL 2
-/*
+/**
* Actions on purge (bit mask)
*/
#define AOP_TRUNCATE 1
#define CRYPTO_LEN_SIZE ((int)sizeof(uint32_t))
-/* This is for dumb compilers/libraries like Solaris. Linux GCC
+/**
+ * This is for dumb compilers/libraries like Solaris. Linux GCC
* does it correctly, so it might be worthwhile
* to remove the isascii(c) with ifdefs on such
* "smart" systems.
#define B_ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
#define B_ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
-/* For multiplying by 10 with shift and addition */
+/** For multiplying by 10 with shift and addition */
#define B_TIMES10(d) ((d<<3)+(d<<1))
#define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
#endif
-/* Added by KES to deal with Win32 systems */
+/** Added by KES to deal with Win32 systems */
#ifndef S_ISWIN32
#define S_ISWIN32 020000
#endif
#endif
-/*
+/**
* The digit following Dmsg and Emsg indicates the number of substitutions in
* the message string. We need to do this kludge because non-GNU compilers
* do not handle varargs #defines.
*/
-/* Debug Messages that are printed */
+/** Debug Messages that are printed */
#ifdef DEBUG
#define Dmsg0(lvl, msg) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg)
#define Dmsg1(lvl, msg, a1) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1)
-/* Messages that are printed (uses d_msg) */
+/** Messages that are printed (uses d_msg) */
#define Pmsg0(lvl, msg) p_msg(__FILE__, __LINE__, lvl, msg)
#define Pmsg1(lvl, msg, a1) p_msg(__FILE__, __LINE__, lvl, msg, a1)
#define Pmsg2(lvl, msg, a1, a2) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
#define Pmsg14(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14)
-/* Daemon Error Messages that are delivered according to the message resource */
+/** Daemon Error Messages that are delivered according to the message resource */
#define Emsg0(typ, lvl, msg) e_msg(__FILE__, __LINE__, typ, lvl, msg)
#define Emsg1(typ, lvl, msg, a1) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
#define Emsg2(typ, lvl, msg, a1, a2) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
#define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
#define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
-/* Job Error Messages that are delivered according to the message resource */
+/** Job Error Messages that are delivered according to the message resource */
#define Jmsg0(jcr, typ, lvl, msg) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
#define Jmsg1(jcr, typ, lvl, msg, a1) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
#define Jmsg2(jcr, typ, lvl, msg, a1, a2) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
#define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
#define Jmsg6(jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
-/* Queued Job Error Messages that are delivered according to the message resource */
+/** Queued Job Error Messages that are delivered according to the message resource */
#define Qmsg0(jcr, typ, lvl, msg) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
#define Qmsg1(jcr, typ, lvl, msg, a1) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
#define Qmsg2(jcr, typ, lvl, msg, a1, a2) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
#define Qmsg6(jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
-/* Memory Messages that are edited into a Pool Memory buffer */
+/** Memory Messages that are edited into a Pool Memory buffer */
#define Mmsg0(buf, msg) m_msg(__FILE__, __LINE__, buf, msg)
#define Mmsg1(buf, msg, a1) m_msg(__FILE__, __LINE__, buf, msg, a1)
#define Mmsg2(buf, msg, a1, a2) m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
int m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...);
-/* Use our strdup with smartalloc */
+/** Use our strdup with smartalloc */
#ifndef HAVE_WXCONSOLE
#undef strdup
#define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
#endif
#endif
-/* Use our fgets which handles interrupts */
+/** Use our fgets which handles interrupts */
#undef fgets
#define fgets(x,y,z) bfgets((x), (y), (z))
-/* Use our sscanf, which is safer and works with known sizes */
+/** Use our sscanf, which is safer and works with known sizes */
#define sscanf bsscanf
#ifdef DEBUG
#define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
#endif
-/* Macro to simplify free/reset pointers */
+/** Macro to simplify free/reset pointers */
#define bfree_and_null(a) do{if(a){free(a); (a)=NULL;}} while(0)
-/*
+/**
* Replace codes needed in both file routines and non-file routines
* Job replace codes -- in "replace"
*/
#define REPLACE_NEVER 'n'
#define REPLACE_IFOLDER 'o'
-/* This probably should be done on a machine by machine basis, but it works */
-/* This is critical for the smartalloc routines to properly align memory */
+/** This probably should be done on a machine by machine basis, but it works */
+/** This is critical for the smartalloc routines to properly align memory */
#define ALIGN_SIZE (sizeof(double))
#define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
#ifdef HAVE_SUN_OS
- /*
+ /**
* On Solaris 2.5, threads are not timesliced by default, so we need to
* explictly increase the conncurrency level.
*/
#else
-/* Not needed on most systems */
+/** Not needed on most systems */
#define set_thread_concurrency(x)
#endif
#endif
-/* HP-UX 11 specific workarounds */
+/** HP-UX 11 specific workarounds */
#ifdef HAVE_HPUX_OS
# undef h_errno
extern int h_errno;
-/* the {get,set}domainname() functions exist in HPUX's libc.
+/** the {get,set}domainname() functions exist in HPUX's libc.
* the configure script detects that correctly.
* the problem is no system headers declares the prototypes for these functions
* this is done below
#endif
-/* Disabled because it breaks internationalisation...
+/** Disabled because it breaks internationalisation...
#undef HAVE_SETLOCALE
#ifdef HAVE_SETLOCALE
#include <locale.h>
#endif
*/
-/* Determine endiannes */
+/** Determine endianes */
static inline bool bigendian() { return htonl(1) == 1L; }
#endif /* _BACONFIG_H */
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
-/*
+/**
* Bacula File Daemon backup.c send file attributes and data
* to the Storage daemon.
*
set_find_options((FF_PKT *)jcr->ff, jcr->incremental, jcr->mtime);
- /* in accurate mode, we overwrite the find_one check function */
+ /** in accurate mode, we overwrite the find_one check function */
if (jcr->accurate) {
set_find_changed_function((FF_PKT *)jcr->ff, accurate_check_file);
}
jcr->xattr_data->content = get_pool_memory(PM_MESSAGE);
}
- /* Subroutine save_file() is called for each file */
+ /** Subroutine save_file() is called for each file */
if (!find_files(jcr, (FF_PKT *)jcr->ff, save_file, plugin_save)) {
ok = false; /* error */
set_jcr_job_status(jcr, JS_ErrorTerminated);
if (jcr->crypto.pki_encrypt) {
uint32_t size = 0;
- /* Create per-job session encryption context */
+ /** Create per-job session encryption context */
jcr->crypto.pki_session = crypto_session_new(cipher, jcr->crypto.pki_recipients);
- /* Get the session data size */
+ /** Get the session data size */
if (!crypto_session_encode(jcr->crypto.pki_session, (uint8_t *)0, &size)) {
Jmsg(jcr, M_FATAL, 0, _("An error occurred while encrypting the stream.\n"));
return false;
}
- /* Allocate buffer */
+ /** Allocate buffer */
jcr->crypto.pki_session_encoded = get_memory(size);
- /* Encode session data */
+ /** Encode session data */
if (!crypto_session_encode(jcr->crypto.pki_session, (uint8_t *)jcr->crypto.pki_session_encoded, &size)) {
Jmsg(jcr, M_FATAL, 0, _("An error occurred while encrypting the stream.\n"));
return false;
}
- /* ... and store the encoded size */
+ /** ... and store the encoded size */
jcr->crypto.pki_session_encoded_size = size;
- /* Allocate the encryption/decryption buffer */
+ /** Allocate the encryption/decryption buffer */
jcr->crypto.crypto_buf = get_memory(CRYPTO_CIPHER_MAX_BLOCK_SIZE);
}
return true;
{
POOLMEM *msgsave;
- /* Send our header */
+ /** Send our header */
Dmsg2(100, "Send hdr fi=%ld stream=%d\n", jcr->JobFiles, STREAM_ENCRYPTED_SESSION_DATA);
sd->fsend("%ld %d 0", jcr->JobFiles, STREAM_ENCRYPTED_SESSION_DATA);
Dmsg1(130, "bfiled: sending %s to stored\n", ff_pkt->fname);
- /* Digests and encryption are only useful if there's file data */
+ /** Digests and encryption are only useful if there's file data */
if (has_file_data) {
/**
* Setup for digest handling. If this fails, the digest will be set to NULL
digest_stream = STREAM_SHA512_DIGEST;
}
- /* Did digest initialization fail? */
+ /** Did digest initialization fail? */
if (digest_stream != STREAM_NONE && digest == NULL) {
Jmsg(jcr, M_WARNING, 0, _("%s digest initialization failed\n"),
stream_to_ascii(digest_stream));
if (jcr->crypto.pki_sign) {
signing_digest = crypto_digest_new(jcr, signing_algorithm);
- /* Full-stop if a failure occurred initializing the signature digest */
+ /** Full-stop if a failure occurred initializing the signature digest */
if (signing_digest == NULL) {
Jmsg(jcr, M_NOTSAVED, 0, _("%s signature digest initialization failed\n"),
stream_to_ascii(signing_algorithm));
}
}
- /* Enable encryption */
+ /** Enable encryption */
if (jcr->crypto.pki_encrypt) {
ff_pkt->flags |= FO_ENCRYPT;
}
}
- /* Initialize the file descriptor we use for data and other streams. */
+ /** Initialize the file descriptor we use for data and other streams. */
binit(&ff_pkt->bfd);
if (ff_pkt->flags & FO_PORTABLE) {
set_portable_backup(&ff_pkt->bfd); /* disable Win32 BackupRead() */
send_plugin_name(jcr, sd, true); /* signal start of plugin data */
}
- /* Send attributes -- must be done after binit() */
+ /** Send attributes -- must be done after binit() */
if (!encode_and_send_attributes(jcr, ff_pkt, data_stream)) {
goto bail_out;
}
- /* Set up the encryption context and send the session data to the SD */
+ /** Set up the encryption context and send the session data to the SD */
if (has_file_data && jcr->crypto.pki_encrypt) {
if (!crypto_session_send(jcr, sd)) {
goto bail_out;
}
}
- /*
+ /**
* Open any file with data that we intend to save, then save it.
*
* Note, if is_win32_backup, we must open the Directory so that
}
if (have_darwin_os) {
- /* Regular files can have resource forks and Finder Info */
+ /** Regular files can have resource forks and Finder Info */
if (ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) &&
ff_pkt->flags & FO_HFSPLUS)) {
if (ff_pkt->hfsinfo.rsrclength > 0) {
}
}
- /*
+ /**
* Save ACLs when requested and available for anything not being a symlink and not being a plugin.
*/
if (have_acl) {
case bacl_exit_fatal:
goto bail_out;
case bacl_exit_error:
- /*
+ /**
* Non-fatal errors, count them and when the number is under ACL_REPORT_ERR_MAX_PER_JOB
* print the error message set by the lower level routine in jcr->errmsg.
*/
}
}
- /*
+ /**
* Save Extended Attributes when requested and available for all files not being a plugin.
*/
if (have_xattr) {
case bxattr_exit_fatal:
goto bail_out;
case bxattr_exit_error:
- /*
+ /**
* Non-fatal errors, count them and when the number is under XATTR_REPORT_ERR_MAX_PER_JOB
* print the error message set by the lower level routine in jcr->errmsg.
*/
}
}
- /* Terminate the signing digest and send it to the Storage daemon */
+ /** Terminate the signing digest and send it to the Storage daemon */
if (signing_digest) {
uint32_t size = 0;
goto bail_out;
}
- /* Get signature size */
+ /** Get signature size */
if (!crypto_sign_encode(sig, NULL, &size)) {
Jmsg(jcr, M_FATAL, 0, _("An error occurred while signing the stream.\n"));
goto bail_out;
}
- /* Grow the bsock buffer to fit our message if necessary */
+ /** Grow the bsock buffer to fit our message if necessary */
if (sizeof_pool_memory(sd->msg) < (int32_t)size) {
sd->msg = realloc_pool_memory(sd->msg, size);
}
- /* Send our header */
+ /** Send our header */
sd->fsend("%ld %ld 0", jcr->JobFiles, STREAM_SIGNED_DIGEST);
Dmsg1(300, "bfiled>stored:header %s\n", sd->msg);
- /* Encode signature data */
+ /** Encode signature data */
if (!crypto_sign_encode(sig, (uint8_t *)sd->msg, &size)) {
Jmsg(jcr, M_FATAL, 0, _("An error occurred while signing the stream.\n"));
goto bail_out;
sd->signal(BNET_EOD); /* end of checksum */
}
- /* Terminate any digest and send it to Storage daemon */
+ /** Terminate any digest and send it to Storage daemon */
if (digest) {
uint32_t size;
size = CRYPTO_DIGEST_MAX_SIZE;
- /* Grow the bsock buffer to fit our message if necessary */
+ /** Grow the bsock buffer to fit our message if necessary */
if (sizeof_pool_memory(sd->msg) < (int32_t)size) {
sd->msg = realloc_pool_memory(sd->msg, size);
}
*/
if (((z_stream*)jcr->pZLIB_compress_workset)->total_in == 0) {
- /* set gzip compression level - must be done per file */
+ /** set gzip compression level - must be done per file */
if ((zstat=deflateParams((z_stream*)jcr->pZLIB_compress_workset,
ff_pkt->GZIP_level, Z_DEFAULT_STRATEGY)) != Z_OK) {
Jmsg(jcr, M_FATAL, 0, _("Compression deflateParams error: %d\n"), zstat);
Jmsg0(jcr, M_FATAL, 0, _("Encrypting sparse data not supported.\n"));
goto err;
}
- /* Allocate the cipher context */
+ /** Allocate the cipher context */
if ((cipher_ctx = crypto_cipher_new(jcr->crypto.pki_session, true,
&cipher_block_size)) == NULL) {
/* Shouldn't happen! */
rbuf += SPARSE_FADDR_SIZE;
rsize -= SPARSE_FADDR_SIZE;
#ifdef HAVE_FREEBSD_OS
- /*
+ /**
* To read FreeBSD partitions, the read size must be
* a multiple of 512.
*/
#endif
}
- /* a RAW device read on win32 only works if the buffer is a multiple of 512 */
+ /** a RAW device read on win32 only works if the buffer is a multiple of 512 */
#ifdef HAVE_WIN32
if (S_ISBLK(ff_pkt->statp.st_mode))
rsize = (rsize/512) * 512;
*/
while ((sd->msglen=(uint32_t)bread(&ff_pkt->bfd, rbuf, rsize)) > 0) {
- /* Check for sparse blocks */
+ /** Check for sparse blocks */
if (ff_pkt->flags & FO_SPARSE) {
ser_declare;
bool allZeros = false;
allZeros = is_buf_zero(rbuf, rsize);
}
if (!allZeros) {
- /* Put file address as first data in buffer */
+ /** Put file address as first data in buffer */
ser_begin(wbuf, SPARSE_FADDR_SIZE);
ser_uint64(fileAddr); /* store fileAddr in begin of buffer */
}
fileAddr += sd->msglen; /* update file address */
- /* Skip block of all zeros */
+ /** Skip block of all zeros */
if (allZeros) {
continue; /* skip block of zeros */
}
jcr->ReadBytes += sd->msglen; /* count bytes read */
- /* Uncompressed cipher input length */
+ /** Uncompressed cipher input length */
cipher_input_len = sd->msglen;
- /* Update checksum if requested */
+ /** Update checksum if requested */
if (digest) {
crypto_digest_update(digest, (uint8_t *)rbuf, sd->msglen);
}
- /* Update signing digest if requested */
+ /** Update signing digest if requested */
if (signing_digest) {
crypto_digest_update(signing_digest, (uint8_t *)rbuf, sd->msglen);
}
#ifdef HAVE_LIBZ
- /* Do compression if turned on */
+ /** Do compression if turned on */
if (ff_pkt->flags & FO_GZIP && jcr->pZLIB_compress_workset) {
Dmsg3(400, "cbuf=0x%x rbuf=0x%x len=%u\n", cbuf, rbuf, sd->msglen);
goto err;
}
compress_len = ((z_stream*)jcr->pZLIB_compress_workset)->total_out;
- /* reset zlib stream to be able to begin from scratch again */
+ /** reset zlib stream to be able to begin from scratch again */
if ((zstat=deflateReset((z_stream*)jcr->pZLIB_compress_workset)) != Z_OK) {
Jmsg(jcr, M_FATAL, 0, _("Compression deflateReset error: %d\n"), zstat);
set_jcr_job_status(jcr, JS_ErrorTerminated);
cipher_input_len += SPARSE_FADDR_SIZE;
}
- /* Encrypt the length of the input block */
+ /** Encrypt the length of the input block */
uint8_t packet_len[sizeof(uint32_t)];
ser_begin(packet_len, sizeof(uint32_t));
if (!crypto_cipher_update(cipher_ctx, packet_len, sizeof(packet_len),
(uint8_t *)jcr->crypto.crypto_buf, &initial_len)) {
- /* Encryption failed. Shouldn't happen. */
+ /** Encryption failed. Shouldn't happen. */
Jmsg(jcr, M_FATAL, 0, _("Encryption error\n"));
goto err;
}
- /* Encrypt the input block */
+ /** Encrypt the input block */
if (crypto_cipher_update(cipher_ctx, cipher_input, cipher_input_len,
(uint8_t *)&jcr->crypto.crypto_buf[initial_len], &encrypted_len)) {
if ((initial_len + encrypted_len) == 0) {
- /* No full block of data available, read more data */
+ /** No full block of data available, read more data */
continue;
}
Dmsg2(400, "encrypted len=%d unencrypted len=%d\n", encrypted_len,
sd->msglen);
sd->msglen = initial_len + encrypted_len; /* set encrypted length */
} else {
- /* Encryption failed. Shouldn't happen. */
+ /** Encryption failed. Shouldn't happen. */
Jmsg(jcr, M_FATAL, 0, _("Encryption error\n"));
goto err;
}
Jmsg(jcr, M_FATAL, 0, _("Too many errors. JobErrors=%d.\n"), jcr->JobErrors);
}
} else if (ff_pkt->flags & FO_ENCRYPT) {
- /*
+ /**
* For encryption, we must call finalize to push out any
* buffered data.
*/
goto err;
}
- /* Note, on SSL pre-0.9.7, there is always some output */
+ /** Note, on SSL pre-0.9.7, there is always some output */
if (encrypted_len > 0) {
sd->msglen = encrypted_len; /* set encrypted length */
sd->msg = jcr->crypto.crypto_buf; /* set correct write buffer */
goto err;
}
- /* Free the cipher context */
+ /** Free the cipher context */
if (cipher_ctx) {
crypto_cipher_free(cipher_ctx);
}
return 1;
err:
- /* Free the cipher context */
+ /** Free the cipher context */
if (cipher_ctx) {
crypto_cipher_free(cipher_ctx);
}
#endif
Dmsg1(300, "encode_and_send_attrs fname=%s\n", ff_pkt->fname);
- /* Find what data stream we will use, then encode the attributes */
+ /** Find what data stream we will use, then encode the attributes */
if ((data_stream = select_data_stream(ff_pkt)) == STREAM_NONE) {
/* This should not happen */
Jmsg0(jcr, M_FATAL, 0, _("Invalid file flags, no supported data stream type.\n"));
}
encode_stat(attribs, &ff_pkt->statp, ff_pkt->LinkFI, data_stream);
- /* Now possibly extend the attributes */
+ /** Now possibly extend the attributes */
attr_stream = encode_attribsEx(jcr, attribsEx, ff_pkt);
Dmsg3(300, "File %s\nattribs=%s\nattribsEx=%s\n", ff_pkt->fname, attribs, attribsEx);
pm_strcpy(jcr->last_fname, ff_pkt->fname);
jcr->unlock();
- /*
+ /**
* Send Attributes header to Storage daemon
* <file-index> <stream> <info>
*/
}
Dmsg1(300, ">stored: attrhdr %s\n", sd->msg);
- /*
+ /**
* Send file attributes to Storage daemon
* File_index
* File type
int stripped;
int numsep = 0;
- /* Copy to first path separator -- Win32 might have c: ... */
+ /** Copy to first path separator -- Win32 might have c: ... */
while (*in && !IsPathSeparator(*in)) {
out++; in++;
}
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2002-2009 Free Software Foundation Europe e.V.
+ Copyright (C) 2002-2010 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
-/*
+/**
* Encode and decode standard Unix attributes and
* Extended attributes for Win32 and
* other non-Unix systems, or Unix systems with ACLs, ...
*
* Kern Sibbald, October MMII
*
- * Version $Id$
- *
*/
#include "bacula.h"
/* */
/*=============================================================*/
-/*
+/**
* Return the data stream that will be used
*/
int select_data_stream(FF_PKT *ff_pkt)
{
int stream;
- /*
+ /**
* Fix all incompatible options
*/
-
- /* No sparse option for encrypted data */
+ /** No sparse option for encrypted data */
if (ff_pkt->flags & FO_ENCRYPT) {
ff_pkt->flags &= ~FO_SPARSE;
}
- /* Note, no sparse option for win32_data */
+ /** Note, no sparse option for win32_data */
if (!is_portable_backup(&ff_pkt->bfd)) {
stream = STREAM_WIN32_DATA;
ff_pkt->flags &= ~FO_SPARSE;
stream = STREAM_FILE_DATA;
}
- /* Encryption is only supported for file data */
+ /** Encryption is only supported for file data */
if (stream != STREAM_FILE_DATA && stream != STREAM_WIN32_DATA &&
stream != STREAM_MACOS_FORK_DATA) {
ff_pkt->flags &= ~FO_ENCRYPT;
}
- /* Compression is not supported for Mac fork data */
+ /** Compression is not supported for Mac fork data */
if (stream == STREAM_MACOS_FORK_DATA) {
ff_pkt->flags &= ~FO_GZIP;
}
- /*
+ /**
* Handle compression and encryption options
*/
#ifdef HAVE_LIBZ
stream = STREAM_GZIP_DATA;
break;
default:
- /* All stream types that do not support gzip should clear out
- * FO_GZIP above, and this code block should be unreachable. */
+ /**
+ * All stream types that do not support gzip should clear out
+ * FO_GZIP above, and this code block should be unreachable.
+ */
ASSERT(!(ff_pkt->flags & FO_GZIP));
return STREAM_NONE;
}
}
-/*
+/**
* Encode a stat structure into a base64 character string
* All systems must create such a structure.
* In addition, we tack on the LinkFI, which is non-zero in
{
char *p = buf;
- /*
+ /**
* Encode a stat packet. I should have done this more intelligently
* with a length so that it could be easily expanded.
*/
#endif
-/* Decode a stat packet from base64 characters */
+/** Decode a stat packet from base64 characters */
int decode_stat(char *buf, struct stat *statp, int32_t *LinkFI)
{
char *p = buf;
return (int)val;
}
-/* Decode a LinkFI field of encoded stat packet */
+/** Decode a LinkFI field of encoded stat packet */
int32_t decode_LinkFI(char *buf, struct stat *statp)
{
char *p = buf;
return 0;
}
-/*
+/**
* Set file modes, permissions and times
*
* fname is the original filename
}
- /*
+ /**
* If Windows stuff failed, e.g. attempt to restore Unix file
* to Windows, simply fall through and we will do it the
* universal way.
}
}
- /*
+ /**
* We do not restore sockets, so skip trying to restore their
* attributes.
*/
ut.modtime = attr->statp.st_mtime;
/* ***FIXME**** optimize -- don't do if already correct */
- /*
+ /**
* For link, change owner of link using lchown, but don't
* try to do a chmod as that will update the file behind it.
*/
if (attr->type == FT_LNK) {
- /* Change owner of link, not of real file */
+ /** Change owner of link, not of real file */
if (lchown(attr->ofname, attr->statp.st_uid, attr->statp.st_gid) < 0 && my_uid == 0) {
berrno be;
Jmsg2(jcr, M_ERROR, 0, _("Unable to set file owner %s: ERR=%s\n"),
ok = false;
}
- /*
+ /**
* Reset file times.
*/
if (utime(attr->ofname, &ut) < 0 && my_uid == 0) {
ok = false;
}
#ifdef HAVE_CHFLAGS
- /*
+ /**
* FreeBSD user flags
*
* Note, this should really be done before the utime() above,
#if !defined(HAVE_WIN32)
-/*
+/**
* It is possible to piggyback additional data e.g. ACLs on
* the encode_stat() data by returning the extended attributes
* here. They must be "self-contained" (i.e. you keep track
int encode_attribsEx(JCR *jcr, char *attribsEx, FF_PKT *ff_pkt)
{
#ifdef HAVE_DARWIN_OS
- /*
+ /**
* We save the Mac resource fork length so that on a
* restore, we can be sure we put back the whole resource.
*/
unix_name_to_win32(&ff_pkt->sys_fname, ff_pkt->fname);
- // try unicode version
+ /** try unicode version */
if (p_GetFileAttributesExW) {
POOLMEM* pwszBuf = get_pool_memory(PM_FNAME);
make_win32_path_UTF8_2_wchar(&pwszBuf, ff_pkt->fname);
return STREAM_UNIX_ATTRIBUTES_EX;
}
-/* Define attributes that are legal to set with SetFileAttributes() */
+/** Define attributes that are legal to set with SetFileAttributes() */
#define SET_ATTRS ( \
FILE_ATTRIBUTE_ARCHIVE| \
FILE_ATTRIBUTE_HIDDEN| \
FILE_ATTRIBUTE_TEMPORARY)
-/*
+/**
* Set Extended File Attributes for Win32
*
* fname is the original filename
ULARGE_INTEGER li;
POOLMEM *win32_ofile;
- // if we have neither ansi nor wchar version, we leave
+ /** if we have neither Win ansi nor wchar API, get out */
if (!(p_SetFileAttributesW || p_SetFileAttributesA)) {
return false;
}
p += from_base64(&val, p);
plug(atts.nFileSizeLow, val);
- /* Convert to Windows path format */
+ /** Convert to Windows path format */
win32_ofile = get_pool_memory(PM_FNAME);
unix_name_to_win32(&win32_ofile, attr->ofname);
- /* At this point, we have reconstructed the WIN32_FILE_ATTRIBUTE_DATA pkt */
+ /** At this point, we have reconstructed the WIN32_FILE_ATTRIBUTE_DATA pkt */
if (!is_bopen(ofd)) {
Dmsg1(100, "File not open: %s\n", attr->ofname);