summaryrefslogtreecommitdiff
path: root/lib/backend
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-10-20 10:52:53 +0300
committerPanu Matilainen <pmatilai@redhat.com>2010-10-20 10:53:28 +0300
commit3714d9e22382b4db528ea97abc3d948f905d43df (patch)
tree6e03a8e98f71a798f264bd30a370d37107b0bec2 /lib/backend
parenta43ea6c54dd059e1a7eef8365d0674799f574764 (diff)
downloadlibrpm-tizen-3714d9e22382b4db528ea97abc3d948f905d43df.tar.gz
librpm-tizen-3714d9e22382b4db528ea97abc3d948f905d43df.tar.bz2
librpm-tizen-3714d9e22382b4db528ea97abc3d948f905d43df.zip
Add a backend-independent flags + getter for dbis
- Keeping up pretense of being backend independent where its easy to do... and rdonly+created status are rather obviously universally mappable
Diffstat (limited to 'lib/backend')
-rw-r--r--lib/backend/db3.c15
-rw-r--r--lib/backend/dbi.h13
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/backend/db3.c b/lib/backend/db3.c
index 47763ac4f..6cad9e8ec 100644
--- a/lib/backend/db3.c
+++ b/lib/backend/db3.c
@@ -366,6 +366,21 @@ dbiIndexType dbiType(dbiIndex dbi)
return dbi->dbi_type;
}
+int dbiFlags(dbiIndex dbi)
+{
+ DB *db = dbi->dbi_db;
+ int flags = DBI_NONE;
+ uint32_t oflags = 0;
+
+ if (db && db->get_open_flags(db, &oflags) == 0) {
+ if (oflags & DB_CREATE)
+ flags |= DBI_CREATED;
+ if (oflags & DB_RDONLY)
+ flags |= DBI_RDONLY;
+ }
+ return flags;
+}
+
int dbiVerify(dbiIndex dbi, unsigned int flags)
{
int rc = 0;
diff --git a/lib/backend/dbi.h b/lib/backend/dbi.h
index 63233a8b8..4da145588 100644
--- a/lib/backend/dbi.h
+++ b/lib/backend/dbi.h
@@ -54,6 +54,12 @@ typedef enum dbiIndexType_e {
DBI_SECONDARY = (2 * sizeof(int32_t)),
} dbiIndexType;
+enum dbiFlags_e {
+ DBI_NONE = 0,
+ DBI_CREATED = (1 << 0),
+ DBI_RDONLY = (1 << 1),
+};
+
/** \ingroup dbi
* Describes an index database (implemented on Berkeley db functionality).
*/
@@ -231,6 +237,13 @@ int dbiByteSwapped(dbiIndex dbi);
RPM_GNUC_INTERNAL
dbiIndexType dbiType(dbiIndex dbi);
+/** \ingroup dbi
+ * Retrieve index control flags (new/existing, read-only etc)
+ * @param dbi index database handle
+ * @return dbi control flags
+ */
+RPM_GNUC_INTERNAL
+int dbiFlags(dbiIndex dbi);
#ifdef __cplusplus
}
#endif