1 #ifndef DDPT_H
2 #define DDPT_H
3 
4 /* This is a C header file for the ddpt utility. See ddpt.c and ddpt.8
5  * for more information.
6  */
7 
8 #ifndef _XOPEN_SOURCE
9 #define _XOPEN_SOURCE 600
10 #endif
11 
12 #ifndef _GNU_SOURCE
13 #define _GNU_SOURCE
14 #endif
15 
16 #include <unistd.h>
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <signal.h>
20 #include <sys/time.h>
21 
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #ifdef SG_LIB_WIN32
31 #include <windows.h>
32 #endif
33 
34 #ifdef SG_LIB_FREEBSD
35 #ifndef SIGINFO
36 /* hack to undo hiding by _XOPEN_SOURCE and _GNU_SOURCE */
37 #define SIGINFO         29
38 #endif
39 #endif
40 
41 #ifdef SG_LIB_WIN32
42 #ifdef SG_LIB_MINGW
43 #define SIGPIPE 13
44 #define SIGQUIT 3
45 #define SIGUSR1 25
46 #endif
47 #endif
48 
49 /* Borrow signal handling from dd (src/dd.c in coreutils-8.13) */
50 /* Use SA_NOCLDSTOP as a proxy for whether the sigaction machinery is
51    present.  */
52 #ifndef SA_NOCLDSTOP
53 # define SA_NOCLDSTOP 0
54 # define sigprocmask(How, Set, Oset) /* empty */
55 # define sigset_t int
56 # if ! HAVE_SIGINTERRUPT
57 #  define siginterrupt(sig, flag) /* empty */
58 # endif
59 #endif
60 
61 /* NonStop circa 2011 lacks SA_RESETHAND; see Bug#9076.  */
62 #ifndef SA_RESETHAND
63 # define SA_RESETHAND 0
64 #endif
65 
66 #ifndef SIGINFO
67 # define SIGINFO SIGUSR1
68 #endif
69 /* end of borrow from dd signal handling defines */
70 
71 
72 #define STR_SZ 1024
73 #define INOUTF_SZ 512
74 #define EBUFF_SZ 512
75 
76 #define DEF_BLOCK_SIZE 512
77 #define DEF_BPT_LT8 8192     /* BPT when IBS < 8 */
78 #define DEF_BPT_LT64 1024    /* BPT when IBS < 64 */
79 #define DEF_BPT_LT1024 128   /* BPT when IBS < 1024 */
80 #define DEF_BPT_LT8192 16    /* BPT when IBS < 8192 */
81 #define DEF_BPT_LT32768 4    /* BPT when IBS < 32768 */
82 #define DEF_BPT_GE32768 1    /* BPT when IBS >= 32768 */
83 #define MAX_XC_BPT 65535     /* BPT maximum for xcopy(LID1) */
84 #define MAX_XC_BPT_POW2 32768  /* BPT maximum that is power of 2 */
85 #define DEF_SCSI_CDBSZ 10
86 #define MAX_SCSI_CDBSZ 32
87 #define DDPT_MAX_JF_DEPTH 4
88 #define DDPT_MAX_JF_LINES 1000
89 #define DDPT_MAX_JF_ARGS_PER_LINE 16
90 
91 #define VPD_DEVICE_ID 0x83
92 #define VPD_3PARTY_COPY 0x8f
93 
94 #define SENSE_BUFF_LEN 32       /* Arbitrary, could be larger */
95 #define READ_CAP_REPLY_LEN 8
96 #define RCAP16_REPLY_LEN 32
97 
98 #define DEF_RW_TIMEOUT 60       /* 60 seconds for READ and WRITE */
99 #define WRITE_SAME16_TIMEOUT 180  /* 3 minutes */
100 
101 #define DEF_GROUP_NUM 0
102 #define DEF_LID4_LID 257        /* just above the LID1 highest of 255 */
103 #define DEF_LID4_WR_LID 258
104 
105 #ifdef SG_LIB_LINUX
106 #ifndef RAW_MAJOR
107 #define RAW_MAJOR 255   /*unlikey value */
108 #endif
109 #define DEV_NULL_MINOR_NUM 3
110 #endif
111 
112 #define SG_LIB_FLOCK_ERR 90
113 
114 /* File type categories */
115 #define FT_OTHER 1              /* unknown (unable to identify) */
116 #define FT_PT 2                 /* SCSI commands can be sent via a
117                                    pass-through */
118 #define FT_REG 4                /* a normal (regular) file */
119 #define FT_DEV_NULL 8           /* either "/dev/null" or "." as filename */
120 #define FT_TAPE 16              /* tape style device */
121 #define FT_BLOCK 32             /* block device */
122 #define FT_FIFO 64              /* fifo (named or unnamed pipe (stdout)) */
123 #define FT_CHAR 128             /* char dev, doesn't fit another category */
124 #define FT_ERROR 256            /* couldn't "stat" file */
125 #define FT_ALL_FF 512           /* iflag=ff so input will be 0xff bytes */
126 
127 /* ODX type requested */
128 #define ODX_REQ_NONE 0          /* some other type of copy */
129 #define ODX_READ_INTO_RODS 1    /* POPULATE TOKENs (PTs): disk->rods */
130 #define ODX_WRITE_FROM_RODS 2   /* WRITE USING TOKENs (WUTs): rods->disk */
131 #define ODX_COPY 3              /* odx disk->disk or zero->disk */
132 
133 /* ROD Types used by ODX */
134 #define RODT_CM_INTERNAL 0x0
135 #define RODT_ACCESS_ON_REF 0x10000
136 #define RODT_PIT_DEF 0x800000
137 #define RODT_PIT_VULN 0x800001
138 #define RODT_PIT_PERS 0x800002
139 #define RODT_PIT_ANY 0x80ffff
140 #define RODT_BLK_ZERO 0xffff0001
141 
142 /* If O_DIRECT or O_SYNC not supported then define harmlessly */
143 #ifndef O_DIRECT
144 #define O_DIRECT 0
145 #endif
146 #ifndef O_SYNC
147 #define O_SYNC 0
148 #endif
149 #ifndef O_NONBLOCK
150 #define O_NONBLOCK 0
151 #endif
152 
153 #define DDPT_ARG_IN 0
154 #define DDPT_ARG_OUT 1
155 #define DDPT_ARG_OUT2 2
156 
157 #define MIN_RESERVED_SIZE 8192
158 
159 #define MAX_UNIT_ATTENTIONS 10
160 #define MAX_ABORTED_CMDS 16
161 
162 #define DELAY_COPY_SEGMENT 0
163 #define DELAY_WRITE 1
164 
165 #define REASON_TAPE_SHORT_READ 1024     /* leave_reason indication */
166 
167 /* Following used for sense_key=aborted_command, asc=0x10, ascq=* which
168  * contains errors associated with protection fields */
169 #ifndef SG_LIB_CAT_PROTECTION
170 #define SG_LIB_CAT_PROTECTION 40
171 #define SG_LIB_CAT_PROTECTION_WITH_INFO 41
172 #endif
173 
174 #define DDPT_CAT_PARAM_LST_LEN_ERR 50
175 #define DDPT_CAT_INVALID_FLD_IN_PARAM 51
176 #define DDPT_CAT_TOO_MANY_SEGS_IN_PARAM 52
177 #define DDPT_CAT_TARGET_UNDERRUN 53
178 #define DDPT_CAT_TARGET_OVERRUN 54
179 #define DDPT_CAT_OP_IN_PROGRESS 55
180 #define DDPT_CAT_INSUFF_RES_CREATE_ROD 56
181 #define DDPT_CAT_INSUFF_RES_CREATE_RODTOK 57
182 #define DDPT_CAT_CMDS_CLEARED_BY_DEV_SVR 58
183 #define DDPT_CAT_TOKOP_BASE 70        /* assume less than 20 above this */
184 
185 #define XCOPY_TO_SRC "XCOPY_TO_SRC"
186 #define XCOPY_TO_DST "XCOPY_TO_DST"
187 #define DEF_XCOPY_SRC0_DST1 1
188 #define ODX_RTF_LEN "ODX_RTF_LEN"     /* append 8 byte ROD size to token */
189 #define DDPT_DEF_BS "DDPT_DEF_BS" /* default default block size: 512 bytes */
190 
191 /* ODX: length field inside ROD Token constant, implies 512 byte ROD Token */
192 #define ODX_ROD_TOK_LEN_FLD 504       /* 0x1f8 */
193 
194 #define DEF_ODX_POLL_DELAY_MS 500
195 
196 /* In SPC-4 the cdb opcodes have more generic names */
197 #define THIRD_PARTY_COPY_OUT_CMD 0x83
198 #define THIRD_PARTY_COPY_IN_CMD 0x84
199 
200 /* Third party copy IN (opcode 0x84) and OUT (opcode 0x83) command service
201  * actions */
202 #define SA_XCOPY_LID1           0x0     /* OUT, originate */
203 #define SA_XCOPY_LID4           0x1     /* OUT, originate */
204 #define SA_POP_TOK              0x10    /* OUT, originate */
205 #define SA_WR_USING_TOK         0x11    /* OUT, originate */
206 #define SA_COPY_ABORT           0x1C    /* OUT, abort */
207 #define SA_COPY_STATUS_LID1     0x0     /* IN, retrieve */
208 #define SA_COPY_DATA_LID1       0x1     /* IN, retrieve */
209 #define SA_COPY_OP_PARAMS       0x3     /* IN, retrieve */
210 #define SA_COPY_FAIL_DETAILS    0x4     /* IN, retrieve */
211 #define SA_COPY_STATUS_LID4     0x5     /* IN, retrieve */
212 #define SA_COPY_DATA_LID4       0x6     /* IN, retrieve */
213 #define SA_ROD_TOK_INFO         0x7     /* IN, retrieve */
214 #define SA_ALL_ROD_TOKS         0x8     /* IN, retrieve */
215 
216 #define MAX_FIXED_SGL_ELEMS 128         /* same for gl and sl; MS max is 64 */
217 
218 
219 struct scat_gath_elem {
220     uint64_t lba;       /* of first block */
221     uint32_t num;       /* of blocks */
222 };
223 
224 struct block_rodtok_vpd {
225     uint16_t max_range_desc;
226     uint32_t max_inactivity_to;
227     uint32_t def_inactivity_to;
228     uint32_t max_tok_xfer_size;
229     uint32_t optimal_xfer_count;
230 };
231 
232 /* One instance for arguments to iflag= , another instance for oflag=
233  * conv= arguments are mapped to flag arguments.
234  * General or for disk unless otherwise marked. */
235 struct flags_t {
236     int append;
237     int atomic;
238     int block;          /* only for pt, non blocking default */
239     int bytchk;         /* set field in WRITE AND VERIFY */
240     int cat;            /* xcopy(lid1) related */
241     int cdbsz;
242     int coe;
243     int dc;             /* xcopy(lid1) related */
244     int del_tkn;        /* xcopy(odx) related */
245     int direct;
246     int dpo;
247     int errblk;
248     int excl;
249     int fdatasync;
250     int ff;             /* iflag=ff makes input all 0xff bytes */
251     int flock;
252     int force;
253     int fsync;
254     int fua;
255     int fua_nv;
256     int ignoreew;       /* tape */
257     int immed;          /* xcopy(odx) related */
258     int nocache;
259     int no_del_tkn;     /* xcopy(odx) related */
260     int nofm;           /* tape */
261     int nopad;
262     int norcap;
263     int nowrite;
264     int odx;            /* xcopy(LID4), sbc-3's POPULATE TOKEN++ */
265     int pad;            /* used for xcopy(lid1) or tape */
266     int prealloc;
267     int pt;             /* use pass-through to inject SCSI commands */
268     int resume;
269     int rarc;
270     int retries;
271     int rtf_len;
272     int self;
273     int sparing;
274     int sparse;
275     int ssync;
276     int strunc;
277     int sync;
278     int trunc;
279     int verify;         /* oflag with pt, turns WRITE into WRITE AND VERIFY */
280     int wsame16;
281     int xcopy;          /* xcopy(LID1) */
282 };
283 
284 /* one instance per file/device: if, of and of2 */
285 struct dev_info_t {
286     int d_type;         /* one of FT_* values */
287     int d_type_hold;
288     int fd;
289 #ifdef SG_LIB_WIN32
290     HANDLE fh;
291 #endif
292     int pdt;
293     int prot_type;      /* from RCAP(16) or 0 */
294     int p_i_exp;        /* protection intervals exponent */
295     unsigned long xc_min_bytes;
296     unsigned long xc_max_bytes;
297     char fn[INOUTF_SZ];
298     struct block_rodtok_vpd * odxp;
299     struct sg_pt_base * ptvp;
300 };
301 
302 /* command line options and most other state */
303 /* The _given fields indicate whether option was given or is a default */
304 struct opts_t {
305     /* command line related variables */
306     int64_t skip;
307     int64_t seek;
308     int count_given;
309     int bs_given;       /* 1 implies bs= option given on command line */
310     int delay;          /* intra copy segment delay in milliseconds */
311     int wdelay;         /* delay prior to each write in copy segment */
312     int subsequent_wdelay;      /* so no delay before first write */
313     int ibs;
314     int ibs_pi;    /* if (protect) ibs_pi = ibs+pi_len else ibs_pi=ibs */
315     int ibs_given;
316     int obs;
317     int obs_pi;    /* if (protect) obs_pi = obs+pi_len else obs_pi=obs */
318     int obs_given;
319     int bpt_i;          /* blocks (of input) per transfer */
320     int bpt_given;
321     int obpch;          /* output blocks per check, granularity of sparse,
322                          * sparing and trim checks for zeros */
323     int id_usage;       /* xcopy(LID1) List identifier usage, init to -1 */
324     int interrupt_io;   /* [intio=0|1] if 0, mask SIGINFO++ during IO */
325     uint32_t list_id;   /* xcopy(LID1) and odx related */
326     int list_id_given;
327     int outf_given;
328     int prio;           /* xcopy(LID1) related */
329     int rdprotect;
330     int wrprotect;
331     int cdbsz_given;
332     int coe_limit;
333     int coe_count;
334     int verbose;
335     int quiet;
336     int do_help;
337     int do_time;
338     int has_xcopy;      /* --xcopy (LID1): iflag=xcopy or oflag=xcopy */
339     int odx_request;    /* ODX_REQ_NONE==0 for no ODX */
340     int has_odx;        /* --odx: equivalent to iflag=odx or oflag=odx */
341     uint32_t inactivity_to;     /* ODX: timeout in seconds */
342     uint32_t rod_type;          /* ODX: ROD type */
343     int rod_type_given;
344     int64_t offset_in_rod;      /* ODX: units are obs bytes */
345     int timeout_xcopy;          /* xcopy(LID1) and ODX */
346     int in_sgl_elems;           /* xcopy, odx */
347     int out_sgl_elems;          /* xcopy, odx */
348     int rtf_fd;                 /* ODX: rtf's file descriptor (init: -1) */
349     int rtf_len_add;            /* append 64 bit ROD byte size to token */
350     int rtf_append;             /* if rtf is regular file: open(O_APPEND) */
351     char rtf[INOUTF_SZ];        /* ODX: ROD token filename */
352     struct scat_gath_elem * in_sgl;     /* xcopy, odx: alternative to skip=
353                                          * and count= */
354     struct scat_gath_elem * out_sgl;    /* xcopy, odx: alternative to seek=
355                                          * and count= */
356     struct flags_t * iflagp;
357     struct dev_info_t * idip;
358     struct flags_t * oflagp;
359     struct dev_info_t * odip;
360     struct dev_info_t * o2dip;
361     /* working variables and statistics */
362     int64_t dd_count;   /* -1 for not specified, 0 for no blocks to copy */
363                         /* after copy/read starts, decrements to 0 */
364     int64_t dd_count_start;     /* dd_count prior to start of copy/read */
365     int64_t in_full;    /* full blocks read from IFILE so far */
366     int64_t out_full;   /* full blocks written to OFILE so far */
367     int64_t out_sparse; /* used for sparse, sparing + trim */
368     int64_t lowest_unrecovered;         /* on reads */
369     int64_t highest_unrecovered;        /* on reads */
370     int64_t num_xcopy;                  /* xcopy(LID1) */
371     int in_partial;
372     int max_aborted;
373     int max_uas;
374     int out_partial;
375     int out_sparse_active;
376     int out_sparing_active;
377     int out_sparse_partial;
378     int out_trim_active;
379     int recovered_errs;          /* on reads */
380     int unrecovered_errs;        /* on reads */
381     int wr_recovered_errs;
382     int wr_unrecovered_errs;
383     int xc_cat;
384     int xc_dc;
385     int status_none;
386     int trim_errs;
387     int read_tape_numbytes;
388     int last_tape_read_len;  /* Length of previous tape read */
389     unsigned int consec_same_len_reads;
390     int num_retries;
391     int sum_of_resids;
392     int interrupted_retries;
393     int err_to_report;
394     int reading_fifo;
395     int read1_or_transfer; /* 1 when of=/dev/null or similar */
396     int ibs_hold;
397     int o_readonly;
398     unsigned char * wrkBuff;
399     unsigned char * wrkPos;
400     unsigned char * wrkBuff2;
401     unsigned char * wrkPos2;
402     unsigned char * zeros_buff;
403 #ifdef HAVE_POSIX_FADVISE
404     off_t lowest_skip;
405     off_t lowest_seek;
406 #endif
407 #if SA_NOCLDSTOP
408     sigset_t caught_signals;
409     sigset_t orig_mask;
410 #endif
411 #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
412     int start_tm_valid;
413     struct timespec start_tm;
414 #elif defined(HAVE_GETTIMEOFDAY)
415     int start_tm_valid;
416     struct timeval start_tm;
417 #endif
418     FILE * errblk_fp;
419     int wscan;  /* only used on Windows, for scanning devices */
420 };
421 
422 /* state of working variables within do_copy() */
423 /* permits do_copy() to be broken up into lots of helpers */
424 struct cp_state_t {
425     int64_t if_filepos;
426     int64_t of_filepos;
427     int icbpt;
428     int ocbpt;
429     int bytes_read;
430     int bytes_of;
431     int bytes_of2;
432     int leave_after_write;
433     int leave_reason;   /* ==0 for no error (e.g. EOF) */
434     int partial_write_bytes;
435 };
436 
437 struct val_str_t {
438     int num;
439     const char * name;
440 };
441 
442 /* This data is from the parameter data found in data-in of RRTI command */
443 struct rrti_resp_t {
444     uint8_t for_sa;     /* response to service action */
445     uint8_t cstat;      /* copy operation status */
446     uint8_t xc_cstatus; /* extended copy completion status */
447     uint8_t sense_len;  /* (parameter data, actual) sense data length */
448     uint32_t esu_del;   /* estimated status update delay (ms) */
449     uint64_t tc;        /* transfer count (blocks) */
450     uint32_t rt_len;    /* might differ from 512, 0 if no ROD token */
451     unsigned char rod_tok[512]; /* (perhaps truncate to) ODX ROD Token */
452 };
453 
454 struct sg_simple_inquiry_resp;
455 
456 
457 /* Functions declared below are shared by different compilation units */
458 
459 /* defined in ddpt.c */
460 /* No global function defined in ddpt.c apart from main() */
461 
462 /* defined in ddpt_com.c */
463 #ifdef __GNUC__
464 int pr2serr(const char * fmt, ...) __attribute__ ((format (printf, 1, 2)));
465 #else
466 int pr2serr(const char * fmt, ...);
467 #endif
468 void sleep_ms(int millisecs);
469 void state_init(struct opts_t * op, struct flags_t * ifp,
470                 struct flags_t * ofp, struct dev_info_t * idip,
471                 struct dev_info_t * odip, struct dev_info_t * o2dip);
472 void print_stats(const char * str, struct opts_t * op, int who);
473 int dd_filetype(const char * filename, int verbose);
474 char * dd_filetype_str(int ft, char * buff, int max_bufflen,
475                        const char * fname);
476 void calc_duration_init(struct opts_t * op);
477 void calc_duration_throughput(const char * leadin, int contin,
478                               struct opts_t * op);
479 void print_blk_sizes(const char * fname, const char * access_typ,
480                      int64_t num_blks, int blk_sz, int to_stderr);
481 void zero_coe_limit_count(struct opts_t * op);
482 int get_blkdev_capacity(struct opts_t * op, int which_arg,
483                         int64_t * num_blks, int * blk_sz);
484 void errblk_open(struct opts_t * op);
485 void errblk_put(uint64_t lba, struct opts_t * op);
486 void errblk_put_range(uint64_t lba, int num, struct opts_t * op);
487 void errblk_close(struct opts_t * op);
488 #ifdef SG_LIB_LINUX
489 void print_tape_summary(struct opts_t * op, int res, const char * str);
490 void print_tape_pos(const char * prefix, const char * postfix,
491                     struct opts_t * op);
492 #endif
493 void install_signal_handlers(struct opts_t * op);
494 void signals_process_delay(struct opts_t * op, int delay_type);
495 void decode_designation_descriptor(const unsigned char * ucp, int len_less_4,
496                                    int to_stderr, int verb);
497 int coe_process_eio(struct opts_t * op, int64_t skip);
498 char * rod_type_str(uint32_t rt, char * b, int b_mlen);
499 char * rt_cm_id_str(const unsigned char * rtp, int rt_len, char * b,
500                     int b_mlen);
501 void print_exit_status_msg(const char * prefix, int exit_stat, int to_stderr);
502 int cl_to_sgl(const char * inp, struct scat_gath_elem * sgl_arr,
503               int * arr_len, int max_arr_len);
504 int file_to_sgl(const char * file_name, struct scat_gath_elem * sgl_arr,
505                 int * arr_len, int max_arr_len);
506 
507 /* defined in ddpt_pt.c */
508 void * pt_construct_obj(void);
509 void pt_destruct_obj(void * vp);
510 int pt_open_if(struct opts_t * op, struct sg_simple_inquiry_resp * sirp);
511 int pt_open_of(struct opts_t * op, struct sg_simple_inquiry_resp * sirp);
512 void pt_close(int fd);
513 int pt_read_capacity(struct opts_t * op, int in0_out1, int64_t * num_blks,
514                      int * blk_sz);
515 int pt_read(struct opts_t * op, int in0_out1, unsigned char * buff,
516             int blocks, int * blks_readp);
517 int pt_write(struct opts_t * op, const unsigned char * buff, int blocks,
518              int64_t to_block);
519 int pt_write_same16(struct opts_t * op, const unsigned char * buff, int bs,
520                     int blocks, int64_t start_block);
521 void pt_sync_cache(int fd);
522 int pt_3party_copy_out(int sg_fd, int sa, uint32_t list_id, int group_num,
523                        int timeout_secs, void * paramp, int param_len,
524                        int noisy, int verbose, int err_vb);
525 int pt_3party_copy_in(int sg_fd, int sa, uint32_t list_id, int timeout_secs,
526                       void * resp, int mx_resp_len, int noisy, int verbose,
527                       int err_vb);
528 
529 /* defined in ddpt_xcopy.c */
530 int open_rtf(struct opts_t * op);
531 const char * cpy_op_status_str(int cos, char * b, int blen);
532 uint64_t count_sgl_blocks(const struct scat_gath_elem * sglp, int elems);
533 int print_3pc_vpd(struct opts_t * op, int to_stderr);
534 int do_xcopy_lid1(struct opts_t * op);
535 int do_pop_tok(struct opts_t * op, uint64_t blk_off, uint32_t num_blks,
536                int walk_list_id, int vb_a);
537 int do_rrti(struct opts_t * op, int in0_out1, struct rrti_resp_t * rrp,
538             int verb);
539 void get_local_rod_tok(unsigned char * tokp, int max_tok_len);
540 int process_after_poptok(struct opts_t * op, uint64_t * tcp, int vb_a);
541 int do_wut(struct opts_t * op, unsigned char * tokp, uint64_t blk_off,
542            uint32_t num_blks, uint64_t oir, int more_left, int walk_list_id,
543            int vb_a);
544 int process_after_wut(struct opts_t * op, uint64_t * tcp, int vb_a);
545 int do_odx(struct opts_t * op);
546 
547 /* defined in ddpt_cl.c */
548 int cl_process(struct opts_t * op, int argc, char * argv[],
549                const char * version_str, int jf_depth);
550 void ddpt_usage(int help);
551 
552 
553 #ifdef SG_LIB_WIN32
554 /* defined in ddpt_win32.c */
555 int win32_dd_filetype(const char * fn, int verbose);
556 int win32_get_blkdev_capacity(struct opts_t * optsp, int which_arg,
557                               int64_t * num_blks, int * blk_sz);
558 void win32_adjust_fns_pt(struct opts_t * optsp);
559 int win32_open_if(struct opts_t * optsp, int flags, int verbose);
560 int win32_open_of(struct opts_t * optsp, int flags, int verbose);
561 int win32_set_file_pos(struct opts_t * optsp, int if0_of1, int64_t pos,
562                        int verbose);
563 int win32_block_read(struct opts_t * optsp, unsigned char * bp, int num_bytes,
564                      int verbose);
565 int win32_block_read_from_of(struct opts_t * optsp, unsigned char * bp,
566                              int num_bytes, int verbose);
567 int win32_block_write(struct opts_t * optsp, const unsigned char * bp,
568                       int num_bytes, int verbose);
569 int win32_cp_read_block(struct opts_t * optsp, struct cp_state_t * csp,
570                         unsigned char * wrkPos, int * ifull_extrap,
571                         int verbose);
572 void win32_sleep_ms(int millisecs);
573 
574 int sg_do_wscan(char letter, int do_scan, int verb);
575 #ifndef HAVE_SYSCONF
576 size_t win32_pagesize(void);
577 #endif
578 #endif          /* SG_LIB_WIN32 */
579 
580 #ifdef __cplusplus
581 }
582 #endif
583 
584 #endif
585