summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2023-05-04 11:55:26 +0200
committerWerner Koch <wk@gnupg.org>2023-05-04 14:37:48 +0200
commita7dbf11954873c6c58a36b57028ced4ecd45bdc6 (patch)
treed24ae94b8a122285290ed31273e62fa7e4d78b68
parentgpgsm: Cache the non-existence of the policy file. (diff)
downloadgnupg2-a7dbf11954873c6c58a36b57028ced4ecd45bdc6.tar.xz
gnupg2-a7dbf11954873c6c58a36b57028ced4ecd45bdc6.zip
kbx: Add extra flags to fopen for use by Windows.
* kbx/keybox-search.c (open_file): Use sysopen and sequential. * kbx/keybox-update.c (create_tmp_file): Ditto. (blob_filecopy): Ditto. (keybox_set_flags): Ditto. (keybox_delete): Ditto. (keybox_compress): Ditto. -- Under Windows "sysopen" requests that direct API calls (CreateFile et al.) are used instead of the libc wrappers. This may or may not improve the performance. Using "sequential" is a hint to Windows to assume that a file is in general access in a sequential manner. This will have an affect only with a future libgpg-error.
-rw-r--r--kbx/keybox-search.c2
-rw-r--r--kbx/keybox-update.c12
-rw-r--r--sm/keydb.c2
3 files changed, 8 insertions, 8 deletions
diff --git a/kbx/keybox-search.c b/kbx/keybox-search.c
index 8dea7cb8e..7645fba4f 100644
--- a/kbx/keybox-search.c
+++ b/kbx/keybox-search.c
@@ -878,7 +878,7 @@ static gpg_error_t
open_file (KEYBOX_HANDLE hd)
{
- hd->fp = es_fopen (hd->kb->fname, "rb");
+ hd->fp = es_fopen (hd->kb->fname, "rb,sysopen,sequential");
if (!hd->fp)
{
hd->error = gpg_error_from_syserror ();
diff --git a/kbx/keybox-update.c b/kbx/keybox-update.c
index 273265635..eab961a3e 100644
--- a/kbx/keybox-update.c
+++ b/kbx/keybox-update.c
@@ -78,7 +78,7 @@ create_tmp_file (const char *template,
err = keybox_tmp_names (template, 0, r_bakfname, r_tmpfname);
if (!err)
{
- *r_fp = es_fopen (*r_tmpfname, "wb");
+ *r_fp = es_fopen (*r_tmpfname, "wb,sysopen,sequential");
if (!*r_fp)
{
err = gpg_error_from_syserror ();
@@ -174,12 +174,12 @@ blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
if ((ec = gnupg_access (fname, W_OK)))
return gpg_error (ec);
- fp = es_fopen (fname, "rb");
+ fp = es_fopen (fname, "rb,sysopen,sequential");
if (mode == FILECOPY_INSERT && !fp && errno == ENOENT)
{
/* Insert mode but file does not exist:
Create a new keybox file. */
- newfp = es_fopen (fname, "wb");
+ newfp = es_fopen (fname, "wb,sysopen,sequential");
if (!newfp )
return gpg_error_from_syserror ();
@@ -536,7 +536,7 @@ keybox_set_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int value)
off += flag_pos;
_keybox_close_file (hd);
- fp = es_fopen (hd->kb->fname, "r+b");
+ fp = es_fopen (hd->kb->fname, "r+b,sysopen,sequential");
if (!fp)
return gpg_error_from_syserror ();
@@ -601,7 +601,7 @@ keybox_delete (KEYBOX_HANDLE hd)
off += 4;
_keybox_close_file (hd);
- fp = es_fopen (hd->kb->fname, "r+b");
+ fp = es_fopen (hd->kb->fname, "r+b,sysopen,sequential");
if (!fp)
return gpg_error_from_syserror ();
@@ -656,7 +656,7 @@ keybox_compress (KEYBOX_HANDLE hd)
if ((ec = gnupg_access (fname, W_OK)))
return gpg_error (ec);
- fp = es_fopen (fname, "rb");
+ fp = es_fopen (fname, "rb,sysopen,sequential");
if (!fp && errno == ENOENT)
return 0; /* Ready. File has been deleted right after the access above. */
if (!fp)
diff --git a/sm/keydb.c b/sm/keydb.c
index a12dba19f..38737c96a 100644
--- a/sm/keydb.c
+++ b/sm/keydb.c
@@ -693,7 +693,7 @@ keydb_release (KEYDB_HANDLE hd)
switch (hd->active[i].type)
{
case KEYDB_RESOURCE_TYPE_NONE:
- break;
+ break;
case KEYDB_RESOURCE_TYPE_KEYBOX:
keybox_release (hd->active[i].u.kr);
break;