aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2023-05-04 09:55:26 +0000
committerWerner Koch <[email protected]>2023-05-04 09:55:26 +0000
commit0f0ab044356dce6965e3f6cb02b0fc24d64dd432 (patch)
tree387196a337e976784d07d6d9398386070398f501
parentkbx: Improve keybox_set_flags (diff)
downloadgnupg-0f0ab044356dce6965e3f6cb02b0fc24d64dd432.tar.gz
gnupg-0f0ab044356dce6965e3f6cb02b0fc24d64dd432.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 fd37ee5b3..dbdd5832d 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 ();
@@ -539,7 +539,7 @@ keybox_set_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int value)
if (!hd->fp || !hd->update_mode)
{
_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 ();
hd->update_mode = 1;
@@ -615,7 +615,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 ();
@@ -670,7 +670,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;