[File] [PATCH] of Magdir/sql SQLite 2.x database+ mime type + extensions

Jörg Jenderek joerg.jen.der.ek at gmx.net
Tue Apr 25 21:46:55 UTC 2023


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

some days ago i send patch for SQLite 3.x database. That concerns
version 3 of this database type, but there exist also older variants.
When running file command (version 5.44) on such older databases and
test examples i get an output like:
FileAttributesStore.db: SQLite 2.x database
TextCache.db:           SQLite 2.x database
test-sqlite2.sqlite:    SQLite 2.x database
test.sqlite2:           SQLite 2.x database

At first glance this does not look bad, but when running with
- --extension option i get output like:
FileAttributesStore.db: ???
TextCache.db:           ???
test-sqlite2.sqlite:    ???
test.sqlite2:           ???

When running with -i option i get output like:
FileAttributesStore.db: application/octet-stream; charset=binary
TextCache.db:           application/octet-stream; charset=binary
test-sqlite2.sqlite:    application/octet-stream; charset=binary
test.sqlite2:           application/octet-stream; charset=binary

For comparison reason i run the file format identification utility
TrID ( See https://mark0.net/soft-trid-e.html). The examples are here
described with as "SQLite 2.x database" with mime type
application/x-sqlite2 and 2 suffix (sqlite2 sqlite) by
sqlite-2x.trid.xml (See appended trid-v-sqlite2.txt.gz).

For comparison reason i also run the file format identification
utility DROID ( See https://sourceforge.net/projects/droid/). Here
the samples are also recognized and are described generic as "SQLite
Database File Format" with version "2" and without mime type by PUID
fmt/1135. Only the sqlite and db name suffix are considered here as
valid, whereas the sqlite2 suffix is considered here as "bad" (see
true EXTENSION_MISMATCH in appended droid-sqlite2.csv.gz).

TrID list the used file name extension and often with -v option the
related URL pointing to some information. So i found here again page
about SQLite on Wikipedia and file formats archive team web site.
This is now expressed by additional comment lines inside Magdir/sql
like:
# Reference:	http://mark0.net/download/triddefs_xml.7z
#		defs/s/sqlite-2x.trid.xml

The description of SQLite 2.x database happens inside Magdir/sql by
line like:
0 string **\ This\ file\ contains\ an\ SQLite  SQLite 2.x database

According to DROID and TrID definition mime type and file names
extensions now also shown. So this now becomes like:
0 string **\ This\ file\ contains\ an\ SQLite  SQLite 2.x database
!:mime	application/x-sqlite2
!:ext	sqlite/sqlite2/db

After applying the above mentioned modifications by patch
file-5.44-sql-sqlite2.diff then i get a more precise output.

With additional --extension option now i get:
FileAttributesStore.db: sqlite/sqlite2/db
TextCache.db:           sqlite/sqlite2/db
test-sqlite2.sqlite:    sqlite/sqlite2/db
test.sqlite2:           sqlite/sqlite2/db

With additional -i option now i get:
FileAttributesStore.db: application/x-sqlite2; charset=binary
TextCache.db:           application/x-sqlite2; charset=binary
test-sqlite2.sqlite:    application/x-sqlite2; charset=binary
test.sqlite2:           application/x-sqlite2; charset=binary

I hope my diff file can be applied in future version of
file utility.

There are also mentioned are more older variants. According to
comments inside Magdir/sql Version 1 used GDBM internally and  its
files cannot be distinguished. I had difficulties to get version 2
samples so i do not try this for version 1. So maybe other users may
have such very old examples and check such samples.

With best wishes
Jörg Jenderek
- --
Jörg Jenderek
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iF0EARECAB0WIQS5/qNWKD4ASGOJGL+v8rHJQhrU1gUCZEhKTwAKCRCv8rHJQhrU
1tjrAJ9+T+OvCYCUDdzQVDUdJ3fgFZxjKwCgrLvRbdv57C4IXsu/tSOifVVsWFo=
=YhHL
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: droid-sqlite2.csv.gz
Type: application/x-gzip
Size: 372 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20230425/a9de4364/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: trid-v-sqlite2.txt.gz
Type: application/x-gzip
Size: 462 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20230425/a9de4364/attachment-0001.bin>
-------------- next part --------------
--- file-5.44/magic/Magdir/sql.old	2022-08-16 15:01:06.000000000 +0200
+++ file-5.44/magic/Magdir/sql	2023-04-25 23:41:02.467752600 +0200
@@ -89,6 +89,12 @@
 # from other GDBM files.
 #
+# Update:	Joerg Jenderek
+# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/s/sqlite-2x.trid.xml
+# Note:		called "SQLite 2.x database" by TrID and "SQLite Database File Format" version 2 by DROID via PUID fmt/1135
 # Version 2 used this format:
 0	string	**\ This\ file\ contains\ an\ SQLite  SQLite 2.x database
+!:mime	application/x-sqlite2
+# FileAttributesStore.db test.sqlite2
+!:ext	sqlite/sqlite2/db
 
 # URL:		https://en.wikipedia.org/wiki/SQLite
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.44-sql-sqlite2.diff.sig
Type: application/octet-stream
Size: 589 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20230425/a9de4364/attachment.obj>


More information about the File mailing list