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

jnr.posix.POSIX.fstat(int, FileStat) fails on Windows #95

Open
jfrantzius opened this issue Jan 4, 2017 · 0 comments
Open

jnr.posix.POSIX.fstat(int, FileStat) fails on Windows #95

jfrantzius opened this issue Jan 4, 2017 · 0 comments

Comments

@jfrantzius
Copy link

The following test unfortunately fails on Windows:

    @Test
    public void filestatDescriptor2() throws Throwable {
        File f = File.createTempFile("stat", null);

        try {
            int fd = posix.open(f.getAbsolutePath(), 0, 438);
            FileStat stat = posix.allocateStat();
            int result = posix.fstat(fd, stat);
            assertEquals(0, result);
            assertEquals(0, stat.st_size());
        } finally {
            f.delete();
        }

    }

With the following exception:

java.lang.IllegalArgumentException: instance of class jnr.posix.WindowsRawFileStat is not a struct
	at jnr.posix.BaseNativePOSIX$2.toNative(BaseNativePOSIX.java:746)
	at jnr.posix.BaseNativePOSIX$2.toNative(BaseNativePOSIX.java:1)
	at jnr.posix.WindowsLibC$jnr$ffi$0.fstat(Unknown Source)
	at jnr.posix.BaseNativePOSIX.fstat(BaseNativePOSIX.java:136)
	at jnr.posix.CheckedPOSIX.fstat(CheckedPOSIX.java:129)
	at jnr.posix.LazyPOSIX.fstat(LazyPOSIX.java:126)
[..]

The call to jnr.posix.POSIX.fstat(int, FileStat) currently isn't covered in jnr.posix.FileStatTest, which is why this (likely) bug may have gone unnoticed yet.

jfrantzius pushed a commit to ibmix-berlin/jnr-posix that referenced this issue Jan 6, 2017
Unfortunately, behaviour is undefined if given fd is not valid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant