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

rename() fails with trailing slash #1008

Closed
ericeil opened this issue Aug 29, 2016 · 8 comments
Closed

rename() fails with trailing slash #1008

ericeil opened this issue Aug 29, 2016 · 8 comments

Comments

@ericeil
Copy link

ericeil commented Aug 29, 2016

Tested on rs_preview build 14905:

Run the following:

#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>

int main(void)
{
    if (mkdir("dir1", 0777) != 0)
        err(1, "mkdir errno %d", errno);

    if (rename("dir1", "dir2/") != 0)
        err(1, "rename errno %d", errno);

    return 0;
}

On Linux, this succeeds. On Windows, I get the following:

a.out: rename errno 2: No such file or directory

Without the trailing slash, the rename works as expected.

This is causing a few failures in the .NET Core tests.

@sunilmut
Copy link
Member

@ericeil - Thanks for reporting this. I have opened a bug to track this. It should get auto-triaged.

@timmontague
Copy link

timmontague commented Sep 14, 2016

If the oldpath has a trailing slash, Bash On Windows to hangs and the lxssmanager service can not be restarted.

#include <stdlib.h>
int main () {
    return rename ("dir1/", "dir2");
}
tmontague@AMP:/mnt/c/test$ gcc rename.c
tmontague@AMP:/mnt/c/test$ mkdir dir1
tmontague@AMP:/mnt/c/test$ ls -l
total 12
-rwxrwxrwx 1 root root 8522 Sep 13 16:34 a.out
drwxrwxrwx 2 root root    0 Sep 13 16:35 dir1
-rwxrwxrwx 1 root root   70 Sep 13 16:30 rename.c
tmontague@AMP:/mnt/c/test$ ./a.out
^C

Pressing ^c does not do anything, and all open bash terminals are unresponsive.

This only occurs when running from a Windows directory (i.e., it occurs in/mnt/c, but not /).

This bug occurs when running configure on m4 during its "checking whether rename honors trailing slash on source" autoconf test. See GNU m4 installation fails on Windows 10 bash on Ubuntu.

I am using Microsoft Windows [Version 10.0.14393]

@misenesi
Copy link

misenesi commented Nov 10, 2016

Both issues are gone on my latest internal build. The fixes should make its way to insider builds eventually.

@JasonLinMS
Copy link

This issue was fixed in Insider build 14965, please re-open if this issue is seen again.

@bogen
Copy link

bogen commented Jan 24, 2017

On the anniversary build this issue can cause bash to not restart. (At work I can't switch to the insider track).
Rebooting does not fix the problem. Stopping the service (sc stop lxssmanager) then running bash once as administrator does fix it. Sometimes it gets stuck though on the stop and rebooting or shutdown does not correct the issue (due to windows 10 hibernating rather than truly shutting down). In this case I've found that it is necessary to "shutdown /s" to truly shutdown, then booting back up and running bash once as administrator.

@aaewong
Copy link

aaewong commented Feb 19, 2017

Bash was unresponsive for me after a bad mv with trailing slashes. I shutdown with shutdown /s and ran bash as administrator as @bogen suggested and everything works again.

@davidmaxwaterman
Copy link

Is there some way we can get fixed versions more quickly? ref: build 14965

@aseering
Copy link
Contributor

aseering commented Apr 5, 2017

If you want to get fixed versions more quickly, you can sign up for Windows Insider builds. Both the Slow and the Fast Insider rings get WSL updates more frequently than regular (stable) Windows.

Alternatively, this particular fix (as well as a lot of other fixes) is scheduled to ship with the Windows Creators update on April 11, less than a week from now.

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

10 participants