]> granicus.if.org Git - sysstat/blob - ioconf.h
Add support for major numbers > 255
[sysstat] / ioconf.h
1 /*
2  * ioconf: ioconf configuration file handling code
3  * Original code (C) 2004 by Red Hat (Charlie Bennett <ccb@redhat.com>)
4  *
5  * Modified and maintained by Sebastien GODARD (sysstat <at> orange.fr)
6  */
7
8 #ifndef _IOCONF_H
9 #define _IOCONF_H
10
11 #include "sysconfig.h"
12
13 #define IOC_NAMELEN     31
14 #define IOC_DESCLEN     63
15 #define IOC_DEVLEN      47
16 #define IOC_LINESIZ     255
17 #define IOC_FMTLEN      15
18
19 #ifndef MINORBITS
20 #define MINORBITS       20
21 #endif
22 #define IOC_MAXMINOR    ((1U << MINORBITS) - 1)
23 #ifndef MAX_BLKDEV
24 /* #define MAX_BLKDEV   ((1U << (32 - MINORBITS)) - 1) */
25 /* Use a lower value since this value is used to allocate arrays statically in ioconf.c */
26 #define MAX_BLKDEV      511
27 #endif
28
29 #define K_NODEV "nodev"
30
31 #define IS_WHOLE(maj,min)       ((min % ioconf[maj]->blkp->pcount) == 0)
32
33 /*
34  * When is C going to get templates?
35  */
36 #define IOC_ALLOC(P,TYPE,SIZE)                  \
37      do {                                       \
38          if (P == NULL) {                       \
39               P = (TYPE *) malloc(SIZE);        \
40               if (P == NULL) {                  \
41                    perror("malloc");            \
42                    ioc_free();                  \
43                    goto free_and_return;        \
44               }                                 \
45          }                                      \
46      }                                          \
47      while (0)
48 /* That dummy while allows ';' on the line that invokes the macro... */
49
50
51 struct blk_config {
52         char name[IOC_NAMELEN + 1];     /* device basename */
53         char cfmt[IOC_FMTLEN + 1];      /* controller format string */
54         char dfmt[IOC_FMTLEN + 1];      /* disk format string */
55         char pfmt[IOC_FMTLEN + 1];      /* partition format string */
56         /* ctrlno is in the ioc_entry */
57         unsigned int ctrl_explicit;     /* use "cN" in name */
58         unsigned int dcount;            /* number of devices handled by this major */
59         unsigned int pcount;            /* partitions per device */
60         char desc[IOC_DESCLEN + 1];
61         /* disk info unit # conversion function */
62         char *(*cconv)(unsigned int);
63
64         /* extension properties (all this for initrd?) */
65         char ext_name[IOC_NAMELEN + 1];
66         unsigned int ext;               /* flag - this is an extension record */
67         unsigned int ext_minor;         /* which minor does this apply to */
68 };
69
70 #define BLK_CONFIG_SIZE (sizeof(struct blk_config))
71
72
73 struct ioc_entry {
74         int live;                       /* is this a Direct entry? */
75         unsigned int ctrlno;            /* controller number */
76         unsigned int basemajor;         /* Major number of the template */
77         char *desc;                     /* (dynamic) per-controller description */
78         struct blk_config *blkp;        /* the real info, may be a shared ref */
79 };
80
81 #define IOC_ENTRY_SIZE  (sizeof(struct ioc_entry))
82
83
84 int ioc_iswhole
85         (unsigned int, unsigned int);
86 char *ioc_name
87         (unsigned int, unsigned int);
88 char *transform_devmapname
89         (unsigned int, unsigned int);
90
91 #endif