This file is indexed.

/usr/include/dmraid/format.h is in libdmraid-dev 1.0.0.rc16-4.2ubuntu3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
/*
 * Copyright (C) 2004-2009  Heinz Mauelshagen, Red Hat GmbH.
 *                          All rights reserved.
 * 
 * Copyright (C) 2007,2009   Intel Corporation. All rights reserved.
 * November, 2007 - additions for Create, Delete, Rebuild & Raid 10. 
 * March, 2008 - additions for hot-spare check
 * August, 2008 - additions for Activation, Rebuild check
 * January, 2009 - additions for Activation, Rebuild check
 *
 * See file LICENSE at the top of this source tree for license information.
 */

#ifndef	_FORMAT_H_
#define	_FORMAT_H_

#ifdef FORMAT_HANDLER
#undef FORMAT_HANDLER

#include <sys/types.h>
#include <dmraid/list.h>
#include <dmraid/metadata.h>

/* Metadata format handler types. */
enum fmt_type {
	FMT_RAID,
	FMT_PARTITION,
};

/*
 * Various structures for data whipped with the different event types.
 */
/* Event: I/O error */
struct event_io {
	struct raid_set *rs;	/* RAID set of I/O error. */
	struct raid_dev *rd;	/* RAID device of I/O error. */
	uint64_t sector;	/* Sector of the I/O error. */
};

/* Event: RAID device add/remove */
enum rd_action {
	rd_add,
	rd_remove,
};

struct event_rd {
	struct raid_set *rs;
	struct raid_dev *rd;
	enum rd_action action;
};

/*
 * List of event handler functions to call for the metadata format handler.
 *
 * Return 1 for event taken, RAID device write necessary.
 * Return 0 for error and/or write unnecessary.
 */
struct event_handlers {
	/* Handle IO error */
	int (*io) (struct lib_context * lc, struct event_io * e_io);

	/* Handle RAID device add/remove. */
	int (*rd) (struct lib_context * lc, struct event_rd * e_rd);
};

/*
 * Hot-spare search types list: it can be searched locally/globally 
 */
enum scope {
	t_scope_local = 0x01,
	t_scope_global = 0x02
};

/* Metadata Handler commands */
enum handler_commands {
	UPDATE_REBUILD_STATE,
	GET_REBUILD_STATE,
	GET_REBUILD_DRIVE,
	GET_REBUILD_DRIVE_NO,
	CHECK_HOT_SPARE,
	ALLOW_ACTIVATE,
	ALLOW_REBUILD,
	GET_STATUS,
	GET_DEVICE_IDX,
	GET_NUMBER_OF_DEVICES,
	/* ... */
};

/* Union to return metadata_handler information. */
struct handler_info {
	unsigned short size;

	union {
		char *str;
		void *ptr;
		int8_t i8;
		int16_t i16;
		int32_t i32;
		int64_t i64;
		uint8_t u8;
		uint16_t u16;
		uint32_t u32;
		uint64_t u64;
	} data;
};

/*
 * Virtual interface definition of a metadata format handler.
 */
struct dmraid_format {
	const char *name;	/* Format name */
	const char *descr;	/* Format description */
	const char *caps;	/* Capabilities (RAID levels supported) */
	enum fmt_type format;	/* Format type (RAID, partition) */

	/*
	 * Read RAID metadata off a device and unify it.
	 */
	struct raid_dev *(*read) (struct lib_context * lc,
				  struct dev_info * di);

	/*
	 * Write RAID metadata to a device deunifying it
	 * or erase ondisk metadata if erase != 0.
	 */
	int (*write) (struct lib_context * lc, struct raid_dev * rd, int erase);

	/*
	 * delete RAID metadata to devices.
	 */
	int (*delete) (struct lib_context * lc, struct raid_set * rs);

	/*
	 * create RAID metadata to devices.
	 */
	int (*create) (struct lib_context * lc, struct raid_set * rs);

	/*
	 * Group a RAID device into a set.
	 */
	struct raid_set *(*group) (struct lib_context * lc,
				   struct raid_dev * rd);

	/*
	 * Check consistency of the RAID set metadata.
	 */
	int (*check) (struct lib_context * lc, struct raid_set * rs);

	/* Metadata handler. */
	int (*metadata_handler) (struct lib_context * lc,
				 enum handler_commands command,
				 struct handler_info * info, void *ptr);

	/*
	 * Event handlers (eg, I/O error).
	 */
	struct event_handlers *events;

	/* 
	 * Hot-spare disk search scope 
	 */
	enum scope scope;
	/*
	 * Display RAID disk metadata native.
	 */
	void (*log) (struct lib_context * lc, struct raid_dev * rd);
};

/* Chain of registered format handlers (needed for library context). */
struct format_list {
	struct list_head list;
	struct dmraid_format *fmt;
};

int register_format_handlers(struct lib_context *lc);
extern void unregister_format_handlers(struct lib_context *lc);


/*
 * Format core function used by (all) metadata format handlers.
 */
#define	NO_CHECK_RD	NULL
extern int check_raid_set(struct lib_context *lc, struct raid_set *rs,
			  unsigned int (*f_devices) (struct raid_dev * rd,
						     void *context),
			  void *f_devices_context,
			  int (*f_check) (struct lib_context * lc,
					  struct raid_set * rs,
					  struct raid_dev * rd, void *context),
			  void *f_check_context, const char *handler);
extern int check_valid_format(struct lib_context *lc, char *fmt);
extern int init_raid_set(struct lib_context *lc, struct raid_set *rs,
			 struct raid_dev *rd, unsigned int stride,
			 unsigned int type, const char *handler);
extern const char **get_format_caps(struct lib_context *lc,
				    struct dmraid_format *fmt);
extern void free_format_caps(struct lib_context *lc, const char **caps);

union read_info {
	void *ptr;
	uint32_t u32;
	uint64_t u64;
};

struct raid_dev *read_raid_dev(struct lib_context *lc,
			       struct dev_info *di,
			       void *(*f_read_metadata) (struct lib_context *
							 lc,
							 struct dev_info * di,
							 size_t * size,
							 uint64_t * offset,
							 union read_info *
							 info), size_t size,
			       uint64_t offset, void (*f_to_cpu) (void *meta),
			       int (*f_is_meta) (struct lib_context * lc,
						 struct dev_info * di,
						 void *meta),
			       void (*f_file_metadata) (struct lib_context *
							lc,
							struct dev_info * di,
							void *meta),
			       int (*f_setup_rd) (struct lib_context * lc,
						  struct raid_dev * rd,
						  struct dev_info * di,
						  void *meta,
						  union read_info * info),
			       const char *handler);

extern void *alloc_meta_areas(struct lib_context *lc, struct raid_dev *rd,
			      const char *who, unsigned int n);
extern void *alloc_private(struct lib_context *lc, const char *who,
			   size_t size);
extern void *alloc_private_and_read(struct lib_context *lc, const char *who,
				    size_t size, char *path, loff_t offset);
extern struct raid_set *join_superset(struct lib_context *lc,
				      char *(*f_name) (struct lib_context * lc,
						       struct raid_dev * rd,
						       unsigned int subset),
				      void (*f_create) (struct raid_set *
							super, void *private),
				      int (*f_set_sort) (struct list_head *
							 pos,
							 struct list_head *
							 new),
				      struct raid_set *rs, struct raid_dev *rd);
extern int register_format_handler(struct lib_context *lc,
				   struct dmraid_format *fmt);
extern int write_metadata(struct lib_context *lc, const char *handler,
			  struct raid_dev *rd, int meta_index, int erase);
extern int log_zero_sectors(struct lib_context *lc, char *path,
			    const char *handler);

#define	to_disk	to_cpu

#define struct_offset(s, member) ((size_t) &((struct s *) 0)->member)

/* Print macros used in log methods. */

/* Undefine this to avoid offsets in metadata logging. */
#define	NATIVE_LOG_OFFSET
#ifdef	NATIVE_LOG_OFFSET
#define	P_FMT	"0x%03x "
#define	P_OFF(x, basevar, y...) \
	((unsigned long) &x - (unsigned long) basevar), y
#else
#define	P_FMT
#define	P_OFF(x, basevar, y...)	y
#endif

#define	P(format, basevar, x, y...) \
	do { log_print(lc, P_FMT format, P_OFF(x, basevar, y)); } while(0)

#define	P2(format, basevar, i, x) \
	do { P(format, basevar, x, i, x); } while(0)
#define	DP(format, basevar, x) \
	do { P(format, basevar, x, x); } while(0)

/*
 * RAID device, set and vendor metadata retrieval macros.
 */
#define	DEVS(rs)	(!list_empty(&((struct raid_set *) (rs))->devs))
#define	SETS(rs)	(!list_empty(&((struct raid_set *) (rs))->sets))

#define	META(rd, type)	((struct type*) ((struct raid_dev*) (rd))->meta_areas->area)
#define	RD(pos)		(list_entry(pos, struct raid_dev, devs))
#define	RS(pos)		(list_entry(pos, struct raid_set, list))
#define RD_RS(rs)	(RD((((struct raid_set*) (rs))->devs.next)))
#define RS_RS(rs)	((struct raid_set*) (rs)->sets.next)

#define	HANDLER_LEN	sizeof(HANDLER)

#endif /* ifdef FORMAT_HANDLER */

#endif