]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/filed/plugins/node.c
Make out of freespace non-fatal for removable devices -- i.e. behaves like tape
[bacula/bacula] / bacula / src / win32 / filed / plugins / node.c
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2018 Kern Sibbald
5
6    The original author of Bacula is Kern Sibbald, with contributions
7    from many others, a complete list can be found in the file AUTHORS.
8
9    You may use this file and others of this release according to the
10    license defined in the LICENSE file, which includes the Affero General
11    Public License, v3.0 ("AGPLv3") and some additional permissions and
12    terms pursuant to its AGPLv3 Section 7.
13
14    This notice must be preserved when any source code is
15    conveyed and/or propagated.
16
17    Bacula(R) is a registered trademark of Kern Sibbald.
18 */
19 /* 
20  *  Written by James Harper, October 2008
21  */
22
23 #include "exchange-fd.h"
24
25 node_t::node_t(char *name, int type)
26 {
27    this->type = type;
28    state = 0;
29    parent = NULL;
30    this->name = bstrdup(name);
31    full_path = make_full_path();
32    size = 0;
33    level = 0;
34 }
35
36 node_t::node_t(char *name, int type, node_t *parent_node)
37 {
38    this->type = type;
39    state = 0;
40    parent = parent_node;
41    this->name = bstrdup(name);
42    full_path = make_full_path();
43    size = 0;
44    level = parent->level + 1;
45 }
46
47 node_t::~node_t()
48 {
49    delete name;
50    delete full_path;
51 }
52
53 char *
54 node_t::make_full_path()
55 {
56    node_t *curr_node;
57    int len;
58    char *retval;
59
60    for (len = 0, curr_node = this; curr_node != NULL; curr_node = curr_node->parent)
61    {
62       len += strlen(curr_node->name) + 1;
63    }
64    if (type == NODE_TYPE_FILE || type == NODE_TYPE_DATABASE_INFO)
65    {
66       retval = new char[len + 1];
67       retval[len] = 0;
68    }
69    else
70    {
71       retval = new char[len + 2];
72       retval[len] = '/';
73       retval[len + 1] = 0;
74    }
75    for (curr_node = this; curr_node != NULL; curr_node = curr_node->parent)
76    {
77       len -= strlen(curr_node->name);
78       memcpy(retval + len, curr_node->name, strlen(curr_node->name));
79       retval[--len] = '/';
80    }
81    return retval;
82 }
83
84 bRC
85 node_t::pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io)
86 {
87    _DebugMessage(100, "pluginIoOpen_Node\n");
88    io->status = 0;
89    io->io_errno = 0;
90    return bRC_OK;
91 }
92
93 bRC
94 node_t::pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io)
95 {
96    _DebugMessage(100, "pluginIoRead_Node\n");
97    io->status = 0;
98    io->io_errno = 0;
99    return bRC_OK;
100 }
101
102 bRC
103 node_t::pluginIoWrite(exchange_fd_context_t *context, struct io_pkt *io)
104 {
105    _DebugMessage(100, "pluginIoWrite_Node\n");
106    io->status = 0;
107    io->io_errno = 1;
108    return bRC_Error;
109 }
110
111 bRC
112 node_t::pluginIoClose(exchange_fd_context_t *context, struct io_pkt *io)
113 {
114    _DebugMessage(100, "pluginIoClose_Node\n");
115    io->status = 0;
116    io->io_errno = 0;
117    return bRC_OK;
118 }