mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
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.
This commit is contained in:
parent
30f1eda7d8
commit
0f0ab04435
@ -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 ();
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user