File: ioconf.h

package info (click to toggle)
sysstat 12.7.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 21,156 kB
  • sloc: ansic: 49,310; sh: 1,388; xml: 1,285; makefile: 768; tcl: 756; python: 277; perl: 257
file content (92 lines) | stat: -rw-r--r-- 2,589 bytes parent folder | download | duplicates (3)
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
/*
 * ioconf: ioconf configuration file handling code
 * Original code (C) 2004 by Red Hat (Charlie Bennett <ccb@redhat.com>)
 *
 * Modified and maintained by Sebastien GODARD (sysstat <at> orange.fr)
 */

#ifndef _IOCONF_H
#define _IOCONF_H

#include "inisysconfig.h"

#define IOC_NAMELEN	32
#define IOC_DESCLEN	64
#define IOC_DEVLEN	48
#define IOC_LINESIZ	256
#define IOC_FMTLEN	16
#define IOC_XFMTLEN	(IOC_FMTLEN + IOC_NAMELEN + 3)

#ifndef MINORBITS
#define MINORBITS	20
#endif
#define IOC_MAXMINOR	((1U << MINORBITS) - 1)
#ifndef MAX_BLKDEV
/* #define MAX_BLKDEV	((1U << (32 - MINORBITS)) - 1) */
/* Use a lower value since this value is used to allocate arrays statically in ioconf.c */
#define MAX_BLKDEV	511
#endif

#define K_NODEV	"nodev"

#define IS_WHOLE(maj,min)	((min % ioconf[maj]->blkp->pcount) == 0)

/*
 * When is C going to get templates?
 */
#define IOC_ALLOC(P,TYPE,SIZE)			\
     do {					\
         if (P == NULL) {			\
              P = (TYPE *) malloc(SIZE);	\
              if (P == NULL) {			\
                   perror("malloc");		\
                   ioc_free();			\
                   goto free_and_return;	\
              }					\
         }					\
     }						\
     while (0)
/* That dummy while allows ';' on the line that invokes the macro... */


struct blk_config {
	char name[IOC_NAMELEN];	/* device basename */
	char cfmt[IOC_XFMTLEN];	/* controller format string */
	char dfmt[IOC_FMTLEN];	/* disk format string */
	char pfmt[IOC_FMTLEN + 2];	/* partition format string */
	/* ctrlno is in the ioc_entry */
	unsigned int ctrl_explicit;	/* use "cN" in name */
	unsigned int dcount;		/* number of devices handled by this major */
	unsigned int pcount;		/* partitions per device */
	char desc[IOC_DESCLEN];
	/* disk info unit # conversion function */
	char *(*cconv)(unsigned int);

	/* extension properties (all this for initrd?) */
	char ext_name[IOC_NAMELEN];
	unsigned int ext;		/* flag - this is an extension record */
	unsigned int ext_minor;		/* which minor does this apply to */
};

#define BLK_CONFIG_SIZE	(sizeof(struct blk_config))


struct ioc_entry {
	int live;			/* is this a Direct entry? */
	unsigned int ctrlno;		/* controller number */
	unsigned int basemajor;		/* Major number of the template */
	char *desc;			/* (dynamic) per-controller description */
	struct blk_config *blkp;	/* the real info, may be a shared ref */
};

#define IOC_ENTRY_SIZE	(sizeof(struct ioc_entry))


int ioc_iswhole
	(unsigned int, unsigned int);
char *ioc_name
	(unsigned int, unsigned int);
char *transform_devmapname
	(unsigned int, unsigned int);

#endif