]> err.no Git - util-linux/commitdiff
libblkid: add chain structs
authorKarel Zak <kzak@redhat.com>
Tue, 15 Sep 2009 19:12:55 +0000 (21:12 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 16 Sep 2009 08:03:49 +0000 (10:03 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/blkid/src/blkidP.h
shlibs/blkid/src/probe.c

index 9c6578cf4f5b69c10b106c84a485ca4b15238787..2eb9d4eb8c40a273ea311ff14160a3a6488cc915 100644 (file)
@@ -87,42 +87,67 @@ struct blkid_struct_tag
 typedef struct blkid_struct_tag *blkid_tag;
 
 /*
- * Low-level probe result
+ * Chain IDs
  */
-#define BLKID_PROBVAL_BUFSIZ   64
-#define BLKID_PROBVAL_NVALS    8       /* see blkid.h BLKID_PROBREQ_* */
+enum {
+       BLKID_CHAIN_SUBLKS,     /* FS/RAID superblocks (enabled by default) */
+/*     BLKID_CHAIN_TOPLGY,        Block device topology */
+/*     BLKID_CHAIN_PARTS,         Partition tables */
 
-struct blkid_prval
-{
-       const char      *name;                  /* value name */
-       unsigned char   data[BLKID_PROBVAL_BUFSIZ]; /* value data */
-       size_t          len;                    /* length of value data */
+       BLKID_NCHAINS           /* number of chains */
+};
+
+struct blkid_chain {
+       const struct blkid_chaindrv *driver;    /* chain driver */
+
+       int             enabled;        /* boolean */
+       int             flags;          /* BLKID_<chain>_* */
+       int             binary;         /* boolean */
+       int             idx;            /* index of the current prober */
+       unsigned long   *fltr;          /* filter or NULL */
+       void            *data;          /* private chain data or NULL */
 };
 
 /*
- * Low-level probing control struct
+ * Chain driver
  */
-struct blkid_struct_probe
-{
-       int                     fd;             /* device file descriptor */
-       blkid_loff_t            off;            /* begin of data on the device */
-       blkid_loff_t            size;           /* end of data on the device */
+struct blkid_chaindrv {
+       const int       id;             /* BLKID_CHAIN_* */
+       const char      *name;          /* name of chain (for debug purpose) */
+       const int       dflt_flags;     /* default chain flags */
+       const int       dflt_enabled;   /* default enabled boolean */
+       int             has_fltr;       /* boolean */
+
+       const struct blkid_idinfo **idinfos; /* description of probing functions */
+       const size_t    nidinfos;       /* number of idinfos */
+
+       /* driver operations */
+       int             (*probe)(blkid_probe, struct blkid_chain *);
+       int             (*safeprobe)(blkid_probe, struct blkid_chain *);
+       void            (*free_data)(blkid_probe, void *);
+};
 
-       unsigned char           *sbbuf;         /* superblok buffer */
-       size_t                  sbbuf_len;      /* size of data in superblock buffer */
+/*
+ * Low-level probe result
+ */
+#define BLKID_PROBVAL_BUFSIZ   64
 
-       unsigned char           *buf;           /* seek buffer */
-       blkid_loff_t            buf_off;        /* offset of seek buffer */
-       size_t                  buf_len;        /* size of data in seek buffer */
-       size_t                  buf_max;        /* allocated size of seek buffer */
+#define BLKID_NVALS_SUBLKS     10
+#define BLKID_NVALS_TOPLGY     3
+#define BLKID_NVALS_PARTS      1
 
-       struct blkid_prval      vals[BLKID_PROBVAL_NVALS];
-       int                     nvals;
+/* Max number of all values in probing result */
+#define BLKID_NVALS             (BLKID_NVALS_SUBLKS + \
+                                BLKID_NVALS_TOPLGY + \
+                                BLKID_NVALS_PARTS)
 
-       int                     probreq;        /* BLKID_PROBREQ_* flags */
-       int                     idx;            /* index of the last prober */
+struct blkid_prval
+{
+       const char      *name;                  /* value name */
+       unsigned char   data[BLKID_PROBVAL_BUFSIZ]; /* value data */
+       size_t          len;                    /* length of value data */
 
-       unsigned long           *fltr;          /* filter */
+       struct blkid_chain      *chain;         /* owner */
 };
 
 #define BLKID_SB_BUFSIZ                0x11000
@@ -144,7 +169,7 @@ struct blkid_idmag
  */
 struct blkid_idinfo
 {
-       const char      *name;          /* FS/RAID name */
+       const char      *name;          /* fs, raid or partition table name */
        int             usage;          /* BLKID_USAGE_* flag */
        int             flags;          /* BLKID_IDINFO_* flags */
 
@@ -163,6 +188,38 @@ struct blkid_idinfo
  */
 #define BLKID_IDINFO_TOLERANT  (1 << 1)
 
+/*
+ * Low-level probing control struct
+ */
+struct blkid_struct_probe
+{
+       int                     fd;             /* device file descriptor */
+       blkid_loff_t            off;            /* begin of data on the device */
+       blkid_loff_t            size;           /* end of data on the device */
+       dev_t                   devno;          /* device number (st.st_rdev) */
+       unsigned int            blkssz;         /* sector size (BLKSSZGET ioctl) */
+       mode_t                  mode;           /* struct stat.sb_mode */
+
+       unsigned char           *sbbuf;         /* superblok buffer */
+       size_t                  sbbuf_len;      /* size of data in superblock buffer */
+
+       unsigned char           *buf;           /* seek buffer */
+       blkid_loff_t            buf_off;        /* offset of seek buffer */
+       size_t                  buf_len;        /* size of data in seek buffer */
+       size_t                  buf_max;        /* allocated size of seek buffer */
+
+       struct blkid_chain      chains[BLKID_NCHAINS];  /* array of chains */
+       struct blkid_chain      *cur_chain;             /* current chain */
+
+       struct blkid_prval      vals[BLKID_NVALS];      /* results */
+       int                     nvals;          /* number of assigned vals */
+
+       /* obsolete */
+       int                     probreq;        /* BLKID_PROBREQ_* flags */
+       int                     idx;            /* index of the last prober */
+       unsigned long           *fltr;          /* filter */
+};
+
 /*
  * Evaluation methods (for blkid_eval_* API)
  */
index a578366b0586634a4d77422e781a09847191c070..02fa0a861ba62fce9d10850835d9ebe71d75b5b9 100644 (file)
@@ -580,7 +580,7 @@ static struct blkid_prval *blkid_probe_assign_value(
 
        if (!name)
                return NULL;
-       if (pr->nvals >= BLKID_PROBVAL_NVALS)
+       if (pr->nvals >= BLKID_NVALS)
                return NULL;
 
        v = &pr->vals[pr->nvals];