/
ndmagents.h
1355 lines (1124 loc) · 47 KB
/
ndmagents.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 1998,1999,2000
* Traakan, Inc., Los Altos, CA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice unmodified, this list of conditions, and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Project: NDMJOB
* Ident: $Id: $
*
* Description:
*
********************************************************************
*
* NDMP Elements of a backup/restore session
*
* +-----+ ###########
* | Job |----># CONTROL # +----------------+
* +-----+ # Agent #<---->|FILE/MEDIA INDEX|
* # # +----------------+
* ###########
* | | |
* +----------------+ | +---------------------+
* | control | connections |
* V V V
* ############ ############ +-------+ #########
* # DATA # # TAPE # | | # ROBOT #
* # Agent # # Agent # | ROBOT |<-># Agent #
* +-----+ # +------+ # image # +------+ # |+-----+| # #
* |FILES|====|butype|============|mover |=====|DRIVE|| # #
* +-----+ # +------+ # stream # +------+ # |+-----+| # #
* ############ ############ +-------+ #########
*
*
********************************************************************
*
* NDMAGENTS components overview
*
*
* "job" -> ndma_client_session() ndma_server_session()
* | |
* /-------------/ Q
* | v
* | +------------------------------------+ +-----------+
* | /->| SESSION QUANTUM |----->| disp conn |
* | | +------------------------------------+ \ +-----------+
* | Q Q Q Q Q Q | v |
* | | | | | | | | +----------+ |
* | /-----|----+--|----+----|----+--|----+---|----| dispatch | |
* | | | | | | | | | | | | | | request | |
* | v | v v v v v v v v v | +----------+ |
* | +-------+ +----+ +------+ +----+ +-----+ | ^ |
* +>|CONTROL| |DATA| |IMAGE | |TAPE| |ROBOT| | | |
* | | | |->|STREAM|<-| | | | | | |
* | | | *====* *====* | | | | | ndmconn_recv()
* | ndmca | ndmda| |ndmis | ndmta| |ndmra| | | |
* +-------+ +----+ +------+ +----+ +-----+ | |resi |
* | | | | | | | +------+ |
* \-----|-+----|----+-------+-------------->| call | |
* | | | +------+ |
* formatter| |image_stream | |remo |
* v v | v v
* +---------+<---ndmchan_poll()----/ +---------+
* | ndmchan |<---------------------------| ndmconn |
* +---------+ +---------+
* non-blocking I/O XDR wrapper
*
* -----> caller/callee
* --Q--> quantum (CPU scheduling)
* ====== image stream shared data structures
*
********************************************************************
*/
#include "ndmp/ndmlib.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* VERSION AND RELEASE CONSTANTS -- KEEPER ONLY
****************************************************************
*
* Revision constants for the source code. These may only be
* changed by the keeper of these sources. Contact ndmp-tech@ndmp.org
* for a pointer to the latest sources and the current keeper.
*
* The Version increases every time there is a significant
* design change. Significant means new functionality,
* reorganization of key data structures, etc. The Release
* increases every time the keeper releases an update to
* the current version, such as bug fixes or integration
* of new contributions.
*
* There are provisions for a free-form string for revisions
* of the O/S specific portions (NDMOS_CONST_NDMOS_REVISION)
* and for local revisions (NDMOS_CONST_NDMJOBLIB_REVISION)
* which reflect in-house change levels.
*/
#define NDMJOBLIB_VERSION 1
#define NDMJOBLIB_RELEASE 2
struct ndm_session; /* forward decl */
/*
* NDM_ENV_TABLE and NDM_NLIST_TABLE
****************************************************************
* Used by DATA and CONTROL agents
*/
#ifndef NDM_MAX_ENV
#define NDM_MAX_ENV 1024
#endif
struct ndm_env_entry {
ndmp9_pval pval;
struct ndm_env_entry * next;
};
struct ndm_env_table {
int n_env;
ndmp9_pval * enumerate;
int enumerate_length;
struct ndm_env_entry * head;
struct ndm_env_entry * tail;
};
/* ndma_listmgt.c */
extern ndmp9_pval * ndma_enumerate_env_list (struct ndm_env_table *envtab);
extern struct ndm_env_entry * ndma_store_env_list (struct ndm_env_table *envtab, ndmp9_pval *pv);
extern struct ndm_env_entry * ndma_update_env_list (struct ndm_env_table *envtab, ndmp9_pval *pv);
extern void ndma_destroy_env_list (struct ndm_env_table *envtab);
#ifndef NDM_MAX_NLIST
#define NDM_MAX_NLIST 10240
#endif
struct ndm_nlist_entry {
ndmp9_name name;
ndmp9_error result_err;
unsigned result_count;
struct ndm_nlist_entry * next;
};
struct ndm_nlist_table {
int n_nlist;
ndmp9_name * enumerate;
int enumerate_length;
struct ndm_nlist_entry * head;
struct ndm_nlist_entry * tail;
};
/* ndma_listmgt.c */
extern ndmp9_name * ndma_enumerate_nlist (struct ndm_nlist_table *nlist);
extern struct ndm_nlist_entry * ndma_store_nlist (struct ndm_nlist_table *nlist, ndmp9_name *nl);
extern void ndma_destroy_nlist (struct ndm_nlist_table *nlist);
#ifndef NDMOS_OPTION_NO_CONTROL_AGENT
/*
* CONTROL AGENT
****************************************************************
*/
#include "ndmp/smc.h" /* SCSI Media Changer */
#ifndef NDM_MAX_MEDIA
#define NDM_MAX_MEDIA 40
#endif
struct ndm_media_table {
int n_media;
struct ndmmedia *head;
struct ndmmedia *tail;
};
/* ndma_listmgt.c */
extern struct ndmmedia * ndma_store_media (struct ndm_media_table *mtab, unsigned short element_address);
extern struct ndmmedia * ndma_clone_media_entry (struct ndm_media_table *mtab, struct ndmmedia *to_clone);
extern void ndmca_destroy_media_table (struct ndm_media_table *mtab);
#define NDM_JOB_OP_BACKUP (0x100 | 'c')
#define NDM_JOB_OP_EXTRACT (0x100 | 'x')
#define NDM_JOB_OP_TOC (0x100 | 't')
#define NDM_JOB_OP_QUERY_AGENTS (0x100 | 'q')
#define NDM_JOB_OP_INIT_LABELS (0x100 | 'I')
#define NDM_JOB_OP_LIST_LABELS (0x100 | 'L')
#define NDM_JOB_OP_REMEDY_ROBOT (0x100 | 'Z')
/* test operations */
#define NDM_JOB_OP_TEST_TAPE (0x200 | 'T')
#define NDM_JOB_OP_TEST_MOVER (0x200 | 'M')
#define NDM_JOB_OP_TEST_DATA (0x200 | 'D')
/* tape handling operations */
#define NDM_JOB_OP_REWIND_TAPE (0x300 | 'r')
#define NDM_JOB_OP_EJECT_TAPE (0x300 | 'j')
#define NDM_JOB_OP_MOVE_TAPE (0x300 | 'm')
#define NDM_JOB_OP_LOAD_TAPE (0x300 | 'l')
#define NDM_JOB_OP_UNLOAD_TAPE (0x300 | 'u')
#define NDM_JOB_OP_IMPORT_TAPE (0x300 | 'i')
#define NDM_JOB_OP_EXPORT_TAPE (0x300 | 'e')
#define NDM_JOB_OP_INIT_ELEM_STATUS (0x300 | 'I')
/* daemon operations */
#define NDM_JOB_OP_DAEMON 'd'
struct ndm_job_param {
int operation; /* NDM_JOB_OP_... */
int time_limit; /* command timeout, 0 is off */
struct ndmagent data_agent; /* DATA AGENT host/pw */
char * bu_type; /* e.g. "tar" */
int bu_level; /* e.g. 0..9 for dump */
struct ndm_env_table env_tab; /* for BACKUP+RECOVER ops */
struct ndm_nlist_table nlist_tab; /* for RECOVER ops */
struct ndm_env_table result_env_tab; /* after BACKUP */
struct ndmlog index_log; /* to log NDMP_FH_ADD_... */
struct ndmagent tape_agent; /* TAPE AGENT host/pw */
char * tape_device; /* eg "/dev/rmt0" */
unsigned tape_timeout; /* secs total to retry open */
unsigned record_size; /* in bytes, 10k typical */
unsigned long long last_w_offset; /* last window offset sent */
struct ndmscsi_target * tape_target; /* unused for now */
char * tape_tcp; /* tcp direct */
NDM_FLAG_DECL(use_eject) /* eject upon close (unload) */
struct ndmagent robot_agent; /* ROBOT AGENT host/pw */
struct ndmscsi_target * robot_target; /* SCSI coord of robot */
unsigned robot_timeout; /* secs total to retry move */
NDM_FLAG_DECL(have_robot) /* yes, we have robot, today */
NDM_FLAG_DECL(auto_remedy) /* if drive loaded, unload */
NDM_FLAG_DECL(remedy_all) /* OP_REMEDY, all drives */
NDM_FLAG_DECL(drive_addr_given)
NDM_FLAG_DECL(from_addr_given)
NDM_FLAG_DECL(to_addr_given)
unsigned drive_addr; /* 0->first, !0->elem addr */
unsigned from_addr; /* for MOVE and EXPORT */
unsigned to_addr; /* for MOVE and IMPORT */
/* use move for many I/E */
struct ndm_media_table media_tab; /* media to use, params */
struct ndm_media_table result_media_tab; /* results after job */
unsigned long n_file_entry;
unsigned long n_dir_entry;
unsigned long n_node_entry;
unsigned long long root_node;
unsigned long long bytes_written;
unsigned long long bytes_read;
};
/* ndma_job.c */
extern int ndma_job_audit (struct ndm_job_param *job,
char *errbuf, int errskip);
extern int ndma_job_media_audit (struct ndm_job_param *job,
char *errbuf, int errskip);
extern void ndma_job_auto_adjust (struct ndm_job_param *job);
struct ndm_control_agent {
/* The JOB, see immediately above */
struct ndm_job_param job;
NDM_FLAG_DECL(swap_connect)
NDM_FLAG_DECL(has_tcp_addr)
NDM_FLAG_DECL(has_local_addr)
/* DATA agent */
ndmp9_data_operation data_op;
ndmp9_data_get_state_reply data_state;
NDM_FLAG_DECL(pending_notify_data_read)
NDM_FLAG_DECL(pending_notify_data_halted)
ndmp9_notify_data_read_request last_notify_data_read;
ndmp9_addr data_addr;
int recover_log_file_count;
int recover_log_file_ok;
int recover_log_file_error;
/* Image stream */
ndmp9_addr mover_addr;
ndmp9_mover_mode mover_mode;
/* TAPE Agent */
ndmp9_mover_get_state_reply mover_state;
NDM_FLAG_DECL(pending_notify_mover_paused)
NDM_FLAG_DECL(pending_notify_mover_halted)
ndmp9_notify_mover_paused_request last_notify_mover_paused;
ndmp9_tape_open_mode tape_mode;
ndmp9_tape_get_state_reply tape_state;
/* Media management, media_table inside of job */
int cur_media_ix; /* references struct ndmmedia index field */
NDM_FLAG_DECL(media_is_loaded)
NDM_FLAG_DECL(is_label_op)
/* ROBOT Agent */
struct smc_ctrl_block * smc_cb;
unsigned drive_addr;
#ifndef NDMOS_OPTION_NO_TEST_AGENTS
/* when testing */
char * active_test; /* name of test or 0 if no test */
char * active_test_failed; /* active test failed */
char * active_test_warned; /* active test warned */
char * test_phase; /* name of sub-series test phase */
int test_step; /* test sequence number */
int n_step_pass; /* per phase test stats */
int n_step_fail;
int n_step_warn;
int n_step_tests;
int total_n_step_pass; /* total test stats */
int total_n_step_fail;
int total_n_step_warn;
int total_n_step_tests;
#endif
#ifdef NDMOS_MACRO_CONTROL_AGENT_ADDITIONS
NDMOS_MACRO_CONTROL_AGENT_ADDITIONS
#endif /* NDMOS_MACRO_CONTROL_AGENT_ADDITIONS */
};
/* ndma_control.c */
extern int ndmca_initialize (struct ndm_session *sess);
extern int ndmca_commission (struct ndm_session *sess);
extern int ndmca_decommission (struct ndm_session *sess);
extern int ndmca_destroy (struct ndm_session *sess);
extern int ndmca_control_agent (struct ndm_session *sess);
/* ndma_cops_backreco.c */
extern int ndmca_op_create_backup (struct ndm_session *sess);
extern int ndmca_op_recover_files (struct ndm_session *sess);
extern int ndmca_op_recover_fh (struct ndm_session *sess);
extern int ndmca_monitor_backup (struct ndm_session *sess);
extern int ndmca_monitor_get_post_backup_env (struct ndm_session *sess);
extern int ndmca_monitor_recover (struct ndm_session *sess);
extern int ndmca_backreco_startup (struct ndm_session *sess);
extern int ndmca_monitor_startup (struct ndm_session *sess);
extern int ndmca_monitor_shutdown (struct ndm_session *sess);
extern int ndmca_monitor_get_states (struct ndm_session *sess);
extern int ndmca_monitor_load_next (struct ndm_session *sess);
extern int ndmca_monitor_seek_tape (struct ndm_session *sess);
extern int ndmca_monitor_unload_last_tape (struct ndm_session *sess);
extern int ndmca_mon_wait_for_something (struct ndm_session *sess,
int max_delay_secs);
/* ndma_cops_labels.c */
extern int ndmca_op_init_labels (struct ndm_session *sess);
extern int ndmca_op_list_labels (struct ndm_session *sess);
/* ndma_cops_query.c */
extern int ndmca_op_query (struct ndm_session *sess);
extern int ndmca_opq_data (struct ndm_session *sess);
extern int ndmca_opq_tape (struct ndm_session *sess);
extern int ndmca_opq_robot (struct ndm_session *sess);
extern int ndmca_opq_host_info (struct ndm_session *sess,
struct ndmconn *conn);
extern int ndmca_opq_get_mover_type (struct ndm_session *sess,
struct ndmconn *conn);
extern int ndmca_opq_get_butype_attr (struct ndm_session *sess,
struct ndmconn *conn);
extern int ndmca_opq_get_fs_info (struct ndm_session *sess,
struct ndmconn *conn);
extern int ndmca_opq_get_tape_info (struct ndm_session *sess,
struct ndmconn *conn);
extern int ndmca_opq_get_scsi_info (struct ndm_session *sess,
struct ndmconn *conn);
extern void ndmalogqr (struct ndm_session *sess, char *fmt, ...);
/* ndma_cops_robot.c */
extern int ndmca_op_robot_remedy (struct ndm_session *sess);
extern int ndmca_op_robot_startup (struct ndm_session *sess,
int verify_media_flag);
extern int ndmca_op_init_elem_status (struct ndm_session *sess);
extern int ndmca_op_rewind_tape (struct ndm_session *sess);
extern int ndmca_op_eject_tape (struct ndm_session *sess);
extern int ndmca_op_mtio (struct ndm_session *sess,
ndmp9_tape_mtio_op mtio_op);
extern int ndmca_op_move_tape (struct ndm_session *sess);
extern int ndmca_op_import_tape (struct ndm_session *sess);
extern int ndmca_op_export_tape (struct ndm_session *sess);
extern int ndmca_op_load_tape (struct ndm_session *sess);
extern int ndmca_op_unload_tape (struct ndm_session *sess);
/* ndma_ctrl_calls.c */
extern int ndmca_data_get_state (struct ndm_session *sess);
extern int ndmca_data_connect (struct ndm_session *sess);
extern int ndmca_data_listen (struct ndm_session *sess);
extern int ndmca_data_start_backup (struct ndm_session *sess);
extern int ndmca_data_start_recover (struct ndm_session *sess);
extern int ndmca_data_start_recover_filehist (struct ndm_session *sess);
extern int ndmca_data_abort (struct ndm_session *sess);
extern int ndmca_data_get_env (struct ndm_session *sess);
extern int ndmca_data_stop (struct ndm_session *sess);
extern int ndmca_tape_open (struct ndm_session *sess);
extern int ndmca_tape_close (struct ndm_session *sess);
extern int ndmca_tape_get_state (struct ndm_session *sess);
extern int ndmca_tape_get_state_no_tattle (struct ndm_session *sess);
extern int ndmca_tape_mtio (struct ndm_session *sess,
ndmp9_tape_mtio_op op, u_long count, u_long *resid);
extern int ndmca_tape_write (struct ndm_session *sess,
char *buf, unsigned count);
extern int ndmca_tape_read (struct ndm_session *sess,
char *buf, unsigned count);
extern int ndmca_mover_get_state (struct ndm_session *sess);
extern int ndmca_mover_listen (struct ndm_session *sess);
extern int ndmca_mover_connect (struct ndm_session *sess);
extern int ndmca_mover_continue (struct ndm_session *sess);
extern int ndmca_mover_abort (struct ndm_session *sess);
extern int ndmca_mover_stop (struct ndm_session *sess);
extern int ndmca_mover_set_window (struct ndm_session *sess,
unsigned long long offset, unsigned long long length);
extern int ndmca_mover_read (struct ndm_session *sess,
unsigned long long offset, unsigned long long length);
extern int ndmca_mover_close (struct ndm_session *sess);
extern int ndmca_mover_set_record_size (struct ndm_session *sess);
/* ndma_ctrl_media.c */
extern int ndmca_media_load_first (struct ndm_session *sess);
extern int ndmca_media_load_next (struct ndm_session *sess);
extern int ndmca_media_unload_last (struct ndm_session *sess);
extern int ndmca_media_change (struct ndm_session *sess);
extern int ndmca_media_load_seek (struct ndm_session *sess,
unsigned long long pos);
extern int ndmca_media_load_current (struct ndm_session *sess);
extern int ndmca_media_unload_current (struct ndm_session *sess);
extern int ndmca_media_unload_best_effort (struct ndm_session *sess);
extern int ndmca_media_open_tape (struct ndm_session *sess);
extern int ndmca_media_close_tape (struct ndm_session *sess);
extern int ndmca_media_mtio_tape (struct ndm_session *sess,
ndmp9_tape_mtio_op op, u_long count, u_long *resid);
extern int ndmca_media_write_filemarks (struct ndm_session *sess);
extern int ndmca_media_read_label (struct ndm_session *sess,
char labbuf[]);
extern int ndmca_media_write_label (struct ndm_session *sess,
int type, char labbuf[]);
extern int ndmca_media_check_label (struct ndm_session *sess,
int type, char labbuf[]);
extern int ndmca_media_verify (struct ndm_session *sess);
extern int ndmca_media_tattle (struct ndm_session *sess);
extern unsigned long long
ndmca_media_capture_tape_offset (struct ndm_session *sess);
extern int ndmca_media_capture_mover_window (struct ndm_session *sess);
extern int ndmca_media_calculate_windows (struct ndm_session *sess);
extern int ndmca_media_calculate_offsets (struct ndm_session *sess);
extern int ndmca_media_set_window_current (struct ndm_session *sess);
/* ndma_ctrl_robot.c */
extern int ndmca_robot_issue_scsi_req (struct smc_ctrl_block *smc);
extern int ndmca_robot_prep_target (struct ndm_session *sess);
extern int ndmca_robot_obtain_info (struct ndm_session *sess);
extern int ndmca_robot_init_elem_status (struct ndm_session *sess);
extern int ndmca_robot_startup (struct ndm_session *sess);
extern int ndmca_robot_move (struct ndm_session *sess,
int src_addr, int dst_addr);
extern int ndmca_robot_load (struct ndm_session *sess, int slot_addr);
extern int ndmca_robot_unload (struct ndm_session *sess, int slot_addr);
extern struct smc_element_descriptor *
ndmca_robot_find_element (struct ndm_session *sess,
int element_address);
extern int ndmca_robot_check_ready (struct ndm_session *sess);
extern int ndmca_robot_remedy_ready (struct ndm_session *sess);
extern int ndmca_robot_query (struct ndm_session *sess);
extern int ndmca_robot_verify_media (struct ndm_session *sess);
extern int ndmca_robot_synthesize_media (struct ndm_session *sess);
/* ndma_ctrl_conn.c */
extern int ndmca_connect_xxx_agent (struct ndm_session *sess,
struct ndmconn **connp, char *prefix,
struct ndmagent *agent);
extern int ndmca_connect_data_agent (struct ndm_session *sess);
extern int ndmca_connect_tape_agent (struct ndm_session *sess);
extern int ndmca_connect_robot_agent (struct ndm_session *sess);
extern int ndmca_connect_control_agent (struct ndm_session *sess);
/* ndma_ctst_tape.c */
extern int ndmca_op_test_tape (struct ndm_session *sess);
/* ndma_ctst_mover.c */
extern int ndmca_op_test_mover (struct ndm_session *sess);
/* ndma_ctst_data.c */
extern int ndmca_op_test_data (struct ndm_session *sess);
/* ndma_ctst_subr.c */
extern int ndmca_test_query_conn_types (struct ndm_session *sess,
struct ndmconn *ref_conn);
extern int ndmca_test_load_tape (struct ndm_session *sess);
extern int ndmca_test_unload_tape (struct ndm_session *sess);
extern int ndmca_test_call (struct ndmconn *conn,
struct ndmp_xa_buf *xa, ndmp9_error expect_err);
extern int ndmca_test_check_expect_errs (struct ndmconn *conn,
int rc, ndmp9_error expect_errs[]);
extern int ndmca_test_check_expect (struct ndmconn *conn,
int rc, ndmp9_error expect_err);
extern int ndmca_test_check_expect_no_err (struct ndmconn *conn,
int rc);
extern int ndmca_test_check_expect_illegal_state (struct ndmconn *conn,
int rc);
extern int ndmca_test_check_expect_illegal_args (struct ndmconn *conn,
int rc);
extern void ndmca_test_phase (struct ndm_session *sess,
char *test_phase, char *desc);
extern void ndmca_test_log_step (struct ndm_session *sess,
int level, char *msg);
extern void ndmca_test_log_note (struct ndm_session *sess,
int level, char *msg);
extern void ndmca_test_done_phase (struct ndm_session *sess);
extern void ndmca_test_done_series (struct ndm_session *sess,
char *series_name);
extern void ndmca_test_open (struct ndm_session *sess,
char *test_name,
char *sub_test_name);
extern void ndmca_test_warn (struct ndm_session *sess, char *warn_msg);
extern void ndmca_test_fail (struct ndm_session *sess, char *fail_msg);
extern void ndmca_test_close (struct ndm_session *sess);
extern void ndmca_test_fill_data (char *buf, int bufsize,
int recno, int fileno);
#endif /* !NDMOS_OPTION_NO_CONTROL_AGENT */
#ifndef NDMOS_OPTION_NO_DATA_AGENT
/*
* DATA AGENT
****************************************************************
*
* NDMP Elements of Data Agent (backup)
*
* +-----------+stderr
* | bu_type |--------formatter_err---------NDMP_LOG-------> to CONTROL
* | formatter |
* | process |========formatter_data=+=====================> to image stream
* +-----------+stdout |
* +-------+
* | snoop |--NDMP_FH_ADD_x--> to CONTROL
* +-------+
*
****************************************************************
*
* NDMP Elements of Data Agent (recover)
*
* +-----------+stderr
* | bu_type |--------formatter_err---------NDMP_LOG-------> to CONTROL
* | formatter | +--------+
* | process |<=======fmt_data=| direct |==================< from image str
* +-----------+stdin | |-NOTIFY_DATA_READ-> to CONTROL
* | snoop |
* +--------+
*
****************************************************************
*
* NDMP Elements of Data Agent (recover filehist)
*
* +--------+
* | direct |==================< from image str
* | |-NOTIFY_DATA_READ-> to CONTROL
* | snoop |--NDMP_FH_ADD_x---> to CONTROL
* +--------+
*
****************************************************************
*/
#ifndef NDMDA_N_FMT_IMAGE_BUF
#define NDMDA_N_FMT_IMAGE_BUF (8*1024)
#endif
#ifndef NDMDA_N_FHH_BUF
#define NDMDA_N_FHH_BUF (8*1024)
#endif
#ifndef NDMDA_N_FMT_ERROR_BUF
#define NDMDA_N_FMT_ERROR_BUF (8*1024)
#endif
#ifndef NDMDA_N_FMT_WRAP_BUF
#define NDMDA_N_FMT_WRAP_BUF (4*1024)
#endif
#ifndef NDMDA_MAX_CMD
#define NDMDA_MAX_CMD (4*1024)
#endif
#ifndef NDMOS_OPTION_NO_GTAR_BUTYPE
extern int ndmda_butype_gtar_config_get_attrs (struct ndm_session *sess,
u_long *attrs_p, int protocol_version);
extern int ndmda_butype_gtar_config_get_default_env (
struct ndm_session *sess,
ndmp9_pval **env_p, int *n_env_p,
int protocol_version);
extern int ndmda_butype_gtar_attach (struct ndm_session *sess);
#endif
#ifndef NDMOS_OPTION_NO_DUMP_BUTYPE
extern int ndmda_butype_dump_config_get_attrs (struct ndm_session *sess,
u_long *attrs_p, int protocol_version);
extern int ndmda_butype_dump_config_get_default_env (
struct ndm_session *sess,
ndmp9_pval **env_p, int *n_env_p,
int protocol_version);
extern int ndmda_butype_dump_attach (struct ndm_session *sess);
#endif
struct ndm_data_recovery_interval {
ndmp9_u_quad offset;
ndmp9_u_quad length;
};
enum ndm_data_recovery_access_method {
NDMDA_RECO_ACCESS_SEQUENTIAL = 1,
NDMDA_RECO_ACCESS_DIRECT,
NDMDA_RECO_ACCESS_SEMI_DIRECT,
NDMDA_RECO_ACCESS_SEMI_DIRECT_PENDING
};
enum ndm_data_recovery_state {
NDMDA_RECO_STATE_START = 1,
NDMDA_RECO_STATE_PASS_THRU,
NDMDA_RECO_STATE_CHOOSE_NLENT,
NDMDA_RECO_STATE_ACQUIRE,
NDMDA_RECO_STATE_DISPOSE,
NDMDA_RECO_STATE_FINISH_NLENT,
NDMDA_RECO_STATE_ALL_DONE
};
enum ndm_data_recovery_acquire_mode {
NDMDA_RECO_ACQUIRE_EVERYTHING = 1,
NDMDA_RECO_ACQUIRE_SEARCHING,
NDMDA_RECO_ACQUIRE_MATCHING
};
enum ndm_data_recovery_disposition {
NDMDA_RECO_DISPOSITION_PASS = 1,
NDMDA_RECO_DISPOSITION_DISCARD
};
struct ndm_data_agent {
int protocol_version;
char bu_type[32];
struct ndm_env_table env_tab;
struct ndm_nlist_table nlist_tab;
NDM_FLAG_DECL(enable_hist)
unsigned long long pass_resid;
ndmp9_data_get_state_reply data_state;
int data_notify_pending;
struct ndmchan formatter_image; /* stdin/out */
struct ndmchan formatter_error; /* stderr */
struct ndmchan formatter_wrap; /* fd=3 */
int formatter_pid;
char * fmt_image_buf;
char * fmt_error_buf;
char * fmt_wrap_buf;
struct ndmfhheap fhh;
unsigned long * fhh_buf;
#ifdef NDMOS_MACRO_DATA_AGENT_ADDITIONS
NDMOS_MACRO_DATA_AGENT_ADDITIONS
#endif /* NDMOS_MACRO_DATA_AGENT_ADDITIONS */
};
/* ndma_data.c */
extern int ndmda_initialize (struct ndm_session *sess);
extern int ndmda_commission (struct ndm_session *sess);
extern int ndmda_decommission (struct ndm_session *sess);
extern int ndmda_destroy (struct ndm_session *sess);
extern int ndmda_belay (struct ndm_session *sess);
extern ndmp9_error ndmda_data_start_backup (struct ndm_session *sess);
extern ndmp9_error ndmda_data_start_recover (struct ndm_session *sess);
extern ndmp9_error ndmda_data_start_recover_fh (struct ndm_session *sess);
extern void ndmda_sync_state (struct ndm_session *sess);
extern ndmp9_error ndmda_data_listen (struct ndm_session *sess);
extern ndmp9_error ndmda_data_connect (struct ndm_session *sess);
extern void ndmda_data_abort (struct ndm_session *sess);
extern void ndmda_sync_environment (struct ndm_session *sess);
extern void ndmda_data_halt (struct ndm_session *sess,
ndmp9_data_halt_reason reason);
extern void ndmda_data_stop (struct ndm_session *sess);
extern int ndmda_quantum (struct ndm_session *sess);
extern int ndmda_quantum_image (struct ndm_session *sess);
extern int ndmda_quantum_stderr (struct ndm_session *sess);
extern int ndmda_quantum_wrap (struct ndm_session *sess);
extern int ndmda_wrap_in (struct ndm_session *sess,
char *wrap_line);
extern void ndmda_send_logmsg (struct ndm_session *sess,
char *fmt, ...);
extern void ndmda_send_notice (struct ndm_session *sess);
extern void ndmda_send_data_read (struct ndm_session *sess,
unsigned long long offset,
unsigned long long length);
extern int ndmda_copy_environment (struct ndm_session *sess,
ndmp9_pval *env, unsigned n_env);
extern struct ndmp9_pval *ndmda_find_env (struct ndm_session *sess,
char *name);
extern int ndmda_interpret_boolean_value (char *value_str,
int default_value);
extern void ndmda_purge_environment (struct ndm_session *sess);
extern int ndmda_copy_nlist (struct ndm_session *sess,
ndmp9_name *nlist, unsigned n_nlist);
extern void ndmda_purge_nlist (struct ndm_session *sess);
extern int ndmda_count_invalid_fh_info (struct ndm_session *sess);
extern int ndmda_count_invalid_fh_info_pending
(struct ndm_session *sess);
/* in ndma_data_recover.c */
extern int ndmda_quantum_recover_common (struct ndm_session *sess);
extern int ndmda_reco_state_start (struct ndm_session *sess);
extern int ndmda_reco_pass_thru (struct ndm_session *sess);
extern int ndmda_reco_state_pass_thru (struct ndm_session *sess);
extern int ndmda_reco_state_choose_nlent (struct ndm_session *sess);
extern int ndmda_reco_state_acquire (struct ndm_session *sess);
extern int ndmda_reco_state_dispose (struct ndm_session *sess);
extern int ndmda_reco_state_finish_nlent (struct ndm_session *sess);
extern int ndmda_reco_state_all_done (struct ndm_session *sess);
extern int ndmda_reco_assess_channels (struct ndm_session *sess);
extern int ndmda_reco_assess_intervals (struct ndm_session *sess);
extern int ndmda_reco_align_to_wanted (struct ndm_session *sess);
extern int ndmda_reco_obtain_wanted (struct ndm_session *sess);
extern int ndmda_reco_send_data_read (struct ndm_session *sess,
unsigned long long offset,
unsigned long long length);
extern int ndmda_reco_internal_error (struct ndm_session *sess,
char *why);
/* ndma_data_fh.c */
extern int ndmda_fh_initialize (struct ndm_session *sess);
extern int ndmda_fh_commission (struct ndm_session *sess);
extern int ndmda_fh_decommission (struct ndm_session *sess);
extern int ndmda_fh_destroy (struct ndm_session *sess);
extern int ndmda_fh_belay (struct ndm_session *sess);
extern void ndmda_fh_add_file (struct ndm_session *sess,
ndmp9_file_stat *filestat, char *name);
extern void ndmda_fh_add_dir (struct ndm_session *sess,
unsigned long long dir_fileno,
char *name,
unsigned long long fileno);
extern void ndmda_fh_add_node (struct ndm_session *sess,
ndmp9_file_stat *filestat);
extern int ndmda_fh_prepare (struct ndm_session *sess,
int vers, int msg, int entry_size,
unsigned n_item,
unsigned total_size_of_items);
extern void ndmda_fh_flush (struct ndm_session *sess);
/* ndma_data_pfe.c (pipe-fork-exec) */
extern int ndmda_pipe_fork_exec (struct ndm_session *sess,
char *cmd, int is_backup);
extern int ndmda_add_to_cmd_with_escapes (char *cmd,
char *word, char *special);
extern int ndmda_add_to_cmd (char *cmd, char *word);
extern int ndmda_add_to_cmd_allow_file_wildcards (char *cmd,
char *word);
#endif /* !NDMOS_OPTION_NO_DATA_AGENT */
#ifndef NDMOS_OPTION_NO_TAPE_AGENT
/*
* TAPE AGENT
****************************************************************
*/
struct ndm_tape_agent {
int protocol_version;
/* TAPE */
ndmp9_tape_get_state_reply tape_state;
/* MOVER */
ndmp9_mover_get_state_reply mover_state;
u_long mover_window_first_blockno;
unsigned long long mover_window_end;
unsigned long long mover_want_pos;
int mover_notify_pending;
int pending_change_after_drain;
ndmp9_mover_state pending_mover_state;
ndmp9_mover_halt_reason pending_mover_halt_reason;
ndmp9_mover_pause_reason pending_mover_pause_reason;
char *tape_buffer;
unsigned long tb_blockno;
#ifdef NDMOS_MACRO_TAPE_AGENT_ADDITIONS
NDMOS_MACRO_TAPE_AGENT_ADDITIONS
#endif /* NDMOS_MACRO_DATA_AGENT_ADDITIONS */
};
#define NDMTA_TAPE_IS_WRITABLE(TA) \
( (TA)->tape_state.open_mode == NDMP9_TAPE_RDWR_MODE \
|| (TA)->tape_state.open_mode == NDMP9_TAPE_RAW_MODE)
extern int ndmta_initialize (struct ndm_session *sess);
extern int ndmta_commission (struct ndm_session *sess);
extern int ndmta_decommission (struct ndm_session *sess);
extern int ndmta_destroy (struct ndm_session *sess);
extern int ndmta_init_mover_state (struct ndm_session *sess);
extern void ndmta_mover_sync_state (struct ndm_session *sess);
ndmp9_error ndmta_mover_listen (struct ndm_session *sess,
ndmp9_mover_mode mover_mode);
ndmp9_error ndmta_mover_connect (struct ndm_session *sess,
ndmp9_mover_mode mover_mode);
extern void ndmta_mover_halt (struct ndm_session *sess,
ndmp9_mover_halt_reason reason);
extern void ndmta_mover_pause (struct ndm_session *sess,
ndmp9_mover_pause_reason reason);
extern void ndmta_mover_active (struct ndm_session *sess);
extern void ndmta_mover_start_active (struct ndm_session *sess);
extern void ndmta_mover_stop (struct ndm_session *sess);
extern void ndmta_mover_abort (struct ndm_session *sess);
extern void ndmta_mover_continue (struct ndm_session *sess);
extern void ndmta_mover_close (struct ndm_session *sess);
extern void ndmta_mover_read (struct ndm_session *sess,
unsigned long long offset,
unsigned long long length);
extern int ndmta_quantum (struct ndm_session *sess);
extern int ndmta_read_quantum (struct ndm_session *sess);
extern int ndmta_write_quantum (struct ndm_session *sess);
extern void ndmta_mover_send_notice (struct ndm_session *sess);
#endif /* !NDMOS_OPTION_NO_TAPE_AGENT */
#ifndef NDMOS_OPTION_NO_ROBOT_AGENT
/*
* ROBOT AGENT
****************************************************************
*/
struct ndm_robot_agent {
int protocol_version;
ndmp9_scsi_get_state_reply scsi_state;
#ifdef NDMOS_MACRO_ROBOT_AGENT_ADDITIONS
NDMOS_MACRO_ROBOT_AGENT_ADDITIONS
#endif /* NDMOS_MACRO_ROBOT_AGENT_ADDITIONS */
};
extern int ndmra_initialize (struct ndm_session *sess);
extern int ndmra_commission (struct ndm_session *sess);
extern int ndmra_decommission (struct ndm_session *sess);
extern int ndmra_destroy (struct ndm_session *sess);
/* all semantic operations are done directly to the ndmos_scsi layer */
#endif /* !NDMOS_OPTION_NO_ROBOT_AGENT */
/*
* IMAGE STREAM
****************************************************************
*/
#ifndef NDM_N_IMAGE_STREAM_BUF
#define NDM_N_IMAGE_STREAM_BUF (100*1024)
#endif
enum ndmis_connect_status {
NDMIS_CONN_IDLE = 0,
NDMIS_CONN_LISTEN,
NDMIS_CONN_ACCEPTED,
NDMIS_CONN_CONNECTED,
NDMIS_CONN_DISCONNECTED,
NDMIS_CONN_CLOSED,
NDMIS_CONN_BOTCHED,
NDMIS_CONN_REMOTE,
NDMIS_CONN_EXCLUDE
};
typedef enum ndmis_connect_status ndmis_connect_status;
struct ndmis_end_point {
char * name;
ndmis_connect_status connect_status;
int transfer_mode;
ndmp9_addr_type addr_type;
};
struct ndmis_remote {
ndmis_connect_status connect_status;
int transfer_mode;
ndmp9_addr local_addr;
ndmp9_addr peer_addr;
ndmp9_addr listen_addr;
struct ndmchan listen_chan;
struct ndmchan sanity_chan;
};
struct ndm_image_stream {
struct ndmis_end_point data_ep;
struct ndmis_end_point tape_ep;
struct ndmis_remote remote;
/* transfer stuff */
int transfer_mode;
struct ndmchan chan;
char buf[NDM_N_IMAGE_STREAM_BUF];
};
extern int ndmis_initialize (struct ndm_session *sess);
extern int ndmis_commission (struct ndm_session *sess);
extern int ndmis_decommission (struct ndm_session *sess);
extern int ndmis_destroy (struct ndm_session *sess);
extern int ndmis_belay (struct ndm_session *sess);
extern int ndmis_quantum (struct ndm_session *sess);
extern ndmp9_error ndmis_data_listen (struct ndm_session *sess,
ndmp9_addr_type addr_type, ndmp9_addr *ret_addr,
char *reason);
extern ndmp9_error ndmis_tape_listen (struct ndm_session *sess,
ndmp9_addr_type addr_type, ndmp9_addr *ret_addr,
char *reason);
extern ndmp9_error ndmis_data_connect (struct ndm_session *sess,
ndmp9_addr *addr, char *reason);
extern ndmp9_error ndmis_tape_connect (struct ndm_session *sess,
ndmp9_addr *addr, char *reason);
extern int
ndmis_data_start (struct ndm_session *sess, int chan_mode);