Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetFinalPathNameByHandle fails with ERROR_FILE_NOT_FOUND #130

Closed
rustyx opened this issue Jul 22, 2019 · 11 comments
Closed

GetFinalPathNameByHandle fails with ERROR_FILE_NOT_FOUND #130

rustyx opened this issue Jul 22, 2019 · 11 comments

Comments

@rustyx
Copy link

rustyx commented Jul 22, 2019

Environment

  • Windows version: Windows 10 Pro 1903, build 18362.239.
  • Processor architecture: x64
  • Encfs4win version: v1.10.1
  • Dokan version (legacy, modern): Dokany v1.2.2.1000

Description

For some reason Git isn't working with a repo mounted via encfs4win (I remember it did before, but don't know what/where changed).

I traced the issue down to the call to GetFinalPathNameByHandle which on my system fails with error 2, ERROR_FILE_NOT_FOUND.

Here's a test program to reproduce the issue.

#include <stdio.h>
#include <Windows.h>

int main(int argc, char**argv) {
    char buf[512];
    if (argc < 2) {
        fprintf(stderr, "Usage: %s <some path>\n", argv[0]);
        return 1;
    }
    HANDLE hnd = CreateFileA(
        argv[1], 0,
        FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
        NULL, OPEN_EXISTING, 0, NULL);
    if (hnd == INVALID_HANDLE_VALUE) {
        fprintf(stderr, "CreateFile(%s) failed, LastError %d\n", argv[1], GetLastError());
        return 1;
    }
    if (!GetFinalPathNameByHandleA(hnd, buf, sizeof(buf), 0)) {
        fprintf(stderr, "GetFinalPathNameByHandle(%s) failed, LastError %d\n", argv[1], GetLastError());
        return 1;
    }
    printf("OK: %s\n", buf);
}

It works for any path outside encfs4win and fail for any path inside encfs4win.
Any idea how to debug this further?

Also tried with Dokan 0.7.4, same issue.

@rustyx
Copy link
Author

rustyx commented Jul 23, 2019

Just to add to this, I got it working again by disabling symlinks in Git settings and removing the MSYS environment variable (when MSYS=winsymlinks:nativestrict, symlinks are enabled again).

Nevertheless,it seems GetFinalPathNameByHandle never worked, and it would be nice to have it working finally.

@jetwhiz
Copy link
Owner

jetwhiz commented Jul 27, 2019

Are you running this inside Cygwin/MSYS, or natively in Windows?

@jetwhiz
Copy link
Owner

jetwhiz commented Jul 28, 2019

If I'm understanding your issue correctly, I expect this is related to the known upstream issue in Dokany, since it does not support symlinks: dokan-dev/dokany#343

@rustyx
Copy link
Author

rustyx commented Jul 28, 2019

I'm running natively and there are no symlinks in the picture; GetFinalPathNameByHandle simply always fails for any file on the encrypted drive.
Although the issue is probably in dokan code, I just don't know how to diagnose it.

@jetwhiz
Copy link
Owner

jetwhiz commented Jul 31, 2019

You can get Dokany to output debug information (though it is very verbose) by using:

encfs.exe path mountpoint -- -d

This might help to figure out what Dokany is doing and why that call is failing.

@stale
Copy link

stale bot commented Sep 29, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 29, 2019
@rustyx
Copy link
Author

rustyx commented Sep 29, 2019

There isn't much to see in the encfs -d output unfortunately. Here's what I get:

###Create 0009
   CreateDisposition 0x00000001
CreateFile : \test.git
	AccessMode: SYNCHRONIZE|FILE_READ_ATTRIBUTES
	ShareMode: FILE_SHARE_DELETE|FILE_SHARE_WRITE|FILE_SHARE_READ
	Disposition: OPEN_EXISTING (3)
	Flags: 0 (0x0)
CreateFile status = 0
###Cleanup 0009
Cleanup: \test.git

At the same time the output from the test program is:
GetFinalPathNameByHandle(Z:\test.git): The system cannot find the file specified.

How to debug this further?

@stale stale bot removed the wontfix label Sep 29, 2019
@stale
Copy link

stale bot commented Nov 28, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 28, 2019
@rustyx
Copy link
Author

rustyx commented Nov 28, 2019

Bump.

@stale stale bot removed the wontfix label Nov 28, 2019
@jetwhiz
Copy link
Owner

jetwhiz commented Jan 7, 2020

Did you say this worked after you disabled symlinks in Git? Or does it not work even in that case? encfs4win cannot handle symbolic links if that is the case.

@stale
Copy link

stale bot commented Mar 7, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Mar 7, 2020
@stale stale bot closed this as completed Mar 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants