How do you make Windows 7 fully case-sensitive with respect to the filesystem?

2,552

Solution 1

You can set the HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\kernel\ dword:ObCaseInsensitive registry value to 0 as other authors suggested. Create a file named add.reg with the following content and run it.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel]
"obcaseinsensitive"=dword:00000000

Then use Cygwin to work with case-sensitive filenames.

In order to do so, you need to mount NTFS filesystems with posix=1 option in your /etc/fstab, as this article suggests. Here's a snippet from my fstab:

none                    /cygdrive       cygdrive        binary,posix=1,user             0 0
C:                      /cygdrive/c     ntfs            binary,posix=1,user,auto        0 0
C:/Users                /home           ntfs            binary,posix=1,user,auto        0 0

Once the above is done, you'll be able to deal with case-sensitive filenames using bash, mc, git etc.

Solution 2

All these settings that you can find on the web are for NFS not for NTFS (note the difference)!

NFS (Network File System) is a network protocol.

Thus changing the registry key HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\kernel\obcaseinsensitive WILL NOT change anything you want.

NTFS is case-sensitive but Windows API is NOT, it only remembers the filename case. This mean that despite your file is displayed as AbC.TXT it is still accessible by abc.txt and aBc.TxT. This is a limitation of Windows, not NTFS.

The other one HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\DontPrettyPath basically turns off the normalization of legacy 8.3 filenames used by DOS (which are all caps). When it is turned on (default) ABC.TXT will be displayed as Abc.txt, but still be accessible by all other variations.

To be more accurate:

Actually it depends of the software that accesses the FS.

If it uses WIN32 API (which 99.9% of the software does) it will be case-insensitive whatever you do. All built-in software in Windows (like Explorer, command prompt, Internet Explorer and etc.) and all consumer software out there uses WIN32 and is always case-insensitive.

NFS Service, Java and some others are POSIX and they will obey the 'obcaseinsensitive' registry setting. However turning off the option might actually get you bigger problems, because this software can create files that are not accesible from Windows itself and other Win32 software.

Solution 3

In order to actually create 2 files with the same name but different case in the same directory, you need to install Unix Services 3.5 but this only works on 32 bit Windows. Then you need to run "C Shell" to create the files. You can't create the files through explorer. Once created, explorer doesn't play nice with the files. If you go to rename the second one, the cursor jumps to the first one. Also, most applications can only open one of the files, as they expect a case-insensitive file system. If you are on 64 bit install Cygwin and change it to case sensitive.

I was trying to emulate a Linux case-sensitive file-system for debugging purposes during development. It seems the better approach is to use VMWare with an instance of Ubuntu for development.

Solution 4

I think this is what you're looking for:

http://www.chilkatsoft.com/p/p_454.asp

This page recommends setting HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\kernel\ dword:ObCaseInsensitive to 0 to make it case-sensitive. I think you found this already though, and this looks like the standard way to do it (even the Microsoft KB you found suggests it).

It looks like you have to change kernel settings. Beware of updates though.

EDIT: Watch out though, some programs might depend on case insensitivity.

EDIT: You could probably use a UDF partition. This filesystem is case-sensitive and I think it works on both Windows and Linux.

See this and this.

Solution 5

What Microsoft has to say about NTFS and changing case sensitivity.

Looks like you do not have to change the kernel to allow case sensitive lookups on the network.

http://technet.microsoft.com/en-us/library/cc783185(WS.10).aspx

.

Configuring case sensitivity for file and folder names

Applies To: Windows Server 2003 R2

To configure case sensitivity for file and folder names using the Windows interface Open Microsoft Services for Network File System: click Start, point to Programs, point to Administrative Tools, and then click Microsoft Services for Network File System.

If necessary, connect to the computer you want to manage.

Right-click Server for NFS, and then click Properties.

Click the Filename Handling tab.

Do one of the following:

To enable case-sensitive file and directory name lookups, select the Enable case sensitive lookups check box.

To disable case-sensitive file and directory name lookups, clear the Enable case sensitive lookups check box.

Click Apply.

Important These changes will not take effect until Server for NFS is restarted. For information about how to stop and start Server for NFS, see Starting and stopping Server for NFS. You also need to disable Windows kernel case-insensitivity in order for Server for NFS to support case-sensitive file names. You can disable Windows kernel case-insensitivity by clearing the following registry key to 0: HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\kernel DWORD “obcaseinsensitive”

To configure case sensitivity for file and folder names using the command line Open the command prompt.

To enable case sensitivity, type the following:

nfsadmin server [ ComputerName ] config casesensitivelookups=yes

To disable case sensitivity and optionally specify the case of file names returned by Server for NFS, at a command prompt, type the following:

nfsadmin server [ ComputerName ] config casesensitivelookups=no [ntfscase={upper | lower | preserve}]

Argument > Computer Name = The name of the computer you want to configure.

Important These changes will not take effect until Server for NFS is restarted. For information about how to stop and start Server for NFS, see Starting and stopping Server for NFS.

Note The ntfscase option sets the case sensitivity for the NTFS file system. The default case sensitivity is preserve (preserve case). To view the complete syntax for this command, at a command prompt, type: nfsadmin server /?

.

Share:
2,552

Related videos on Youtube

ANIME4154142
Author by

ANIME4154142

Updated on September 18, 2022

Comments

  • ANIME4154142
    ANIME4154142 almost 2 years

    My teacher gave us a practice assignment for studying in my Operating Systems class. The assignment was to pipe three processes together and implement the commands in the title all at once. We are only allowed to use these commands when implementing it:

    dup2()
    one of the exec()
    fork()
    pipe()
    close()
    

    I can pipe two together but I don't know how to do three. Could someone either show me how to do it or at least point me in the right direction?

    Here is my code so far:

    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    
    int main() {
            int pfd[2];
            int pfdb[2];
            int pid;
    
            if (pipe(pfd) == -1) {
                    perror("pipe failed");
                    exit(-1);
            }
            if ((pid = fork()) < 0) {
                    perror("fork failed");
                    exit(-2);
            }
            if (pid == 0) {
                    close(pfd[1]);
                    dup2(pfd[0], 0);
                    close(pfd[0]);
                    execlp("ps", "ps", "-ef", (char *) 0);
                    perror("ps failed");
                    exit(-3);
            } 
            else {
                    close(pfd[0]);
                    dup2(pfd[1], 1);
                    close(pfd[1]);
                    execlp("grep", "grep", "darrowr", (char *) 0);
                    perror("grep failed");
                    exit(-4);
            }
            exit(0);
    
    }
    

    Any help would be appreciated. Heck a tutorial on how to complete it would be wondrous!

    • The Paramagnetic Croissant
      The Paramagnetic Croissant over 9 years
      in order to replicate the semantics, you don't have to pipe anything. (You could do system("ps -ef | grep USERID | wc") as well.. Since this is simple text search, you could just read the process table and count the occurrences of the user ID.
    • The Paramagnetic Croissant
      The Paramagnetic Croissant over 9 years
      @JonathanLeffler well, exec() is there, so... (my advice wasn't using system(), just read the second part of my comment.)
    • Jonathan Leffler
      Jonathan Leffler over 9 years
      I don't think the proposed duplicate is a sufficiently good duplicate; it is dealing with a deadlock problem because of lack of closes, rather than 'how to do the job at all'. The solution is just about sufficient for the pipeline in the question; it is not as complete as it should be for general use.
    • pilcrow
      pilcrow over 9 years
      @JonathanLeffler, perhaps so. It seems to me this general question — How do I implement a shell-like pipeline of 3+ processes in C/C++ — has been asked and answered many times here.
    • Jonathan Leffler
      Jonathan Leffler over 9 years
      Dammit; I don't like SO removing my carefully written comments! @pilcrow — I said, before SO removed it, something along the lines of: I agree that there are probably other questions which cover this situation. I like the answer to the second question linked in your second comment as a duplicate (Connecting n processes with pipes in a shell?; that makes a good duplicate. Thank you for doing the researching.
  • ChrisF
    ChrisF about 13 years
    Can you post more information from the page you link to please. Don't copy the whole thing but you can copy the relevant paragraph and summarise the rest.
  • Mateusz Jamrocki
    Mateusz Jamrocki about 13 years
    Well, the whole page only is a paragraph. I'll make a quick edit though.
  • Breno Macena
    Breno Macena about 13 years
    Thanks tjameson. Regarding programs that might depend on case insensitivity, this is indeed a big problem. A program might look for "WINDOWS" and not find it because it is really "Windows" now, right? Shoot, I'm at a loss trying to figure out how to copy things over from Linux to Windows, and I've found myself in a situation where folders of the same spelling with different caps exist in one location.
  • Mateusz Jamrocki
    Mateusz Jamrocki about 13 years
    Well, the only thing I can think of is to conflicts manually. If you copy files over, Windows should ask you if you want to merge or make a copy or something. I can't remember (I'm a linux man myself).
  • harrymc
    harrymc about 13 years
    According to this article this only works for non-Win32 subsystems, so doesn't apply to NTFS.
  • Mateusz Jamrocki
    Mateusz Jamrocki about 13 years
    I added an option for UDF. This will circumvent the problem.
  • Moab
    Moab about 13 years
    You are also correct that it presents a security issue if you do. "For example, a version of edit.exe infected with a Trojan horse-type malicious program, and named EDIT.EXE, could be stored in the same directory as edit.exe. If a user were to type edit at a Windows command prompt, the Trojan horse version (EDIT.EXE) could be executed instead of the standard version"..technet.microsoft.com/en-us/library/cc732389.aspx
  • harrymc
    harrymc about 13 years
    The question was for NTFS.
  • Mateusz Jamrocki
    Mateusz Jamrocki about 13 years
    @harrymc Yeah, I understand that, but I left it as an option. My answer says how to do it in NTFS, but using a separate UDF partition may also be a viable solution...
  • Mateusz Jamrocki
    Mateusz Jamrocki about 13 years
    It probably won't crash Windows unless you rename key files/folders. I'm pretty sure that Windows makes sure to use the correct case, in fact, they even recommend it.
  • Moab
    Moab about 13 years
    Then he will have to do the registry hack.
  • Breno Macena
    Breno Macena over 12 years
    Hmm, that's interesting tjameson. Can you provide a link to that recommendation?
  • Breno Macena
    Breno Macena over 12 years
    Thanks for those EDITS tjameson. That stuff about UDF is interesting. I wonder if any apps that encounter problem with case-sensitivity turned on will also face the same problem in Windows with UDF?
  • Rhys
    Rhys about 12 years
    @tjameson have you ever loaded Safe mode and watched the files? Defiantly not proper case for all of them.
  • Rhys
    Rhys about 12 years
    Actually, on a FS level before additional processing it IS case sensitive, however, NTFS translates all file names to all uppercase and when one with lowercase characters is entered translates it to uppercase then looks for said file.(see support.microsoft.com/kb/103657)
  • venimus
    venimus about 12 years
    You are right. I just tried to explain it simpler.
  • kreemoweet
    kreemoweet about 12 years
    The Registry is chock-full of references to system files with wildly inconsistent case usage. Case-sensitivity would cause massive breakage.
  • Behrouz.M
    Behrouz.M about 10 years
    Applies To: Windows Server 2008 R2
  • niutech
    niutech about 10 years
    According to Microsoft, "Filenames are Case Sensitive on NTFS Volumes"
  • harrymc
    harrymc about 10 years
    @niutech: This article is about Windows NT 3.1, and only says that an application can use case insensitivity. Of course nobody uses it, except as Microsoft did - in POSIX compliance tests.
  • Ira Baxter
    Ira Baxter over 9 years
    So how does a Win32 based version of java succeed in finding "SHORT.class" vs. "Short.class" if they are in the same directory? I cannot believe there is NO call to do this.
  • venimus
    venimus over 9 years
    I think because Java is POSIX
  • ANIME4154142
    ANIME4154142 over 9 years
    The thing is I don't know what I need to write for the third part. Like what should I add to the code to make wc work. And what should I add to the code to make the second pipe. And how do I make the second fork? Can you choose whichever one of these questions you think is important and show me the actual code?
  • ANIME4154142
    ANIME4154142 over 9 years
    at the very least can you show me where I need to put the third command code? and what I need to write it as like do I make it and else statement or if?
  • ANIME4154142
    ANIME4154142 over 9 years
    Thank you very much. I really appreciate it. In fact I'm learning alot. Would the program work though if I took out the stuff after NOTREACHED?
  • Jonathan Leffler
    Jonathan Leffler over 9 years
    The close brace after /*NOTREACHED*/ is the end of the main() function; you'll need that. The headers and code after that implement the err_syserr() function used liberally in the main() function. If you remove it from there, you'll have to either change the calls in the main() function or provide it somewhere else. If you like, you can consider the function as a cover for perror() plus exit(); you could rewrite it as: void err_syserr(const char *msg, int status) { perror(msg); exit(status); } and you could modify the calls in my code to use your error messages plus a status.
  • Jonathan Leffler
    Jonathan Leffler over 9 years
    The /*NOTREACHED*/ comment is stylized and was used with lint (back in the days when lint was useful because compilers didn't have the cross-module information about function interfaces -- which means before C89 standard compilers became universal, meaning before circa 1995). It indicates that the flow of control in a function does not reach this point (so the fact that there isn't a return 0; at the end is harmless. Of course, with C99 or C11, there is an implicit return 0; there anyway.
  • ANIME4154142
    ANIME4154142 over 9 years
    Hi one last final question. What is the reason for changing the process with grep in it to an if statement.
  • Jonathan Leffler
    Jonathan Leffler over 9 years
    You have three processes; the if (pid2 == 0) is true for the child that needs to run grep, and false for the parent which needs to run wc -l. Note that this code avoids all the issues of waiting for children to die because it simply runs the commands (the exit status of the sequence is the exit status of the wc command). In a shell, you'd need the parent to continue after the commands in the pipeline complete, which requires a bit more coding.
  • William
    William over 8 years
    I edited your question to be more cohesive/accurate but you are welcome to revert the changes.
  • William
    William over 8 years
    You must restart for this to take effect.
  • Петър Петров
    Петър Петров over 8 years
    "use VMWare with an instance of Ubuntu for development" => Not the case with games
  • Harry Johnston
    Harry Johnston almost 8 years
    I'm fairly sure that the standard Java runtime (i.e., from Oracle) is not case-insensitive on Windows. If you tried to put SHORT.class and Short.class in the same directory, it wouldn't work. (Of course if they are inside a .jar file there's no problem.)
  • Bass
    Bass over 7 years
    @William: I believe you only need to terminate all Cygwin processes and services (like Apache, sshd, etc.). That should be enough, as cygwin1.dll will be unloaded from RAM.
  • William
    William over 7 years
    I'm talking about HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\kernel\ dword:ObCaseInsensitive support.microsoft.com/en-us/kb/929110
  • phuclv
    phuclv about 7 years
    it's not correct. For example you can create files differed only in case in Ubuntu and Windows can still work without crashing superuser.com/q/1116625/241386
  • harrymc
    harrymc about 7 years
    @LưuVĩnhPhúc: Bash on Ubuntu on Windows is a special case. From your link: "You can't access to those folders in Explorer, simply because the Win32 subsystem doesn't support case sensitivity, and Explorer doesn't support POSIX subsystem".
  • phuclv
    phuclv about 7 years
    but what you said I am quite sure that if you managed to make NTFS case-sensitive, Windows will crash and re-installation will be the only solution is completely incorrect. First, NTFS already supports case sensitive and nothing else needs to be done. Windows support is another problem. MS has said POSIX Support: NTFS is the most POSIX.1 compliant of the supported file systems because it supports the following POSIX.1 requirements: Case Sensitive Naming: in your link above. Second, no crash will happen even when there are files with same case-insensitive name
  • phuclv
    phuclv about 7 years
    you don't even need Ubuntu on Windows to work with case-sensitive files. Windows supported POSIX subsystem decades ago, and applications that are carefully designed can work with those files without problem
  • harrymc
    harrymc about 7 years
    @LưuVĩnhPhúc: With all respect, you don't know Windows API and disk tables well enough.
  • phuclv
    phuclv about 7 years
    yes, I'm not proficient in Windows API but I know that "NTFS, names preserve case, but are not case sensitive" is wrong, and "Windows will crash and re-installation will be the only solution" is also wrong
  • harrymc
    harrymc about 7 years
    @LưuVĩnhPhúc: Let's say that our knowledge differs, but mine is based on experience. Bash etc. on Windows just simulates case-sensitive, as Windows is not built to do that.
  • Danijel
    Danijel almost 4 years
    Thanks so much for the posix=1 info.