-static int open_data_spool_file(JCR *jcr)
-{
- POOLMEM *name = get_pool_memory(PM_MESSAGE);
- int spool_fd;
-
- make_unique_data_spool_filename(jcr, &name);
- if ((spool_fd = open(name, O_CREAT|O_TRUNC|O_RDWR|O_BINARY, 0640)) >= 0) {
- jcr->dcr->spool_fd = spool_fd;
- jcr->spool_attributes = true;
- } else {
- Jmsg(jcr, M_ERROR, 0, "open data spool file %s failed: ERR=%s\n", name, strerror(errno));
- free_pool_memory(name);
- return 0;
- }
- free_pool_memory(name);
- return 1;
-}
-
-static int close_data_spool_file(JCR *jcr)
-{
- POOLMEM *name = get_pool_memory(PM_MESSAGE);
-
- make_unique_data_spool_filename(jcr, &name);
- close(jcr->dcr->spool_fd);
- jcr->dcr->spool_fd = -1;
- unlink(name);
- free_pool_memory(name);
- return 1;
-}
-
-
-static bool are_attributes_spooled(JCR *jcr)
-{
- return jcr->spool_attributes && jcr->dir_bsock->spool_fd;
-}
-
-static int begin_attribute_spool(JCR *jcr)
-{
- if (!jcr->no_attributes && jcr->spool_attributes) {
- return open_spool_file(jcr, jcr->dir_bsock);
- }
- return 1;
-}
-
-static int discard_attribute_spool(JCR *jcr)
-{
- if (are_attributes_spooled(jcr)) {
- return close_spool_file(jcr, jcr->dir_bsock);
- }
- return 1;
-}
-
-static int commit_attribute_spool(JCR *jcr)
-{
- if (are_attributes_spooled(jcr)) {
- bnet_despool_to_bsock(jcr->dir_bsock);
- return close_spool_file(jcr, jcr->dir_bsock);
- }
- return 1;