From: ttaylor AT mitre DOT org (Tim Taylor) Subject: B19.1: chdir bug (NT 4.0) 27 Aug 1998 03:50:54 -0700 Message-ID: <3.0.5.32.19980826112252.00b78b30.cygnus.gnu-win32@linus.mitre.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=====================_904159372==_" To: gnu-win32 AT cygnus DOT com --=====================_904159372==_ Content-Type: text/plain; charset="us-ascii" I've found a bug that affects chdir() when trying to change to the root of a self-mounted drives. I've attached an example program that demonstrates the problem. For discussion, consider the following directory structure: //G/ | +-- foo | +-- bar If my example program is run from //G/ with the command chdir_test foo, it will change to the directory foo, and then try to change back to //G/. chdir will return a success result code, but the current directory doesn't get changed. If it is run from //G/foo with the command chdir_test bar, it will change to //G/foo/bar and then change back to /G/foo as expected. I searched the FAQ and mailing list archives, and didn't see any mention of this particular problem. I don't have the sources, so I haven't been able to see if I could identify the cause of the problem. - Tim Taylor - Tim --=====================_904159372==_ Content-Type: text/plain; charset="us-ascii" Content-Disposition: attachment; filename="chdir_test.c" /* * This program tests the chdir function in CygWin32 B19.1. * This function fails to work when invoked with a directory name from a * unmounted drives root. It works fine if invoked for a directory that is a * subdirectory on the same drive. * * Here's the situation: * //G/ * | * +-- foo * | * +-- bar * * When this program is invoked, it will print out the name of the directory * it was invoked from, it will then chdir() to the directory provided on the * command line. Next it will use getcwd() and print out the current * directory. It will then use chdir() again to move back to the directory it * started from, and then use getcwd() to print out the directory that is now * current. * * Using the directory tree shown above, the output will look like: * * Invoked from //G/ with chdir_test foo * ------------------------------------- * Starting directory: //G * chdir(foo) succeeded. * Current dir: //G/foo * chdir(//G) succeeded. * Current dir: //G/foo * **** Error - current dir is not what it should be. * * Invoked from //G/foo with chdir_test bar * ---------------------------------------- * Starting directory: //G/foo * chdir(bar) succeeded. * Current dir: //G/foo/bar * chdir(//G/foo) succeeded. * Current dir: //g/foo * current dir is corrent. * * Author: Tim Taylor (ttaylor AT mitre DOT org) * Date: 26 Aug. 1998 */ #include #include void print_usage(void) { printf("Usage: stat_test dir_name\n\n"); printf(" dir_name should be a directory in the current directory\n"); } int main(int argc, char **argv) { char *dirName, origDir[256], curDir[256]; if(argc < 2) { print_usage(); return; } dirName = argv[1]; getcwd(origDir, sizeof(curDir)); printf("Starting directory: %s\n", origDir); if(chdir(dirName) < 0) { printf("chdir(%s) failed with error code: %d\n", dirName, errno); } else { printf("chdir(%s) succeeded.\n", dirName); } getcwd(curDir, sizeof(curDir)); printf("Current dir: %s\n", curDir); if(chdir(origDir) < 0) { printf("chdir(%s) failed with error code: %d\n", origDir, errno); } else { printf("chdir(%s) succeeded.\n", origDir); } getcwd(curDir, sizeof(curDir)); printf("Current dir: %s\n", curDir); if(strcmp(origDir, curDir)) printf(" **** Error - current dir is not what it should be.\n"); else printf(" current dir is corrent.\n"); } --=====================_904159372==_ Content-Type: text/plain; charset="us-ascii" ====================================================================== Timothy L. Taylor Internet: ttaylor AT mitre DOT org Lead Software Systems Engineer Voice: (781) 271-8770 The Mitre Corporation Fax: (781) 271-7231 202 Burlington Rd. Mail Stop: B295 Bedford, Massachusetts 01730-1420 ====================================================================== --=====================_904159372==_-- - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".