File: zbd.h

package info (click to toggle)
libzbd 2.0.4-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 452 kB
  • sloc: ansic: 4,558; makefile: 117; sh: 1
file content (77 lines) | stat: -rw-r--r-- 1,536 bytes parent folder | download | duplicates (2)
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
// SPDX-License-Identifier: GPL-3.0-or-later
/*
 * SPDX-FileCopyrightText: 2021 Western Digital Corporation or its affiliates.
 *
 * Authors: Damien Le Moal (damien.lemoal@wdc.com)
 */
#ifndef _ZBD_TOOL_H_
#define _ZBD_TOOL_H_

#define _LARGEFILE64_SOURCE
#define _GNU_SOURCE

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <libgen.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <malloc.h>

#include "libzbd/zbd.h"

enum zbd_cmd {
	ZBD_REPORT,
	ZBD_RESET,
	ZBD_OPEN,
	ZBD_CLOSE,
	ZBD_FINISH,
	ZBD_DUMP,
	ZBD_RESTORE,
};

/*
 * Command line options and device information.
 */
struct zbd_opts {
	/* Common options */
	char			*dev_path;
	char			*dump_path;
	char			*dump_prefix;
	struct zbd_info		dev_info;
	enum zbd_cmd		cmd;
	long long		ofst;
	long long		len;
	size_t			unit;

	/* Report zones options */
	bool			rep_csv;
	bool			rep_num_zones;
	bool			rep_capacity;
	bool			rep_dump;
	enum zbd_report_option	rep_opt;
};

/*
 * Zone information dump file header.
 */
struct zbd_dump {
	struct zbd_info		dev_info;	/* 128 */

	unsigned int		zstart;		/* 132 */
	unsigned int		zend;		/* 136 */

	uint8_t			reserved[56];	/* 192 */
} __attribute__((packed));

int zbd_open_dump(struct zbd_opts *opts);
int zbd_dump_report_zones(int fd, struct zbd_opts *opts,
			  struct zbd_zone *zones, unsigned int *nr_zones);
int zbd_dump(int fd, struct zbd_opts *opts);
int zbd_restore(int fd, struct zbd_opts *opts);

#endif /* _ZBD_TOOL_H_ */