File: arch.h

package info (click to toggle)
diskscan 0.21-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,656 kB
  • sloc: ansic: 11,136; python: 338; xml: 138; sh: 41; makefile: 34
file content (56 lines) | stat: -rw-r--r-- 2,230 bytes parent folder | download | duplicates (6)
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
#ifndef _DISKSCAN_ARCH_H
#define _DISKSCAN_ARCH_H

#include "libscsicmd/include/scsicmd.h"

#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>

typedef struct disk_dev_t disk_dev_t;

typedef struct {
	enum result_data_e {
		DATA_FULL,         /* All data received for the request */
		DATA_PARTIAL,      /* Only some of the data was received/sent */
		DATA_NONE          /* No data was received/sent */
	} data;
	enum result_error_e {
		ERROR_NONE,        /* No error encountered */
		ERROR_CORRECTED,   /* A corrected error encountered */
		ERROR_UNCORRECTED, /* Unocrrected but non-fatal (i.e. local) error */
		ERROR_NEED_RETRY,  /* Temporary error that only merits a retry to complete */
		ERROR_FATAL,       /* A fatal error encountered, no reason to continue using disk */
		ERROR_UNKNOWN,     /* An unknown error encountered, continue for a while unless it persists */
	} error;

	sense_info_t info;
	unsigned char sense[256];
	unsigned sense_len;
} io_result_t;

typedef enum {
	DISK_NOT_MOUNTED = 0,
	DISK_MOUNTED_RO = 1,
	DISK_MOUNTED_RW = 2,
} disk_mount_e;

disk_mount_e disk_dev_mount_state(const char *path);

bool disk_dev_open(disk_dev_t *dev, const char *path);
void disk_dev_close(disk_dev_t *dev);
void disk_dev_cdb_out(disk_dev_t *dev, unsigned char *cdb, unsigned cdb_len, unsigned char *buf, unsigned buf_size, unsigned *buf_read,
		unsigned char *sense, unsigned sense_size, unsigned *sense_read, io_result_t *io_res);
void disk_dev_cdb_in(disk_dev_t *dev, unsigned char *cdb, unsigned cdb_len, unsigned char *buf, unsigned buf_size, unsigned *buf_read,
		unsigned char *sense, unsigned sense_size, unsigned *sense_read, io_result_t *io_res);

ssize_t disk_dev_read(disk_dev_t *dev, uint64_t offset_bytes, uint32_t len_bytes, void *buf, io_result_t *io_res);
ssize_t disk_dev_write(disk_dev_t *dev, uint64_t offset_bytes, uint32_t len_bytes, void *buf, io_result_t *io_res);
int disk_dev_read_cap(disk_dev_t *dev, uint64_t *size_bytes, uint64_t *sector_size);
int disk_dev_identify(disk_dev_t *dev, char *vendor, char *model, char *fw_rev, char *serial, bool *is_ata, unsigned char *ata_buf, unsigned *ata_buf_len);

void mac_read(unsigned char *buf, int len);

#include "arch-internal.h"

#endif