Print this page
NEX-9532 NDMP: readdir errors when file/directory has special characters
Reviewed by: Peer Dampmann <peer.dampmann@nexenta.com>
Reviewed by: Alexander Eremin <alexander.eremin@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-5801 Snapshots left over after failed backups
Reviewed by: Rick Mesta <rick.mesta@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Revert "NEX-5801 Snapshots left over after failed backups"
This reverts commit f182fb95f09036db71fbfc6f0a6b90469b761f21.
NEX-5801 Snapshots left over after failed backups
Reviewed by: Rick Mesta <rick.mesta@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-2911 NDMP logging should use syslog and is too chatty
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/cmd/ndmpd/ndmp/ndmpd_fhistory.c
+++ new/usr/src/cmd/ndmpd/ndmp/ndmpd_fhistory.c
1 1 /*
2 2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
3 3 */
4 4
5 5 /*
6 6 * BSD 3 Clause License
7 7 *
8 8 * Copyright (c) 2007, The Storage Networking Industry Association.
9 9 *
10 10 * Redistribution and use in source and binary forms, with or without
11 11 * modification, are permitted provided that the following conditions
12 12 * are met:
13 13 * - Redistributions of source code must retain the above copyright
14 14 * notice, this list of conditions and the following disclaimer.
15 15 *
16 16 * - Redistributions in binary form must reproduce the above copyright
17 17 * notice, this list of conditions and the following disclaimer in
18 18 * the documentation and/or other materials provided with the
19 19 * distribution.
20 20 *
21 21 * - Neither the name of The Storage Networking Industry Association (SNIA)
22 22 * nor the names of its contributors may be used to endorse or promote
23 23 * products derived from this software without specific prior written
24 24 * permission.
25 25 *
26 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
↓ open down ↓ |
29 lines elided |
↑ open up ↑ |
30 30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 36 * POSSIBILITY OF SUCH DAMAGE.
37 37 */
38 38 /* Copyright (c) 1996, 1997 PDC, Network Appliance. All Rights Reserved */
39 39 /* Copyright (c) 2007, The Storage Networking Industry Association. */
40 +/* Copyright 2017 Nexenta Systems, Inc. All rights reserved. */
40 41
41 42 /*
42 43 * File history callback functions called by backup modules. NDMP file history
43 44 * supports 2 file history models: path based and inode/directory based.
44 45 * Backup/recover modules similar to unix dump/restore utilize the
45 46 * inode/directory based model. During the filesystem scan pass,
46 47 * ndmpd_file_history_dir() is called. During the file backup pass,
47 48 * ndmpd_file_history_node() is called. This model is appropriate for
48 49 * modules whose code is structured such that file name and file attribute
49 50 * data is not available at the same time. Backup/recover modules similar
50 51 * to tar or cpio utilize the path based model. The simple dump/restore module
51 52 * included with the SDK uses the path based model.
52 53 */
53 54
54 55 #include <sys/stat.h>
55 56 #include <sys/types.h>
57 +#include <syslog.h>
56 58 #include <dirent.h>
57 59 #include <errno.h>
58 60 #include <stdlib.h>
59 61 #include <string.h>
60 62 #include "ndmpd.h"
61 63 #include <dirent.h>
62 64 #include <bitmap.h>
63 65
64 66
65 67 #define N_PATH_ENTRIES 1000
66 68 #define N_FILE_ENTRIES N_PATH_ENTRIES
67 69 #define N_DIR_ENTRIES 1000
68 70 #define N_NODE_ENTRIES 1000
69 71
70 72 /* Figure an average of 32 bytes per path name */
71 73 #define PATH_NAMEBUF_SIZE (N_PATH_ENTRIES * 32)
72 74
73 75 /* Figure an average of 16 bytes per file name */
74 76 #define DIR_NAMEBUF_SIZE (N_PATH_ENTRIES * 16)
75 77
76 78 static boolean_t fh_requested(void *cookie);
77 79 static void ndmpd_file_history_cleanup_v2(ndmpd_session_t *session,
78 80 boolean_t send_flag);
79 81 static void ndmpd_file_history_cleanup_v3(ndmpd_session_t *session,
80 82 boolean_t send_flag);
81 83 static ndmpd_module_params_t *get_params(void *cookie);
82 84
83 85
84 86 /*
85 87 * Each file history as a separate message to the client.
86 88 */
87 89 static int ndmp_syncfh = 0;
88 90
89 91
90 92 /*
91 93 * ************************************************************************
92 94 * NDMP V2 HANDLERS
93 95 * ************************************************************************
94 96 */
95 97
96 98 /*
97 99 * ndmpd_api_file_history_path_v2
98 100 *
99 101 * Add a file history path entry to the buffer.
100 102 * History data is buffered until the buffer is filled.
101 103 * Full buffers are then sent to the client.
102 104 *
103 105 * Parameters:
104 106 * cookie (input) - session pointer.
105 107 * name (input) - file name.
106 108 * NULL forces buffered data to be sent.
107 109 * file_stat (input) - file status pointer.
108 110 * fh_info (input) - data stream position of file data used during
109 111 * fast restore.
110 112 *
111 113 * Returns:
112 114 * 0 - success
113 115 * -1 - error
114 116 */
115 117 int
116 118 ndmpd_api_file_history_path_v2(void *cookie, char *name,
117 119 struct stat64 *file_stat, u_longlong_t fh_info)
118 120 {
119 121 ndmpd_session_t *session = (ndmpd_session_t *)cookie;
120 122 ndmp_fh_unix_path *entry;
121 123
122 124 if (name == NULL && session->ns_fh.fh_path_index == 0)
123 125 return (0);
124 126
125 127 /*
126 128 * If the buffer does not have space
|
↓ open down ↓ |
61 lines elided |
↑ open up ↑ |
127 129 * for the current entry, send the buffered data to the client.
128 130 * A NULL name indicates that any buffered data should be sent.
129 131 */
130 132 if (name == NULL ||
131 133 (ndmp_syncfh && session->ns_fh.fh_path_index != 0) ||
132 134 session->ns_fh.fh_path_index == N_PATH_ENTRIES ||
133 135 session->ns_fh.fh_path_name_buf_index + strlen(name) + 1 >
134 136 PATH_NAMEBUF_SIZE) {
135 137 ndmp_fh_add_unix_path_request request;
136 138
137 - NDMP_LOG(LOG_DEBUG,
138 - "sending %ld entries", session->ns_fh.fh_path_index);
139 139
140 140 request.paths.paths_val = session->ns_fh.fh_path_entries;
141 141 request.paths.paths_len = session->ns_fh.fh_path_index;
142 142
143 143 if (ndmp_send_request_lock(session->ns_connection,
144 144 NDMP_FH_ADD_UNIX_PATH, NDMP_NO_ERR, (void *) &request,
145 145 0) < 0) {
146 - NDMP_LOG(LOG_DEBUG, "Sending file history data");
146 + syslog(LOG_ERR, "Sending file history data failed");
147 147 return (-1);
148 148 }
149 149 session->ns_fh.fh_path_index = 0;
150 150 session->ns_fh.fh_path_name_buf_index = 0;
151 151 }
152 152 if (name == NULL)
153 153 return (0);
154 154
155 155 if (session->ns_fh.fh_path_entries == 0) {
156 156 session->ns_fh.fh_path_entries = ndmp_malloc(N_PATH_ENTRIES *
157 157 sizeof (ndmp_fh_unix_path));
158 158 if (session->ns_fh.fh_path_entries == 0)
159 159 return (-1);
160 160 }
161 161 if (session->ns_fh.fh_path_name_buf == 0) {
162 162 session->ns_fh.fh_path_name_buf =
163 163 ndmp_malloc(PATH_NAMEBUF_SIZE);
164 164 if (session->ns_fh.fh_path_name_buf == 0)
165 165 return (-1);
166 166 }
167 167 entry = &session->ns_fh.fh_path_entries[session->ns_fh.fh_path_index];
168 168 ndmpd_get_file_entry_type(file_stat->st_mode, &entry->fstat.ftype);
169 169
170 170 entry->name = &session->
171 171 ns_fh.fh_path_name_buf[session->ns_fh.fh_path_name_buf_index];
172 172 (void) strlcpy(entry->name, name, PATH_NAMEBUF_SIZE);
173 173 session->ns_fh.fh_path_name_buf_index += strlen(name) + 1;
174 174 entry->fstat.mtime = (ulong_t)file_stat->st_mtime;
175 175 entry->fstat.atime = (ulong_t)file_stat->st_atime;
176 176 entry->fstat.ctime = (ulong_t)file_stat->st_ctime;
177 177 entry->fstat.uid = file_stat->st_uid;
178 178 entry->fstat.gid = file_stat->st_gid;
179 179 entry->fstat.mode = (file_stat->st_mode) & 0x0fff;
180 180 entry->fstat.size = long_long_to_quad((u_longlong_t)file_stat->st_size);
181 181 entry->fstat.fh_info = long_long_to_quad((u_longlong_t)fh_info);
182 182 session->ns_fh.fh_path_index++;
183 183 return (0);
184 184 }
185 185
186 186
187 187 /*
188 188 * ndmpd_api_file_history_dir_v2
189 189 *
190 190 * Add a file history dir entry to the buffer.
191 191 * History data is buffered until the buffer is filled.
192 192 * Full buffers are then sent to the client.
193 193 *
194 194 * Parameters:
195 195 * cookie (input) - session pointer.
196 196 * name (input) - file name.
197 197 * NULL forces buffered data to be sent.
198 198 * node (input) - file inode.
199 199 * parent (input) - file parent inode.
200 200 * Should equal node if the file is the root of
201 201 * the filesystem and has no parent.
202 202 *
203 203 * Returns:
204 204 * 0 - success
205 205 * -1 - error
206 206 */
207 207 int
208 208 ndmpd_api_file_history_dir_v2(void *cookie, char *name, ulong_t node,
209 209 ulong_t parent)
210 210 {
211 211 ndmpd_session_t *session = (ndmpd_session_t *)cookie;
212 212 ndmp_fh_unix_dir *entry;
213 213
214 214 if (name == NULL && session->ns_fh.fh_dir_index == 0)
215 215 return (0);
216 216
217 217 /*
218 218 * If the buffer does not have space for the current entry,
|
↓ open down ↓ |
62 lines elided |
↑ open up ↑ |
219 219 * send the buffered data to the client. A NULL name indicates
220 220 * that any buffered data should be sent.
221 221 */
222 222 if (name == NULL ||
223 223 (ndmp_syncfh && session->ns_fh.fh_dir_index != 0) ||
224 224 session->ns_fh.fh_dir_index == N_DIR_ENTRIES ||
225 225 session->ns_fh.fh_dir_name_buf_index + strlen(name) + 1 >
226 226 DIR_NAMEBUF_SIZE) {
227 227 ndmp_fh_add_unix_dir_request request;
228 228
229 - NDMP_LOG(LOG_DEBUG,
230 - "sending %ld entries", session->ns_fh.fh_dir_index);
231 -
232 229 request.dirs.dirs_val = session->ns_fh.fh_dir_entries;
233 230 request.dirs.dirs_len = session->ns_fh.fh_dir_index;
234 231 if (ndmp_send_request_lock(session->ns_connection,
235 232 NDMP_FH_ADD_UNIX_DIR, NDMP_NO_ERR, (void *) &request,
236 233 0) < 0) {
237 - NDMP_LOG(LOG_DEBUG, "Sending file history data");
234 + syslog(LOG_DEBUG, "Sending file history data");
238 235 return (-1);
239 236 }
240 237 session->ns_fh.fh_dir_index = 0;
241 238 session->ns_fh.fh_dir_name_buf_index = 0;
242 239 }
243 240 if (name == NULL)
244 241 return (0);
245 242
246 243 if (session->ns_fh.fh_dir_entries == 0) {
247 244 session->ns_fh.fh_dir_entries = ndmp_malloc(N_DIR_ENTRIES
248 245 * sizeof (ndmp_fh_unix_dir));
249 246 if (session->ns_fh.fh_dir_entries == 0)
250 247 return (-1);
251 248 }
252 249 if (session->ns_fh.fh_dir_name_buf == 0) {
253 250 session->ns_fh.fh_dir_name_buf = ndmp_malloc(DIR_NAMEBUF_SIZE);
254 251 if (session->ns_fh.fh_dir_name_buf == 0)
255 252 return (-1);
256 253 }
257 254 entry = &session->ns_fh.fh_dir_entries[session->ns_fh.fh_dir_index];
258 255
259 256 entry->name = &session->
260 257 ns_fh.fh_dir_name_buf[session->ns_fh.fh_dir_name_buf_index];
261 258 (void) strlcpy(&session->
262 259 ns_fh.fh_dir_name_buf[session->ns_fh.fh_dir_name_buf_index],
263 260 name, PATH_NAMEBUF_SIZE);
264 261 session->ns_fh.fh_dir_name_buf_index += strlen(name) + 1;
265 262
266 263 entry->node = node;
267 264 entry->parent = parent;
268 265
269 266 session->ns_fh.fh_dir_index++;
270 267 return (0);
271 268 }
272 269
273 270
274 271 /*
275 272 * ndmpd_api_file_history_node_v2
276 273 *
277 274 * Add a file history node entry to the buffer.
278 275 * History data is buffered until the buffer is filled.
279 276 * Full buffers are then sent to the client.
280 277 *
281 278 * Parameters:
282 279 * cookie (input) - session pointer.
283 280 * node (input) - file inode.
284 281 * must match a node from a prior ndmpd_api_file_history_dir()
285 282 * call.
286 283 * file_stat (input) - file status pointer.
287 284 * 0 forces buffered data to be sent.
288 285 * fh_info (input) - data stream position of file data used during
289 286 * fast restore.
290 287 *
291 288 * Returns:
292 289 * 0 - success
293 290 * -1 - error.
294 291 */
295 292 int
296 293 ndmpd_api_file_history_node_v2(void *cookie, ulong_t node,
297 294 struct stat64 *file_stat, u_longlong_t fh_info)
298 295 {
299 296 ndmpd_session_t *session = (ndmpd_session_t *)cookie;
300 297 ndmp_fh_unix_node *entry;
301 298
302 299 if (file_stat == NULL && session->ns_fh.fh_node_index == 0)
303 300 return (-1);
304 301
305 302 /*
|
↓ open down ↓ |
58 lines elided |
↑ open up ↑ |
306 303 * If the buffer does not have space
307 304 * for the current entry, send the buffered data to the client.
308 305 * A 0 file_stat pointer indicates that any buffered data should
309 306 * be sent.
310 307 */
311 308 if (file_stat == NULL ||
312 309 (ndmp_syncfh && session->ns_fh.fh_node_index != 0) ||
313 310 session->ns_fh.fh_node_index == N_NODE_ENTRIES) {
314 311 ndmp_fh_add_unix_node_request request;
315 312
316 - NDMP_LOG(LOG_DEBUG,
317 - "sending %ld entries", session->ns_fh.fh_node_index);
318 -
319 313 request.nodes.nodes_val = session->ns_fh.fh_node_entries;
320 314 request.nodes.nodes_len = session->ns_fh.fh_node_index;
321 315 /*
322 316 * Need to send Dir entry as well. Since Dir entry is more than
323 317 * Node entry, we may send a Node entry that hasn't have
324 318 * its dir entry sent. Therefore, we need to flush Dir entry
325 319 * as well everytime the Dir entry is send.
326 320 */
327 321 (void) ndmpd_api_file_history_dir_v2(session, 0, 0, 0);
328 322
329 323 if (ndmp_send_request_lock(session->ns_connection,
330 324 NDMP_FH_ADD_UNIX_NODE, NDMP_NO_ERR, (void *) &request,
331 325 0) < 0) {
332 - NDMP_LOG(LOG_DEBUG, "Sending file history data");
326 + syslog(LOG_ERR, "Sending file history data failed");
333 327 return (-1);
334 328 }
335 329 session->ns_fh.fh_node_index = 0;
336 330 }
337 331 if (file_stat == NULL)
338 332 return (0);
339 333
340 334 if (session->ns_fh.fh_node_entries == 0) {
341 335 session->ns_fh.fh_node_entries = ndmp_malloc(N_NODE_ENTRIES
342 336 * sizeof (ndmp_fh_unix_node));
343 337 if (session->ns_fh.fh_node_entries == 0)
344 338 return (-1);
345 339 }
346 340 entry = &session->ns_fh.fh_node_entries[session->ns_fh.fh_node_index];
347 341 ndmpd_get_file_entry_type(file_stat->st_mode, &entry->fstat.ftype);
348 342
349 343 entry->node = node;
350 344 entry->fstat.mtime = (ulong_t)file_stat->st_mtime;
351 345 entry->fstat.atime = (ulong_t)file_stat->st_atime;
352 346 entry->fstat.ctime = (ulong_t)file_stat->st_ctime;
353 347 entry->fstat.uid = file_stat->st_uid;
354 348 entry->fstat.gid = file_stat->st_gid;
355 349 entry->fstat.mode = (file_stat->st_mode) & 0x0fff;
356 350 entry->fstat.size = long_long_to_quad((u_longlong_t)file_stat->st_size);
357 351 entry->fstat.fh_info = long_long_to_quad(fh_info);
358 352
359 353 session->ns_fh.fh_node_index++;
360 354 return (0);
361 355 }
362 356
363 357
364 358 /*
365 359 * ************************************************************************
366 360 * NDMP V3 HANDLERS
367 361 * ************************************************************************
368 362 */
369 363
370 364 /*
371 365 * ndmpd_api_file_history_file_v3
372 366 *
373 367 * Add a file history file entry to the buffer.
374 368 * History data is buffered until the buffer is filled.
375 369 * Full buffers are then sent to the client.
376 370 *
377 371 * Parameters:
378 372 * cookie (input) - session pointer.
379 373 * name (input) - file name.
380 374 * NULL forces buffered data to be sent.
381 375 * file_stat (input) - file status pointer.
382 376 * fh_info (input) - data stream position of file data used during
383 377 * fast restore.
384 378 *
385 379 * Returns:
386 380 * 0 - success
387 381 * -1 - error
388 382 */
389 383 int
390 384 ndmpd_api_file_history_file_v3(void *cookie, char *name,
391 385 struct stat64 *file_stat, u_longlong_t fh_info)
392 386 {
393 387 ndmpd_session_t *session = (ndmpd_session_t *)cookie;
394 388 ndmp_file_v3 *file_entry;
395 389 ndmp_file_name_v3 *file_name_entry;
396 390 ndmp_file_stat_v3 *file_stat_entry;
397 391 ndmp_fh_add_file_request_v3 request;
398 392
399 393 if (name == NULL && session->ns_fh_v3.fh_file_index == 0)
400 394 return (0);
401 395
|
↓ open down ↓ |
59 lines elided |
↑ open up ↑ |
402 396 /*
403 397 * If the buffer does not have space
404 398 * for the current entry, send the buffered data to the client.
405 399 * A NULL name indicates that any buffered data should be sent.
406 400 */
407 401 if (name == NULL ||
408 402 session->ns_fh_v3.fh_file_index == N_FILE_ENTRIES ||
409 403 session->ns_fh_v3.fh_file_name_buf_index + strlen(name) + 1 >
410 404 PATH_NAMEBUF_SIZE) {
411 405
412 - NDMP_LOG(LOG_DEBUG, "sending %ld entries",
413 - session->ns_fh_v3.fh_file_index);
414 -
415 406 request.files.files_len = session->ns_fh_v3.fh_file_index;
416 407 request.files.files_val = session->ns_fh_v3.fh_files;
417 408
418 409 if (ndmp_send_request_lock(session->ns_connection,
419 410 NDMP_FH_ADD_FILE, NDMP_NO_ERR, (void *) &request, 0) < 0) {
420 - NDMP_LOG(LOG_DEBUG,
421 - "Sending ndmp_fh_add_file request");
411 + syslog(LOG_ERR,
412 + "Sending ndmp_fh_add_file request failed");
422 413 return (-1);
423 414 }
424 415
425 416 session->ns_fh_v3.fh_file_index = 0;
426 417 session->ns_fh_v3.fh_file_name_buf_index = 0;
427 418 }
428 419
429 420 if (name == NULL)
430 421 return (0);
431 422
432 423 if (session->ns_fh_v3.fh_files == 0) {
433 424 session->ns_fh_v3.fh_files = ndmp_malloc(sizeof (ndmp_file_v3) *
434 425 N_FILE_ENTRIES);
435 426 if (session->ns_fh_v3.fh_files == 0)
436 427 return (-1);
437 428 }
438 429
439 430 if (session->ns_fh_v3.fh_file_names == 0) {
440 431 session->ns_fh_v3.fh_file_names =
441 432 ndmp_malloc(sizeof (ndmp_file_name_v3) * N_FILE_ENTRIES);
442 433 if (session->ns_fh_v3.fh_file_names == 0)
443 434 return (-1);
444 435 }
445 436
446 437 if (session->ns_fh_v3.fh_file_name_buf == 0) {
447 438 session->ns_fh_v3.fh_file_name_buf =
448 439 ndmp_malloc(sizeof (char) * PATH_NAMEBUF_SIZE);
449 440 if (session->ns_fh_v3.fh_file_name_buf == 0)
450 441 return (-1);
451 442 }
452 443
453 444 if (session->ns_fh_v3.fh_file_stats == 0) {
454 445 session->ns_fh_v3.fh_file_stats =
455 446 ndmp_malloc(sizeof (ndmp_file_stat_v3) * N_FILE_ENTRIES);
456 447 if (session->ns_fh_v3.fh_file_stats == 0)
457 448 return (-1);
458 449 }
459 450
460 451 file_entry =
461 452 &session->ns_fh_v3.fh_files[session->ns_fh_v3.fh_file_index];
462 453 file_name_entry =
463 454 &session->ns_fh_v3.fh_file_names[session->ns_fh_v3.fh_file_index];
464 455 file_stat_entry =
465 456 &session->ns_fh_v3.fh_file_stats[session->ns_fh_v3.fh_file_index];
466 457 file_entry->names.names_len = 1;
467 458 file_entry->names.names_val = file_name_entry;
468 459 file_entry->stats.stats_len = 1;
469 460 file_entry->stats.stats_val = file_stat_entry;
470 461 file_entry->node = long_long_to_quad(file_stat->st_ino);
471 462 file_entry->fh_info = long_long_to_quad(fh_info);
472 463
473 464 file_name_entry->fs_type = NDMP_FS_UNIX;
474 465 file_name_entry->ndmp_file_name_v3_u.unix_name =
475 466 &session->ns_fh_v3.fh_file_name_buf[session->
476 467 ns_fh_v3.fh_file_name_buf_index];
477 468 (void) strlcpy(&session->ns_fh_v3.fh_file_name_buf[session->
478 469 ns_fh_v3.fh_file_name_buf_index], name, PATH_NAMEBUF_SIZE);
479 470 session->ns_fh_v3.fh_file_name_buf_index += strlen(name) + 1;
480 471 ndmpd_get_file_entry_type(file_stat->st_mode, &file_stat_entry->ftype);
481 472
482 473 file_stat_entry->invalid = 0;
483 474 file_stat_entry->fs_type = NDMP_FS_UNIX;
484 475 file_stat_entry->mtime = file_stat->st_mtime;
485 476 file_stat_entry->atime = file_stat->st_atime;
486 477 file_stat_entry->ctime = file_stat->st_ctime;
487 478 file_stat_entry->owner = file_stat->st_uid;
488 479 file_stat_entry->group = file_stat->st_gid;
489 480 file_stat_entry->fattr = file_stat->st_mode & 0x0fff;
490 481 file_stat_entry->size =
491 482 long_long_to_quad((u_longlong_t)file_stat->st_size);
492 483 file_stat_entry->links = file_stat->st_nlink;
493 484
494 485 session->ns_fh_v3.fh_file_index++;
495 486
496 487 return (0);
497 488 }
498 489
499 490
500 491 /*
501 492 * ndmpd_api_file_history_dir_v3
502 493 *
503 494 * Add a file history dir entry to the buffer.
504 495 * History data is buffered until the buffer is filled.
505 496 * Full buffers are then sent to the client.
506 497 *
507 498 * Parameters:
508 499 * cookie (input) - session pointer.
509 500 * name (input) - file name.
510 501 * NULL forces buffered data to be sent.
511 502 * node (input) - file inode.
512 503 * parent (input) - file parent inode.
513 504 * Should equal node if the file is the root of
514 505 * the filesystem and has no parent.
515 506 *
516 507 * Returns:
517 508 * 0 - success
518 509 * -1 - error
519 510 */
520 511 int
521 512 ndmpd_api_file_history_dir_v3(void *cookie, char *name, ulong_t node,
522 513 ulong_t parent)
523 514 {
524 515 ndmpd_session_t *session = (ndmpd_session_t *)cookie;
525 516 ndmp_dir_v3 *dir_entry;
526 517 ndmp_file_name_v3 *dir_name_entry;
527 518 ndmp_fh_add_dir_request_v3 request;
528 519
529 520 if (name == NULL && session->ns_fh_v3.fh_dir_index == 0)
530 521 return (0);
531 522
|
↓ open down ↓ |
100 lines elided |
↑ open up ↑ |
532 523 /*
533 524 * If the buffer does not have space
534 525 * for the current entry, send the buffered data to the client.
535 526 * A NULL name indicates that any buffered data should be sent.
536 527 */
537 528 if (name == NULL ||
538 529 session->ns_fh_v3.fh_dir_index == N_DIR_ENTRIES ||
539 530 session->ns_fh_v3.fh_dir_name_buf_index + strlen(name) + 1 >
540 531 DIR_NAMEBUF_SIZE) {
541 532
542 - NDMP_LOG(LOG_DEBUG, "sending %ld entries",
543 - session->ns_fh_v3.fh_dir_index);
544 -
545 533 request.dirs.dirs_val = session->ns_fh_v3.fh_dirs;
546 534 request.dirs.dirs_len = session->ns_fh_v3.fh_dir_index;
547 535
548 536 if (ndmp_send_request_lock(session->ns_connection,
549 537 NDMP_FH_ADD_DIR, NDMP_NO_ERR, (void *) &request, 0) < 0) {
550 - NDMP_LOG(LOG_DEBUG,
551 - "Sending ndmp_fh_add_dir request");
538 + syslog(LOG_ERR,
539 + "Sending ndmp_fh_add_dir request failed");
552 540 return (-1);
553 541 }
554 542
555 543 session->ns_fh_v3.fh_dir_index = 0;
556 544 session->ns_fh_v3.fh_dir_name_buf_index = 0;
557 545 }
558 546
559 547 if (name == NULL)
560 548 return (0);
561 549
562 550 if (session->ns_fh_v3.fh_dirs == 0) {
563 551 session->ns_fh_v3.fh_dirs =
564 552 ndmp_malloc(sizeof (ndmp_dir_v3) * N_DIR_ENTRIES);
565 553 if (session->ns_fh_v3.fh_dirs == 0)
566 554 return (-1);
567 555 }
568 556
569 557 if (session->ns_fh_v3.fh_dir_names == 0) {
570 558 session->ns_fh_v3.fh_dir_names =
571 559 ndmp_malloc(sizeof (ndmp_file_name_v3) * N_DIR_ENTRIES);
572 560 if (session->ns_fh_v3.fh_dir_names == 0)
573 561 return (-1);
574 562 }
575 563
576 564 if (session->ns_fh_v3.fh_dir_name_buf == 0) {
577 565 session->ns_fh_v3.fh_dir_name_buf =
578 566 ndmp_malloc(sizeof (char) * DIR_NAMEBUF_SIZE);
579 567 if (session->ns_fh_v3.fh_dir_name_buf == 0)
580 568 return (-1);
581 569 }
582 570
583 571 dir_entry = &session->ns_fh_v3.fh_dirs[session->ns_fh_v3.fh_dir_index];
584 572 dir_name_entry =
585 573 &session->ns_fh_v3.fh_dir_names[session->ns_fh_v3.fh_dir_index];
586 574
587 575 dir_name_entry->fs_type = NDMP_FS_UNIX;
588 576 dir_name_entry->ndmp_file_name_v3_u.unix_name =
589 577 &session->ns_fh_v3.fh_dir_name_buf[session->
590 578 ns_fh_v3.fh_dir_name_buf_index];
591 579
592 580 (void) strlcpy(&session->ns_fh_v3.fh_dir_name_buf[session->
593 581 ns_fh_v3.fh_dir_name_buf_index], name, PATH_NAMEBUF_SIZE);
594 582 session->ns_fh_v3.fh_dir_name_buf_index += strlen(name) + 1;
595 583
596 584 dir_entry->names.names_len = 1;
597 585 dir_entry->names.names_val = dir_name_entry;
598 586 dir_entry->node = long_long_to_quad(node);
599 587 dir_entry->parent = long_long_to_quad(parent);
600 588
601 589 session->ns_fh_v3.fh_dir_index++;
602 590
603 591 return (0);
604 592 }
605 593
606 594
607 595 /*
608 596 * ndmpd_api_file_history_node_v3
609 597 *
610 598 * Add a file history node entry to the buffer.
611 599 * History data is buffered until the buffer is filled.
612 600 * Full buffers are then sent to the client.
613 601 *
614 602 * Parameters:
615 603 * cookie (input) - session pointer.
616 604 * node (input) - file inode.
617 605 * must match a node from a prior ndmpd_api_file_history_dir()
618 606 * call.
619 607 * file_stat (input) - file status pointer.
620 608 * 0 forces buffered data to be sent.
621 609 * fh_info (input) - data stream position of file data used during
622 610 * fast restore.
623 611 *
624 612 * Returns:
625 613 * 0 - success
626 614 * -1 - error.
627 615 */
628 616 int
629 617 ndmpd_api_file_history_node_v3(void *cookie, ulong_t node,
630 618 struct stat64 *file_stat, u_longlong_t fh_info)
631 619 {
632 620 ndmpd_session_t *session = (ndmpd_session_t *)cookie;
633 621 ndmp_node_v3 *node_entry;
634 622 ndmp_file_stat_v3 *file_stat_entry;
635 623 ndmp_fh_add_node_request_v3 request;
636 624
637 625 if (file_stat == NULL && session->ns_fh_v3.fh_node_index == 0)
|
↓ open down ↓ |
76 lines elided |
↑ open up ↑ |
638 626 return (0);
639 627
640 628 /*
641 629 * If the buffer does not have space
642 630 * for the current entry, send the buffered data to the client.
643 631 * A 0 file_stat pointer indicates that any buffered data should
644 632 * be sent.
645 633 */
646 634 if (file_stat == NULL ||
647 635 session->ns_fh_v3.fh_node_index == N_NODE_ENTRIES) {
648 - NDMP_LOG(LOG_DEBUG, "sending %ld entries",
649 - session->ns_fh_v3.fh_node_index);
650 636
651 637 /*
652 638 * Need to send Dir entry as well. Since Dir entry is more
653 639 * than a Node entry, we may send a Node entry that hasn't
654 640 * had its Dir entry sent. Therefore, we need to flush Dir
655 641 * entry as well every time the Dir entry is sent.
656 642 */
657 643 (void) ndmpd_api_file_history_dir_v3(session, 0, 0, 0);
658 644
659 645 request.nodes.nodes_len = session->ns_fh_v3.fh_node_index;
660 646 request.nodes.nodes_val = session->ns_fh_v3.fh_nodes;
661 647
662 648 if (ndmp_send_request_lock(session->ns_connection,
663 649 NDMP_FH_ADD_NODE,
664 650 NDMP_NO_ERR, (void *) &request, 0) < 0) {
665 - NDMP_LOG(LOG_DEBUG,
666 - "Sending ndmp_fh_add_node request");
651 + syslog(LOG_ERR,
652 + "Sending ndmp_fh_add_node request failed");
667 653 return (-1);
668 654 }
669 655
670 656 session->ns_fh_v3.fh_node_index = 0;
671 657 }
672 658
673 659 if (file_stat == NULL)
674 660 return (0);
675 661
676 662 if (session->ns_fh_v3.fh_nodes == 0) {
677 663 session->ns_fh_v3.fh_nodes =
678 664 ndmp_malloc(sizeof (ndmp_node_v3) * N_NODE_ENTRIES);
679 665 if (session->ns_fh_v3.fh_nodes == 0)
680 666 return (-1);
681 667 }
682 668
683 669 if (session->ns_fh_v3.fh_node_stats == 0) {
684 670 session->ns_fh_v3.fh_node_stats =
685 671 ndmp_malloc(sizeof (ndmp_file_stat_v3) * N_NODE_ENTRIES);
686 672 if (session->ns_fh_v3.fh_node_stats == 0)
687 673 return (-1);
688 674 }
689 675
690 676 node_entry =
691 677 &session->ns_fh_v3.fh_nodes[session->ns_fh_v3.fh_node_index];
692 678
693 679 file_stat_entry =
694 680 &session->ns_fh_v3.fh_node_stats[session->ns_fh_v3.fh_node_index];
695 681 ndmpd_get_file_entry_type(file_stat->st_mode, &file_stat_entry->ftype);
696 682
697 683 file_stat_entry->invalid = 0;
698 684 file_stat_entry->fs_type = NDMP_FS_UNIX;
699 685 file_stat_entry->mtime = file_stat->st_mtime;
700 686 file_stat_entry->atime = file_stat->st_atime;
701 687 file_stat_entry->ctime = file_stat->st_ctime;
702 688 file_stat_entry->owner = file_stat->st_uid;
703 689 file_stat_entry->group = file_stat->st_gid;
704 690 file_stat_entry->fattr = file_stat->st_mode & 0x0fff;
705 691 file_stat_entry->size =
706 692 long_long_to_quad((u_longlong_t)file_stat->st_size);
707 693 file_stat_entry->links = file_stat->st_nlink;
708 694
709 695 node_entry->stats.stats_len = 1;
710 696 node_entry->stats.stats_val = file_stat_entry;
711 697 node_entry->node = long_long_to_quad((u_longlong_t)node);
712 698 node_entry->fh_info = long_long_to_quad(fh_info);
713 699
714 700 session->ns_fh_v3.fh_node_index++;
715 701
716 702 return (0);
717 703 }
718 704
719 705
720 706 /*
721 707 * ************************************************************************
722 708 * NDMP V4 HANDLERS
723 709 * ************************************************************************
724 710 */
725 711
726 712
727 713 /*
728 714 * ndmpd_fhpath_v3_cb
729 715 *
730 716 * Callback function for file history path information
731 717 */
|
↓ open down ↓ |
55 lines elided |
↑ open up ↑ |
732 718 int
733 719 ndmpd_fhpath_v3_cb(lbr_fhlog_call_backs_t *cbp, char *path, struct stat64 *stp,
734 720 u_longlong_t off)
735 721 {
736 722 int err;
737 723 ndmp_lbr_params_t *nlp;
738 724 ndmpd_module_params_t *params;
739 725
740 726 if (!cbp) {
741 727 err = -1;
742 - NDMP_LOG(LOG_DEBUG, "cbp is NULL");
728 + syslog(LOG_DEBUG, "cbp is NULL");
743 729 } else if (!cbp->fh_cookie) {
744 730 err = -1;
745 - NDMP_LOG(LOG_DEBUG, "cookie is NULL");
731 + syslog(LOG_DEBUG, "cookie is NULL");
746 732 } else if (!path) {
747 733 err = -1;
748 - NDMP_LOG(LOG_DEBUG, "path is NULL");
734 + syslog(LOG_DEBUG, "path is NULL");
749 735 } else if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
750 736 err = -1;
751 - NDMP_LOG(LOG_DEBUG, "nlp is NULL");
737 + syslog(LOG_DEBUG, "nlp is NULL");
752 738 } else
753 739 err = 0;
754 740
755 741 if (err != 0)
756 742 return (0);
757 743
758 - NDMP_LOG(LOG_DEBUG, "pname(%s)", path);
759 -
760 744 err = 0;
761 745 if (NLP_ISSET(nlp, NLPF_FH)) {
762 746 if (!NLP_ISSET(nlp, NLPF_DIRECT)) {
763 - NDMP_LOG(LOG_DEBUG, "DAR NOT SET!");
747 + syslog(LOG_DEBUG, "DAR NOT SET!");
764 748 off = 0LL;
765 749 }
766 750
767 751 params = get_params(cbp->fh_cookie);
768 752 if (!params || !params->mp_file_history_path_func) {
769 753 err = -1;
770 754 } else {
771 755 char *p =
772 756 ndmp_get_relative_path(get_backup_path_v3(params),
773 757 path);
774 758 if ((err = ndmpd_api_file_history_file_v3(cbp->
775 759 fh_cookie, p, stp, off)) < 0)
776 - NDMP_LOG(LOG_DEBUG, "\"%s\" %d", path, err);
760 + syslog(LOG_DEBUG, "\"%s\" %d", path, err);
777 761 }
778 762 }
779 763
780 764 return (err);
781 765 }
782 766
783 767
784 768 /*
785 769 * ndmpd_fhdir_v3_cb
786 770 *
787 771 * Callback function for file history dir information
788 772 */
789 773 int
790 774 ndmpd_fhdir_v3_cb(lbr_fhlog_call_backs_t *cbp, char *dir, struct stat64 *stp)
791 775 {
792 776 char nm[PATH_MAX+1];
793 777 int nml;
|
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
794 778 int err;
795 779 ulong_t ino, pino;
796 780 ulong_t pos;
797 781 ndmp_lbr_params_t *nlp;
798 782 ndmpd_module_params_t *params;
799 783 DIR *dirp;
800 784 char dirpath[PATH_MAX];
801 785
802 786 if (!cbp) {
803 787 err = -1;
804 - NDMP_LOG(LOG_DEBUG, "cbp is NULL");
788 + syslog(LOG_DEBUG, "cbp is NULL");
805 789 } else if (!cbp->fh_cookie) {
806 790 err = -1;
807 - NDMP_LOG(LOG_DEBUG, "cookie is NULL");
791 + syslog(LOG_DEBUG, "cookie is NULL");
808 792 } else if (!dir) {
809 793 err = -1;
810 - NDMP_LOG(LOG_DEBUG, "dir is NULL");
794 + syslog(LOG_DEBUG, "dir is NULL");
811 795 } else if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
812 796 err = -1;
813 - NDMP_LOG(LOG_DEBUG, "nlp is NULL");
797 + syslog(LOG_DEBUG, "nlp is NULL");
814 798 } else
815 799 err = 0;
816 800
817 801 if (err != 0)
818 802 return (0);
819 803
820 - NDMP_LOG(LOG_DEBUG, "d(%s)", dir);
821 -
822 804 if (!NLP_ISSET(nlp, NLPF_FH))
823 805 return (0);
824 806
825 807 /*
826 808 * Veritas net_backup accepts only 2 as the inode number of the backup
827 809 * root directory. The other way compares the path against the
828 810 * backup path which is slower.
829 811 */
830 812 if (stp->st_ino == nlp->nlp_bkdirino)
831 813 pino = ROOT_INODE;
832 814 else
|
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
833 815 pino = stp->st_ino;
834 816
835 817 /*
836 818 * There is nothing below this directory to be backed up.
837 819 * If there was, the bit for this directory would have
838 820 * been set. Backup root directory is exception. We
839 821 * always send the dir file history records of it.
840 822 */
841 823 if (pino != ROOT_INODE &&
842 824 !dbm_getone(nlp->nlp_bkmap, (u_longlong_t)stp->st_ino)) {
843 - NDMP_LOG(LOG_DEBUG, "nothing below here");
825 + syslog(LOG_DEBUG, "nothing below here");
844 826 return (0);
845 827 }
846 828
847 829 params = nlp->nlp_params;
848 830 if (!params || !params->mp_file_history_dir_func)
849 831 return (-1);
850 832
851 833 pos = 0;
852 834 err = 0;
853 835
854 836 dirp = opendir(dir);
855 837 if (dirp == NULL)
856 838 return (0);
857 839
858 840 do {
859 841 nml = PATH_MAX;
860 842 err = dp_readdir(dirp, &pos, nm, &nml, &ino);
861 843 if (err != 0) {
862 - NDMP_LOG(LOG_DEBUG,
844 + syslog(LOG_DEBUG,
863 845 "%d reading pos %u dir \"%s\"", err, pos, dir);
864 846 break;
865 847 }
866 848 if (nml == 0)
867 849 break;
868 850 nm[nml] = '\0';
869 851
870 852 if (pino == ROOT_INODE) {
871 853 if (rootfs_dot_or_dotdot(nm))
872 854 ino = ROOT_INODE;
873 855 } else if (ino == nlp->nlp_bkdirino && IS_DOTDOT(nm)) {
874 - NDMP_LOG(LOG_DEBUG, "nm(%s): %lu", nm, ino);
875 856 ino = ROOT_INODE;
876 857 }
877 858
878 859 if (!dbm_getone(nlp->nlp_bkmap, (u_longlong_t)ino))
879 860 continue;
880 861
881 862 /*
882 863 * If the entry is on exclusion list dont send the info
883 864 */
884 865 if (tlm_is_excluded(dir, nm, ndmp_excl_list)) {
885 - NDMP_LOG(LOG_DEBUG,
886 - "name \"%s\" skipped", nm == 0 ? "nil" : nm);
866 + syslog(LOG_DEBUG,
867 + "name \"%s\" skipped", *nm == '\0' ? "nil" : nm);
887 868 continue;
888 869 }
889 870
890 871 err = (*params->mp_file_history_dir_func)(cbp->fh_cookie, nm,
891 872 ino, pino);
892 873 if (err < 0) {
893 - NDMP_LOG(LOG_DEBUG, "\"%s\": %d", dir, err);
874 + syslog(LOG_ERR, "\"%s\": %d", dir, err);
894 875 break;
895 876 }
896 877
897 878 /*
898 879 * This is a requirement by some DMA's (net_vault) that during
899 880 * the incremental backup, the node info should also be sent
900 881 * along with the dir info for all directories leading to a
901 882 * backed up file.
902 883 */
903 884 if (ndmp_fhinode) {
904 885 struct stat64 ret_attr;
905 886
906 887 (void) strlcpy(dirpath, dir, PATH_MAX);
907 888 (void) strlcat(dirpath, "/", PATH_MAX);
908 889 (void) strlcat(dirpath, nm, PATH_MAX);
909 890 err = stat64(dirpath, &ret_attr);
910 891 if (err != 0) {
911 - NDMP_LOG(LOG_DEBUG,
892 + syslog(LOG_ERR,
912 893 "Error looking up %s", nm);
913 894 break;
914 895 }
915 896
916 897 if (S_ISDIR(ret_attr.st_mode)) {
917 898 err = (*params->mp_file_history_node_func)(cbp->
918 899 fh_cookie, ino, &ret_attr, 0);
919 900 if (err < 0) {
920 - NDMP_LOG(LOG_DEBUG, "\"%s/\": %d",
901 + syslog(LOG_ERR, "\"%s/\": %d",
921 902 dir, err);
922 903 break;
923 904 }
924 905 }
925 906 }
926 907 } while (err == 0);
927 908
928 909 (void) closedir(dirp);
929 910 return (err);
930 911 }
931 912
932 913
933 914 /*
934 915 * ndmpd_fhnode_v3_cb
935 916 *
936 917 * Callback function for file history node information
937 918 */
938 919 int
|
↓ open down ↓ |
8 lines elided |
↑ open up ↑ |
939 920 ndmpd_fhnode_v3_cb(lbr_fhlog_call_backs_t *cbp, char *dir, char *file,
940 921 struct stat64 *stp, u_longlong_t off)
941 922 {
942 923 int err;
943 924 ulong_t ino;
944 925 ndmp_lbr_params_t *nlp;
945 926 ndmpd_module_params_t *params;
946 927
947 928 if (!cbp) {
948 929 err = -1;
949 - NDMP_LOG(LOG_DEBUG, "cbp is NULL");
930 + syslog(LOG_DEBUG, "cbp is NULL");
950 931 } else if (!cbp->fh_cookie) {
951 932 err = -1;
952 - NDMP_LOG(LOG_DEBUG, "cookie is NULL");
933 + syslog(LOG_DEBUG, "cookie is NULL");
953 934 } else if (!dir) {
954 935 err = -1;
955 - NDMP_LOG(LOG_DEBUG, "dir is NULL");
936 + syslog(LOG_DEBUG, "dir is NULL");
956 937 } else if (!file) {
957 938 err = -1;
958 - NDMP_LOG(LOG_DEBUG, "file is NULL");
939 + syslog(LOG_DEBUG, "file is NULL");
959 940 } else if (!stp) {
960 941 err = -1;
961 - NDMP_LOG(LOG_DEBUG, "stp is NULL");
942 + syslog(LOG_DEBUG, "stp is NULL");
962 943 } else if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
963 944 err = -1;
964 - NDMP_LOG(LOG_DEBUG, "nlp is NULL");
945 + syslog(LOG_DEBUG, "nlp is NULL");
965 946 } else {
966 947 err = 0;
967 948 }
968 949
969 950 if (err != 0)
970 951 return (0);
971 952
972 - NDMP_LOG(LOG_DEBUG, "d(%s), f(%s)", dir, file);
973 953
974 954 err = 0;
975 955 if (NLP_ISSET(nlp, NLPF_FH)) {
976 956 if (!NLP_ISSET(nlp, NLPF_DIRECT))
977 957 off = 0LL;
978 958 if (stp->st_ino == nlp->nlp_bkdirino) {
979 959 ino = ROOT_INODE;
980 - NDMP_LOG(LOG_DEBUG,
981 - "bkroot %d -> %d", stp->st_ino, ROOT_INODE);
982 960 } else
983 961 ino = stp->st_ino;
984 962
985 963 params = nlp->nlp_params;
986 964 if (!params || !params->mp_file_history_node_func)
987 965 err = -1;
988 966 else if ((err = (*params->mp_file_history_node_func)(cbp->
989 967 fh_cookie, ino, stp, off)) < 0)
990 - NDMP_LOG(LOG_DEBUG, "\"%s/%s\" %d", dir, file, err);
968 + syslog(LOG_ERR, "\"%s/%s\" %d", dir, file, err);
991 969 }
992 970
993 971 return (err);
994 972 }
995 973
996 974
997 975 /*
998 976 * ndmp_send_recovery_stat_v3
999 977 *
1000 978 * Send the recovery status to the DMA
1001 979 */
1002 980 int
1003 981 ndmp_send_recovery_stat_v3(ndmpd_module_params_t *params,
1004 982 ndmp_lbr_params_t *nlp, int idx, int stat)
1005 983 {
1006 984 int rv;
1007 985 mem_ndmp_name_v3_t *ep;
1008 986
1009 987 rv = -1;
1010 988 if (!params) {
1011 - NDMP_LOG(LOG_DEBUG, "params == NULL");
989 + syslog(LOG_DEBUG, "params == NULL");
1012 990 } else if (!params->mp_file_recovered_func) {
1013 - NDMP_LOG(LOG_DEBUG, "paramsfile_recovered_func == NULL");
991 + syslog(LOG_DEBUG, "paramsfile_recovered_func == NULL");
1014 992 } else if (!nlp) {
1015 - NDMP_LOG(LOG_DEBUG, "nlp == NULL");
993 + syslog(LOG_DEBUG, "nlp == NULL");
1016 994 } else if (idx < 0) {
1017 - NDMP_LOG(LOG_DEBUG, "idx(%d) < 0", idx);
995 + syslog(LOG_DEBUG, "idx(%d) < 0", idx);
1018 996 } else if (!(ep = (mem_ndmp_name_v3_t *)MOD_GETNAME(params, idx))) {
1019 - NDMP_LOG(LOG_DEBUG, "nlist[%d] == NULL", idx);
997 + syslog(LOG_DEBUG, "nlist[%d] == NULL", idx);
1020 998 } else if (!ep->nm3_opath) {
1021 - NDMP_LOG(LOG_DEBUG, "nlist[%d].nm3_opath == NULL", idx);
999 + syslog(LOG_DEBUG, "nlist[%d].nm3_opath == NULL", idx);
1022 1000 } else {
1023 - NDMP_LOG(LOG_DEBUG,
1001 + syslog(LOG_DEBUG,
1024 1002 "ep[%d].nm3_opath \"%s\"", idx, ep->nm3_opath);
1025 1003 rv = MOD_FILERECOVERD(params, ep->nm3_opath, stat);
1026 1004 }
1027 1005
1028 1006 return (rv);
1029 1007 }
1030 1008
1031 1009
1032 1010 /*
1033 1011 * ndmpd_path_restored_v3
1034 1012 *
1035 1013 * Send the recovery status and the information for the restored
1036 1014 * path.
1037 1015 */
1038 1016 /*ARGSUSED*/
|
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
1039 1017 int
1040 1018 ndmpd_path_restored_v3(lbr_fhlog_call_backs_t *cbp, char *name,
1041 1019 struct stat64 *st, u_longlong_t ll_idx)
1042 1020 {
1043 1021 int rv;
1044 1022 ndmp_lbr_params_t *nlp;
1045 1023 ndmpd_module_params_t *params;
1046 1024 int idx = (int)ll_idx;
1047 1025
1048 1026 if (!cbp) {
1049 - NDMP_LOG(LOG_DEBUG, "cbp is NULL");
1027 + syslog(LOG_DEBUG, "cbp is NULL");
1050 1028 return (-1);
1051 1029 }
1052 1030 if (!name) {
1053 - NDMP_LOG(LOG_DEBUG, "name is NULL");
1031 + syslog(LOG_DEBUG, "name is NULL");
1054 1032 return (-1);
1055 1033 }
1056 1034
1057 - NDMP_LOG(LOG_DEBUG, "name: \"%s\", idx: %d", name, idx);
1058 -
1059 1035 nlp = ndmp_get_nlp(cbp->fh_cookie);
1060 1036 if (!nlp) {
1061 - NDMP_LOG(LOG_DEBUG, "nlp is NULL");
1037 + syslog(LOG_DEBUG, "nlp is NULL");
1062 1038 return (-1);
1063 1039 }
1064 1040 if (idx < 0 || idx >= nlp->nlp_nfiles) {
1065 - NDMP_LOG(LOG_DEBUG, "Invalid idx: %d", idx);
1041 + syslog(LOG_DEBUG, "Invalid idx: %d", idx);
1066 1042 return (-1);
1067 1043 }
1068 1044 params = nlp->nlp_params;
1069 1045 if (!params || !params->mp_file_recovered_func)
1070 1046 return (-1);
1071 1047
1072 1048 if (nlp->nlp_lastidx == -1)
1073 1049 nlp->nlp_lastidx = idx;
1074 1050
1075 1051 rv = 0;
1076 1052 (void) bm_setone(nlp->nlp_rsbm, (u_longlong_t)idx);
1077 1053 /*
1078 1054 * Note: We should set the nm3_err here.
1079 1055 */
1080 1056 if (nlp->nlp_lastidx != idx) {
1081 1057 rv = ndmp_send_recovery_stat_v3(params, nlp, nlp->nlp_lastidx,
1082 1058 0);
1083 1059 nlp->nlp_lastidx = idx;
1084 1060 }
1085 1061
1086 1062 return (rv);
1087 1063 }
1088 1064
1089 1065
1090 1066
1091 1067 /*
1092 1068 * ndmpd_file_history_init
1093 1069 *
1094 1070 * Initialize file history variables.
1095 1071 * Note that the entry and name buffers are not allocated here.
1096 1072 * Since it is not know if the backup module will be sending file history
1097 1073 * data or what kind of data (path or dir/node), the entry and name
1098 1074 * buffers are not allocated until the first call to one of the file history
1099 1075 * entry functions is made. This way resources are only allocated as
1100 1076 * needed.
1101 1077 *
1102 1078 * Parameters:
1103 1079 * session (input) - session pointer.
1104 1080 *
1105 1081 * Returns:
1106 1082 * void
1107 1083 */
1108 1084 void
1109 1085 ndmpd_file_history_init(ndmpd_session_t *session)
1110 1086 {
1111 1087 session->ns_fh.fh_path_entries = 0;
1112 1088 session->ns_fh.fh_dir_entries = 0;
1113 1089 session->ns_fh.fh_node_entries = 0;
1114 1090 session->ns_fh.fh_path_name_buf = 0;
1115 1091 session->ns_fh.fh_dir_name_buf = 0;
1116 1092 session->ns_fh.fh_path_index = 0;
1117 1093 session->ns_fh.fh_dir_index = 0;
1118 1094 session->ns_fh.fh_node_index = 0;
1119 1095 session->ns_fh.fh_path_name_buf_index = 0;
1120 1096 session->ns_fh.fh_dir_name_buf_index = 0;
1121 1097
1122 1098 /*
1123 1099 * V3.
1124 1100 */
1125 1101 session->ns_fh_v3.fh_files = 0;
1126 1102 session->ns_fh_v3.fh_dirs = 0;
1127 1103 session->ns_fh_v3.fh_nodes = 0;
1128 1104 session->ns_fh_v3.fh_file_names = 0;
1129 1105 session->ns_fh_v3.fh_dir_names = 0;
1130 1106 session->ns_fh_v3.fh_file_stats = 0;
1131 1107 session->ns_fh_v3.fh_node_stats = 0;
1132 1108 session->ns_fh_v3.fh_file_name_buf = 0;
1133 1109 session->ns_fh_v3.fh_dir_name_buf = 0;
1134 1110 session->ns_fh_v3.fh_file_index = 0;
1135 1111 session->ns_fh_v3.fh_dir_index = 0;
1136 1112 session->ns_fh_v3.fh_node_index = 0;
1137 1113 session->ns_fh_v3.fh_file_name_buf_index = 0;
1138 1114 session->ns_fh_v3.fh_dir_name_buf_index = 0;
1139 1115 }
1140 1116
1141 1117
1142 1118 /*
1143 1119 * ndmpd_file_history_cleanup_v2
1144 1120 *
1145 1121 * Send (or discard) any buffered file history entries.
1146 1122 *
1147 1123 * Parameters:
1148 1124 * session (input) - session pointer.
1149 1125 * send_flag (input) - if TRUE buffered entries are sent.
1150 1126 * if FALSE buffered entries are discarded.
1151 1127 *
1152 1128 * Returns:
1153 1129 * void
1154 1130 */
1155 1131 static void
1156 1132 ndmpd_file_history_cleanup_v2(ndmpd_session_t *session, boolean_t send_flag)
1157 1133 {
1158 1134 if (send_flag == TRUE) {
1159 1135 (void) ndmpd_api_file_history_path_v2(session, 0, 0, 0);
1160 1136 (void) ndmpd_api_file_history_dir_v2(session, 0, 0, 0);
1161 1137 (void) ndmpd_api_file_history_node_v2(session, 0, 0, 0);
1162 1138 }
1163 1139
1164 1140 if (session->ns_fh.fh_path_entries != 0) {
1165 1141 free(session->ns_fh.fh_path_entries);
1166 1142 session->ns_fh.fh_path_entries = 0;
1167 1143 }
1168 1144 if (session->ns_fh.fh_dir_entries != 0) {
1169 1145 free(session->ns_fh.fh_dir_entries);
1170 1146 session->ns_fh.fh_dir_entries = 0;
1171 1147 }
1172 1148 if (session->ns_fh.fh_node_entries != 0) {
1173 1149 free(session->ns_fh.fh_node_entries);
1174 1150 session->ns_fh.fh_node_entries = 0;
1175 1151 }
1176 1152 if (session->ns_fh.fh_path_name_buf != 0) {
1177 1153 free(session->ns_fh.fh_path_name_buf);
1178 1154 session->ns_fh.fh_path_name_buf = 0;
1179 1155 }
1180 1156 if (session->ns_fh.fh_dir_name_buf != 0) {
1181 1157 free(session->ns_fh.fh_dir_name_buf);
1182 1158 session->ns_fh.fh_dir_name_buf = 0;
1183 1159 }
1184 1160 session->ns_fh.fh_path_index = 0;
1185 1161 session->ns_fh.fh_dir_index = 0;
1186 1162 session->ns_fh.fh_node_index = 0;
1187 1163 session->ns_fh.fh_path_name_buf_index = 0;
1188 1164 session->ns_fh.fh_dir_name_buf_index = 0;
1189 1165 }
1190 1166
1191 1167
1192 1168 /*
1193 1169 * ndmpd_file_history_cleanup_v3
1194 1170 *
1195 1171 * Send (or discard) any buffered file history entries.
1196 1172 *
1197 1173 * Parameters:
1198 1174 * session (input) - session pointer.
1199 1175 * send_flag (input) - if TRUE buffered entries are sent.
1200 1176 * if FALSE buffered entries are discarded.
1201 1177 *
1202 1178 * Returns:
1203 1179 * void
1204 1180 */
1205 1181 static void
1206 1182 ndmpd_file_history_cleanup_v3(ndmpd_session_t *session, boolean_t send_flag)
1207 1183 {
1208 1184 if (send_flag == TRUE) {
1209 1185 (void) ndmpd_api_file_history_file_v3(session, 0, 0, 0);
1210 1186 (void) ndmpd_api_file_history_dir_v3(session, 0, 0, 0);
1211 1187 (void) ndmpd_api_file_history_node_v3(session, 0, 0, 0);
1212 1188 }
1213 1189
1214 1190 if (session->ns_fh_v3.fh_files != 0) {
1215 1191 free(session->ns_fh_v3.fh_files);
1216 1192 session->ns_fh_v3.fh_files = 0;
1217 1193 }
1218 1194 if (session->ns_fh_v3.fh_dirs != 0) {
1219 1195 free(session->ns_fh_v3.fh_dirs);
1220 1196 session->ns_fh_v3.fh_dirs = 0;
1221 1197 }
1222 1198 if (session->ns_fh_v3.fh_nodes != 0) {
1223 1199 free(session->ns_fh_v3.fh_nodes);
1224 1200 session->ns_fh_v3.fh_nodes = 0;
1225 1201 }
1226 1202 if (session->ns_fh_v3.fh_file_names != 0) {
1227 1203 free(session->ns_fh_v3.fh_file_names);
1228 1204 session->ns_fh_v3.fh_file_names = 0;
1229 1205 }
1230 1206 if (session->ns_fh_v3.fh_dir_names != 0) {
1231 1207 free(session->ns_fh_v3.fh_dir_names);
1232 1208 session->ns_fh_v3.fh_dir_names = 0;
1233 1209 }
1234 1210 if (session->ns_fh_v3.fh_file_stats != 0) {
1235 1211 free(session->ns_fh_v3.fh_file_stats);
1236 1212 session->ns_fh_v3.fh_file_stats = 0;
1237 1213 }
1238 1214 if (session->ns_fh_v3.fh_node_stats != 0) {
1239 1215 free(session->ns_fh_v3.fh_node_stats);
1240 1216 session->ns_fh_v3.fh_node_stats = 0;
1241 1217 }
1242 1218 if (session->ns_fh_v3.fh_file_name_buf != 0) {
1243 1219 free(session->ns_fh_v3.fh_file_name_buf);
1244 1220 session->ns_fh_v3.fh_file_name_buf = 0;
1245 1221 }
1246 1222 if (session->ns_fh_v3.fh_dir_name_buf != 0) {
1247 1223 free(session->ns_fh_v3.fh_dir_name_buf);
1248 1224 session->ns_fh_v3.fh_dir_name_buf = 0;
1249 1225 }
1250 1226
1251 1227 session->ns_fh_v3.fh_file_index = 0;
1252 1228 session->ns_fh_v3.fh_dir_index = 0;
1253 1229 session->ns_fh_v3.fh_node_index = 0;
1254 1230 session->ns_fh_v3.fh_file_name_buf_index = 0;
1255 1231 session->ns_fh_v3.fh_dir_name_buf_index = 0;
1256 1232 }
1257 1233
1258 1234
1259 1235 /*
1260 1236 * ndmpd_file_history_cleanup
1261 1237 *
1262 1238 * Send any pending posts and clean up
1263 1239 */
1264 1240 void
1265 1241 ndmpd_file_history_cleanup(ndmpd_session_t *session, boolean_t send_flag)
1266 1242 {
|
↓ open down ↓ |
191 lines elided |
↑ open up ↑ |
1267 1243 switch (session->ns_protocol_version) {
1268 1244 case 1:
1269 1245 case 2:
1270 1246 ndmpd_file_history_cleanup_v2(session, send_flag);
1271 1247 break;
1272 1248 case 3:
1273 1249 case 4:
1274 1250 ndmpd_file_history_cleanup_v3(session, send_flag);
1275 1251 break;
1276 1252 default:
1277 - NDMP_LOG(LOG_DEBUG, "Unknown version %d",
1253 + syslog(LOG_ERR, "Unknown version %d",
1278 1254 session->ns_protocol_version);
1279 1255 }
1280 1256 }
1281 1257
1282 1258 /*
1283 1259 * get_params
1284 1260 *
1285 1261 * Callbacks from LBR.
1286 1262 */
1287 1263 static ndmpd_module_params_t *
1288 1264 get_params(void *cookie)
1289 1265 {
1290 1266 ndmp_lbr_params_t *nlp;
1291 1267
1292 1268 if ((nlp = ndmp_get_nlp(cookie)) == NULL)
1293 1269 return (NULL);
1294 1270
1295 1271 return (nlp->nlp_params);
1296 1272 }
1297 1273
1298 1274
1299 1275 /*
|
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
1300 1276 * fh_requested
1301 1277 *
1302 1278 * Check in LB parameters if file history is requested
1303 1279 */
1304 1280 static boolean_t
1305 1281 fh_requested(void *cookie)
1306 1282 {
1307 1283 ndmp_lbr_params_t *nlp;
1308 1284
1309 1285 if ((nlp = ndmp_get_nlp(cookie)) == NULL) {
1310 - NDMP_LOG(LOG_DEBUG, "nlp is NULL");
1286 + syslog(LOG_DEBUG, "nlp is NULL");
1311 1287 return (FALSE);
1312 1288 }
1313 1289
1314 - NDMP_LOG(LOG_DEBUG, "nlp_fh %c", NDMP_YORN(NLP_ISSET(nlp, NLPF_FH)));
1290 + syslog(LOG_DEBUG, "nlp_fh %c", NDMP_YORN(NLP_ISSET(nlp, NLPF_FH)));
1315 1291
1316 1292 return (NLP_ISSET(nlp, NLPF_FH));
1317 1293 }
1318 1294
1319 1295
1320 1296 /*
1321 1297 * ndmpd_file_history_path
1322 1298 *
1323 1299 * Generates file history path information posts
1324 1300 *
1325 1301 * Note:
1326 1302 * Action must be determined when the 'dir' and/or 'file'
1327 1303 * arguments of ndmpd_file_history_path(), ndmpd_file_history_dir(), and
1328 1304 * ndmpd_file_history_node() are NULL.
1329 1305 */
|
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
1330 1306 /*ARGSUSED*/
1331 1307 int
1332 1308 ndmpd_file_history_path(lbr_fhlog_call_backs_t *cbp, char *path,
1333 1309 struct stat64 *stp, u_longlong_t off)
1334 1310 {
1335 1311 int err;
1336 1312 ndmpd_module_params_t *params;
1337 1313
1338 1314 if (!cbp) {
1339 1315 err = -1;
1340 - NDMP_LOG(LOG_DEBUG, "cbp is NULL");
1316 + syslog(LOG_DEBUG, "cbp is NULL");
1341 1317 } else if (!cbp->fh_cookie) {
1342 1318 err = -1;
1343 - NDMP_LOG(LOG_DEBUG, "cookie is NULL");
1319 + syslog(LOG_DEBUG, "cookie is NULL");
1344 1320 } else if (!path) {
1345 1321 err = -1;
1346 - NDMP_LOG(LOG_DEBUG, "path is NULL");
1322 + syslog(LOG_DEBUG, "path is NULL");
1347 1323 } else if (!stp) {
1348 1324 err = -1;
1349 - NDMP_LOG(LOG_DEBUG, "stp is NULL");
1325 + syslog(LOG_DEBUG, "stp is NULL");
1350 1326 } else
1351 1327 err = 0;
1352 1328
1353 1329 if (err != 0)
1354 1330 return (0);
1355 1331
1356 - NDMP_LOG(LOG_DEBUG, "path: \"%s\"", path);
1332 + syslog(LOG_DEBUG, "path: \"%s\"", path);
1357 1333
1358 1334 err = 0;
1359 1335 if (fh_requested(cbp->fh_cookie)) {
1360 1336 params = get_params(cbp->fh_cookie);
1361 1337 if (params == NULL || params->mp_file_history_path_func == NULL)
1362 1338 err = -1;
1363 1339 else if ((err = (*params->mp_file_history_path_func)(cbp->
1364 1340 fh_cookie, path, stp, 0)) < 0)
1365 - NDMP_LOG(LOG_DEBUG, "\"%s\": %d", path, err);
1341 + syslog(LOG_DEBUG, "\"%s\": %d", path, err);
1366 1342 }
1367 1343
1368 1344 return (err);
1369 1345 }
1370 1346
1371 1347
1372 1348 /*
1373 1349 * ndmpd_file_history_dir
1374 1350 *
1375 1351 * Generate file history directory information posts
1376 1352 */
1377 1353 int
1378 1354 ndmpd_file_history_dir(lbr_fhlog_call_backs_t *cbp, char *dir,
1379 1355 struct stat64 *stp)
1380 1356 {
1381 1357 char nm[PATH_MAX+1];
1382 1358 int nml;
|
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
1383 1359 int err;
1384 1360 ulong_t ino, pino;
1385 1361 ulong_t pos;
1386 1362 ndmp_lbr_params_t *nlp;
1387 1363 ndmpd_module_params_t *params;
1388 1364 DIR *dirp;
1389 1365 char dirpath[PATH_MAX];
1390 1366
1391 1367 if (!cbp) {
1392 1368 err = -1;
1393 - NDMP_LOG(LOG_DEBUG, "cbp is NULL");
1369 + syslog(LOG_DEBUG, "cbp is NULL");
1394 1370 } else if (!cbp->fh_cookie) {
1395 1371 err = -1;
1396 - NDMP_LOG(LOG_DEBUG, "cookie is NULL");
1372 + syslog(LOG_DEBUG, "cookie is NULL");
1397 1373 } else if (!dir) {
1398 1374 err = -1;
1399 - NDMP_LOG(LOG_DEBUG, "dir is NULL");
1375 + syslog(LOG_DEBUG, "dir is NULL");
1400 1376 } else if (!stp) {
1401 1377 err = -1;
1402 - NDMP_LOG(LOG_DEBUG, "stp is NULL");
1378 + syslog(LOG_DEBUG, "stp is NULL");
1403 1379 } if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
1404 1380 err = -1;
1405 - NDMP_LOG(LOG_DEBUG, "nlp is NULL");
1381 + syslog(LOG_DEBUG, "nlp is NULL");
1406 1382 } else
1407 1383 err = 0;
1408 1384
1409 1385 if (err != 0)
1410 1386 return (0);
1411 1387
1412 - NDMP_LOG(LOG_DEBUG, "dir: \"%s\"", dir);
1388 + syslog(LOG_DEBUG, "dir: \"%s\"", dir);
1413 1389
1414 1390 if (!fh_requested(cbp->fh_cookie))
1415 1391 return (0);
1416 1392
1417 1393 /*
1418 1394 * Veritas net_backup accepts only 2 as the inode number of the backup
1419 1395 * root directory. The other way compares the path against the
1420 1396 * backup path which is slower.
1421 1397 */
1422 1398 if (stp->st_ino == nlp->nlp_bkdirino)
1423 1399 pino = ROOT_INODE;
1424 1400 else
|
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
1425 1401 pino = stp->st_ino;
1426 1402
1427 1403 /*
1428 1404 * There is nothing below this directory to be backed up.
1429 1405 * If there was, the bit for this directory would have
1430 1406 * been set. Backup root directory is exception. We
1431 1407 * always send the dir file history records of it.
1432 1408 */
1433 1409 if (pino != ROOT_INODE &&
1434 1410 !dbm_getone(nlp->nlp_bkmap, (u_longlong_t)stp->st_ino)) {
1435 - NDMP_LOG(LOG_DEBUG, "nothing below here");
1411 + syslog(LOG_DEBUG, "nothing below here");
1436 1412 return (0);
1437 1413 }
1438 1414
1439 1415 params = get_params(cbp->fh_cookie);
1440 1416 if (params == NULL || params->mp_file_history_dir_func == NULL) {
1441 1417 return (0);
1442 1418 }
1443 1419
1444 1420 pos = 0;
1445 1421 err = 0;
1446 1422
1447 1423 dirp = opendir(dir);
1448 1424 if (dirp == NULL)
1449 1425 return (0);
1450 1426
1451 1427 do {
1452 1428 nml = PATH_MAX;
1453 1429 err = dp_readdir(dirp, &pos, nm, &nml, &ino);
1454 1430 if (err != 0) {
1455 - NDMP_LOG(LOG_DEBUG,
1431 + syslog(LOG_DEBUG,
1456 1432 "%d reading pos %u dir \"%s\"", err, pos, dir);
1457 1433 break;
1458 1434 }
1459 1435 if (nml == 0)
1460 1436 break;
1461 1437 nm[nml] = '\0';
1462 1438
1463 1439 if (pino == ROOT_INODE) {
1464 1440 if (rootfs_dot_or_dotdot(nm))
1465 1441 ino = ROOT_INODE;
1466 1442 } else if (ino == nlp->nlp_bkdirino && IS_DOTDOT(nm)) {
1467 - NDMP_LOG(LOG_DEBUG, "nm(%s): %lu", nm, ino);
1443 + syslog(LOG_DEBUG, "nm(%s): %lu", nm, ino);
1468 1444 ino = ROOT_INODE;
1469 1445 }
1470 1446
1471 1447 if (!dbm_getone(nlp->nlp_bkmap, (u_longlong_t)ino))
1472 1448 continue;
1473 1449
1474 1450 err = (*params->mp_file_history_dir_func)(cbp->fh_cookie, nm,
1475 1451 ino, pino);
1476 1452 if (err < 0) {
1477 - NDMP_LOG(LOG_DEBUG, "\"%s/%s\": %d", dir, nm, err);
1453 + syslog(LOG_ERR, "\"%s/%s\": %d", dir, nm, err);
1478 1454 break;
1479 1455 }
1480 1456
1481 1457 /*
1482 1458 * This is a requirement by some DMA's (net_vault) that during
1483 1459 * the incremental backup, the node info should also be sent
1484 1460 * along with the dir info for all directories leading to a
1485 1461 * backed up file.
1486 1462 */
1487 1463 if (ndmp_fhinode) {
1488 1464 struct stat64 ret_attr;
1489 1465
1490 1466 (void) strlcpy(dirpath, dir, PATH_MAX);
1491 1467 (void) strlcat(dirpath, "/", PATH_MAX);
1492 1468 (void) strlcat(dirpath, nm, PATH_MAX);
1493 1469 err = stat64(dirpath, &ret_attr);
1494 1470 if (err != 0) {
1495 - NDMP_LOG(LOG_DEBUG,
1496 - "Error looking up %s", nm);
1471 + syslog(LOG_ERR,
1472 + "Error looking up %s failed", nm);
1497 1473 break;
1498 1474 }
1499 1475
1500 1476 if (S_ISDIR(ret_attr.st_mode)) {
1501 1477 err = (*params->mp_file_history_node_func)(cbp->
1502 1478 fh_cookie, ino, &ret_attr, 0);
1503 1479 if (err < 0) {
1504 - NDMP_LOG(LOG_DEBUG, "\"%s/\": %d",
1480 + syslog(LOG_DEBUG, "\"%s/\": %d",
1505 1481 dir, err);
1506 1482 break;
1507 1483 }
1508 1484 }
1509 1485 }
1510 1486 } while (err == 0);
1511 1487
1512 1488 (void) closedir(dirp);
1513 1489 return (err);
1514 1490 }
1515 1491
1516 1492
1517 1493 /*
1518 1494 * ndmpd_file_history_node
1519 1495 *
1520 1496 * Generate file history node information posts
1521 1497 */
1522 1498 /*ARGSUSED*/
1523 1499 int
|
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
1524 1500 ndmpd_file_history_node(lbr_fhlog_call_backs_t *cbp, char *dir, char *file,
1525 1501 struct stat64 *stp, u_longlong_t off)
1526 1502 {
1527 1503 int err;
1528 1504 ulong_t ino;
1529 1505 ndmp_lbr_params_t *nlp;
1530 1506 ndmpd_module_params_t *params;
1531 1507
1532 1508 if (!cbp) {
1533 1509 err = -1;
1534 - NDMP_LOG(LOG_DEBUG, "cbp is NULL");
1510 + syslog(LOG_DEBUG, "cbp is NULL");
1535 1511 } else if (!cbp->fh_cookie) {
1536 1512 err = -1;
1537 - NDMP_LOG(LOG_DEBUG, "cookie is NULL");
1513 + syslog(LOG_DEBUG, "cookie is NULL");
1538 1514 } else if (!dir) {
1539 1515 err = -1;
1540 - NDMP_LOG(LOG_DEBUG, "dir is NULL");
1516 + syslog(LOG_DEBUG, "dir is NULL");
1541 1517 } else if (!file) {
1542 1518 err = -1;
1543 - NDMP_LOG(LOG_DEBUG, "file is NULL");
1519 + syslog(LOG_DEBUG, "file is NULL");
1544 1520 } else if (!stp) {
1545 1521 err = -1;
1546 - NDMP_LOG(LOG_DEBUG, "stp is NULL");
1522 + syslog(LOG_DEBUG, "stp is NULL");
1547 1523 } else if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
1548 1524 err = -1;
1549 - NDMP_LOG(LOG_DEBUG, "nlp is NULL");
1525 + syslog(LOG_DEBUG, "nlp is NULL");
1550 1526 } else
1551 1527 err = 0;
1552 1528
1553 1529 if (err != 0)
1554 1530 return (0);
1555 1531
1556 - NDMP_LOG(LOG_DEBUG, "d(%s), f(%s)", dir, file);
1557 -
1558 1532 err = 0;
1559 1533 if (fh_requested(cbp->fh_cookie) == TRUE) {
1560 1534 if (stp->st_ino == nlp->nlp_bkdirino) {
1561 1535 ino = ROOT_INODE;
1562 - NDMP_LOG(LOG_DEBUG,
1563 - "bkroot %d -> %d", stp->st_ino, ROOT_INODE);
1564 1536 } else {
1565 1537 ino = stp->st_ino;
1566 1538 }
1567 1539
1568 1540 params = get_params(cbp->fh_cookie);
1569 1541 if (params == NULL || params->mp_file_history_node_func == NULL)
1570 1542 err = -1;
1571 1543 else if ((err = (*params->mp_file_history_node_func)(cbp->
1572 1544 fh_cookie, ino, stp, 0)) < 0)
1573 - NDMP_LOG(LOG_DEBUG, "\"%s/\": %d", dir, file, err);
1545 + syslog(LOG_DEBUG, "\"%s/\": %d", dir, file, err);
1574 1546
1575 1547 }
1576 1548
1577 1549 return (err);
1578 1550 }
1579 1551
1580 1552
1581 1553 /*
1582 1554 * ndmpd_path_restored
1583 1555 *
1584 1556 * Mark the specified path as a restored path
1585 1557 */
1586 1558 /*ARGSUSED*/
1587 1559 int
|
↓ open down ↓ |
4 lines elided |
↑ open up ↑ |
1588 1560 ndmpd_path_restored(lbr_fhlog_call_backs_t *cbp, char *name, struct stat64 *stp,
1589 1561 u_longlong_t ll_pos)
1590 1562 {
1591 1563 int rv;
1592 1564 ndmp_name *entp;
1593 1565 ndmp_lbr_params_t *nlp;
1594 1566 ndmpd_module_params_t *params;
1595 1567 int pos = (int)ll_pos;
1596 1568
1597 1569 if (cbp == NULL) {
1598 - NDMP_LOG(LOG_DEBUG, "cbp is NULL");
1570 + syslog(LOG_DEBUG, "cbp is NULL");
1599 1571 return (-1);
1600 1572 }
1601 1573 if (name == NULL) {
1602 - NDMP_LOG(LOG_DEBUG, "name is NULL");
1574 + syslog(LOG_DEBUG, "name is NULL");
1603 1575 return (-1);
1604 1576 }
1605 1577
1606 - NDMP_LOG(LOG_DEBUG, "name: \"%s\", pos: %d",
1607 - name, pos);
1608 -
1609 1578 if ((nlp = ndmp_get_nlp(cbp->fh_cookie)) == NULL) {
1610 - NDMP_LOG(LOG_DEBUG, "nlp is NULL");
1579 + syslog(LOG_DEBUG, "nlp is NULL");
1611 1580 return (-1);
1612 1581 }
1613 1582 if (pos < 0 || pos >= nlp->nlp_nfiles) {
1614 - NDMP_LOG(LOG_DEBUG, "Invalid pos: %d", pos);
1583 + syslog(LOG_DEBUG, "Invalid pos: %d", pos);
1615 1584 return (-1);
1616 1585 }
1617 1586 params = get_params(cbp->fh_cookie);
1618 1587 if (params == NULL || params->mp_file_recovered_func == NULL)
1619 1588 return (-1);
1620 1589
1621 1590 rv = 0;
1622 1591 if (!nlp->nlp_restored[pos]) {
1623 1592 entp = (ndmp_name *)MOD_GETNAME(params, pos);
1624 1593 if (entp && entp->name)
1625 1594 name = entp->name;
1626 1595
1627 1596 if ((rv = MOD_FILERECOVERD(params, name, 0)) >= 0)
1628 1597 nlp->nlp_restored[pos] = TRUE;
1629 1598 }
1630 1599
1631 1600 return (rv);
1632 1601 }
1633 1602
1634 1603
1635 1604 /*
1636 1605 * dp_readdir
1637 1606 *
1638 1607 * Reads the entry of the directory and provides other information
1639 1608 * such as i-number, name, length and saves the dir entry position
1640 1609 * in a cookie for future calls.
1641 1610 */
1642 1611 int
1643 1612 dp_readdir(DIR *dirp, unsigned long *cookiep, char *name, int *n_namep,
1644 1613 unsigned long *fileidp)
1645 1614 {
1646 1615 struct dirent *entp;
1647 1616 int err = errno;
1648 1617
1649 1618 if ((entp = readdir(dirp)) == 0) {
1650 1619 if (err == errno) {
1651 1620 *n_namep = 0;
1652 1621 return (0);
1653 1622 }
1654 1623 return (errno);
1655 1624 }
1656 1625
1657 1626 *fileidp = entp->d_ino;
1658 1627 (void) strlcpy(name, entp->d_name, *n_namep);
1659 1628 *n_namep = entp->d_reclen + 1;
1660 1629 *cookiep = telldir(dirp);
1661 1630 return (0);
1662 1631 }
|
↓ open down ↓ |
38 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX