Case sensitive no linux

Windows и case-sensitive filesystem

Давным-давно, на заре своего рождения Windows использовала файловую систему FAT. Потом ей на смену Microsoft и IBM разработали NTFS. В те давние времена возникло два противоположных подхода к файловой системе. В Linux используется case-sensitive файловая система, а в Microsoft — case-insensitive.

Суть в том, что в case-sensitive файловой системе считается, что имена, написанные в разных регистрах (например, FILE.txt и file.txt) — это разные имена. А для Windows между ними нет разницы.

Несмотря на нечувствительность Windows к регистру букв, разработчики NTFS подошли к делу ответственно, и бережно сохраняют регистр имен каталогов и файлов. Возможно, они не теряли надежды на сближение с противоборствующим лагерем.

Первые жертвы

Шли годы, информационные технологии не стояли на месте, и дистрибутивы Linux научились монтировать NTFS-разделы. Операционные системы стали ближе, а наши противники впервые столкнулись на одном поле — и появились первые проблемы. Присоединив NTFS-раздел, пользователь Linux мог создать в одном каталоге несколько различных файлов с именами, которые отличаются только регистром. А как мы знаем, NTFS сохраняет регистр букв при создании объектов файловой системы. Если потом подключить тот же NTFS-раздел к Windows, то операционная система начнет путать файлы-близнецы между собой. С ее точки зрения, они имеют одинаковые имена! Пользователь кликает по одному файлу, а открывается совсем другой. Короче, хаос и безобразие.

В 2016 году Microsoft сделала шаг навстречу Linux и выпустила Windows 10 Anniversary Update с подсистемой WSL. Windows Subsystem for Linux (WSL) предоставляет интерфейсы, во многом совместимые с интерфейсами ядра Linux. Что позволяет запускать большинство Linux-приложений, в том числе оригинальные образы некоторых Linux-дистрибутивов. Например, Ubuntu 14.04! Это была революция! Linux и Windows работают на одном компьютере одновременно, как партнеры. Но к сожалению, партнеры все еще по-разному смотрели на регистрочувствительность в плане работы с файловой системой. Ввести Windows в замешательство с помощью создания файлов или каталогов с именами, отличающимися только регистром, стало еще проще.

Попытка примирения

В новой версии Windows 10 Spring Creators Update компания Microsoft добавила возможность задания режима case-sensitivity для отдельно взятого каталога. Сделать это можно с помощью утилиты fsutil. Читатель, наверное, уже знаком с этой полезной утилитой.

Теперь у нее появились две новые команды:

fsutil file queryCaseSensitiveInfo

fsutil file setCaseSensitiveInfo

Для того чтобы воспользоваться этими командами, у вас должна быть активирована WSL-подсистема, а команда setCaseSensitiveInfo требует прав администратора.

После включения режима case-sensitivity файлы и каталоги, находящиеся внутри, будут доступны только при указании их точного имени! И Windows теперь четко видит разницу между FILE.txt и file.txt.

С другой стороны, WSL-подсистема тоже должна учитывать, включен или выключен режим case-sensitivity у каталога, в котором она создает файл или дочерний каталог. Каталоги, которые формируют структуру WSL или создаются из WSL, сразу имеют включенный case-sensitivity. Все остальные каталоги по умолчанию режим case-sensitivity не включают.

Если в WSL зайти в каталог с выключенным case-sensitivity режимом и попробовать создать в нем два файла, имена которых будут отличаться только регистром, то получите ошибку.

Читайте также:  Осеннее обновление windows 10 2019

Таким образом, WSL и Windows поделили логический диск между собой. Часть каталогов поддерживает режим case-sensitivity, а другая часть – нет.

Спускаемся ниже

Под капотом для получения и задания флага case-sensitivity используются функции NtQueryInformationFile и NtSetInformationFile c новым параметром FileCaseSensitiveInformation.

В результате работы функции в переменной csFlags будет 1, если режим case-sensitivity включен, и 0 — если выключен.

Еще ниже — Raw NTFS

На уровне NTFS флаг case-sensitivity хранится в атрибуте StandartInfoData, в поле NumVersion.
Если атрибут выставлен, то NumVersion = 1, иначе NumVersion = 0

Заключение

Мы видим, что Microsoft прикладывает значительные усилия для того, чтобы объединить в одной системе два разных мира — Windows и Linux. И для успеха своей миссии они пошли на уступки в плане регистрочувствительности своей файловой системы. Поможет ли это? Решит ли противоречия? И какие еще проблемы всплывут? Все это покажет лишь Его Величество Время.

Источник

Thread: Why is Linux/Ubuntu case-sensitive?

Thread Tools
Display

Why is Linux/Ubuntu case-sensitive?

I’m just curious why Ubuntu and Linux in general is case-sensitive? I can see a very good reason for having a case-insensitive file system though: less confusion!

Re: Why is Linux/Ubuntu case-sensitive?

Actually, having a case sensitive file system creates less confusion. You’re only confused with a case sensitive file system because you’re used to a case non-sensitive file system.

Happy Ubunting!

Re: Why is Linux/Ubuntu case-sensitive?

Linux is written in C, which is case sensitive. It makes for faster sorting.

Re: Why is Linux/Ubuntu case-sensitive?

Counter question : Why is Windows not case-sensitive?
Users of Linux/Unix really appreciate the value of case-sensitiveness.
I myself feel very irritated by MS Windows treatment of file/network/user names (and more)

Re: Why is Linux/Ubuntu case-sensitive?

because its the simple way to do it. on computers letters are represented by numbers using an encoding like ascii or unicode. in ascii ‘a’ is 97 and ‘A’ is 65.

when you ask is ‘Sam’ the same string as ‘sam’, the computer sees three numbers, and check that numbers are all equal. does not need to know anything about the actual letters.

to do a case insensitive compare you need to convert both strings to lowercase, and then do the compare. so now you need a big table of equivalents. this is a fairly small task for the old ascii character set as it only has 128 characters, and you can convert to lower case by adding 32 to all the characters within a certain range.

Unicode which is now used modern operating systems has millions of characters from every language on earth (and some from elsewhere eg middle earth). some languages don’t even have a concept of upper and lower case.

this does not make it impossible, but its a big task, and probably not worth the benefit in many places.

Источник

Filesystem Case-Sensitivity Mismatch

Fixed in 2021.1, please see https://youtrack.jetbrains.com/issue/IDEA-135546

What was that?

All IDEs based on IntelliJ platform have a global setting telling whether to treat file systems as case-sensitive. The setting depends on OS: by default, Mac OS X and Windows are case-insensitive, Linux and friends are case-sensitive.

Unfortunately, life is never that simple. The warning you’ve seen means that on opening a project an IDE has performed a quick check and found you guilty that case-sensitivity of a file system, on which the project is located, doesn’t match aforementioned setting.

Читайте также:  При установке windows запрашивает пароль
Is it bad?

Well, this won’t set your computer on fire, but certain undesired things may happen — missing files, undetected external changes, file cache conflicts and excessive indexing among them.

How to deal

You can either move your projects, or tell an IDE to change its mind.
For the latter add the following line to idea.properties file (Help | Edit Custom Properties, see «Configuring platform properties» for more details):

Use true if your projects are located on case-sensitive FS, false otherwise. Then choose File | Invalidate Caches and restart the IDE.

That’s all?

Nope. Setting the global property is a temporary solution; vote/watch this issue to be notified when a permanent fix will be in place.

Источник

Improved per-directory case sensitivity support in WSL

With the Windows Subsystem for Linux, we’ve always allowed you to treat your files as case sensitive, just like Linux does. In the past, if you had files whose name differed only by case, these files could not be accessed by Windows, because Windows applications treat the file system as case insensitive.

A while ago, we introduced per-directory case sensitivity. This allows specific directories to be treated as case sensitive by both WSL and Windows applications. Because Linux developers usually expect the file system to be case sensitive, we opted to make new directories created by WSL on your Windows volumes case sensitive by default.

Unfortunately, this had an unintended side effect. Some Windows applications, using the assumption that the file system is case insensitive, don’t use the correct case to refer to files. For example, it’s not uncommon for applications to transform filenames to use all upper or lower case. In directories marked as case sensitive, this means that these applications can no longer access the files.

While in the long term the preferred solution is to fix these applications to correctly handle case sensitive directories, we realize that this isn’t always an option, and you, our customers, shouldn’t have to wait for that.

Additionally, if Windows applications created new directories in a directory tree where you are using case sensitive files, these directories would not be case sensitive. This made it difficult to work with Windows tools in case sensitive directories.

For these reasons, we have made two changes to how case sensitive directories work: an extended attribute to control case sensitivity in WSL, and inheritance of the case sensitivity flag for new directories.

Using Linux extended attributes to get and set per-directory case sensitivity

As of Windows insider build 17692, it’s now possible to inspect and modify the case sensitivity flag for a directory from inside WSL. Case sensitivity is exposed using an extended attribute named system.wsl_case_sensitive . The value of this attribute will be 0 for case insensitive directories, and 1 for case sensitive directories.

To manipulate extended attributes from the terminal, you can use the setfattr and getfattr applications. On Ubuntu, these can be installed using sudo apt install attr .

With these applications, you can determine if a directory is case sensitive using:

Mark a directory as case sensitive:

Mark a directory as case insensitive:

The following shows an example where a case insensitive directory is marked as case sensitive:

Note: changing the case sensitivity attribute requires “Write attributes”, “Create files”, “Create folders” and “Delete subfolders and files” permissions on the directory. In some cases, with folders outside your user profile, you may not have all these permissions by default even if you own the directory. If you receive an access denied error when changing the attribute, make sure you have the correct Windows permissions on the folder.

Читайте также:  Linux это операционная система россии

Changing the case sensitivity attribute requires that none of the folder’s descendants are currently open in WSL. It is not possible to disable per-directory case sensitivity on a directory that contains files whose names only differ by case.

The case sensitivity attribute is not available on file systems that do not support per-directory case sensitivity, such as FAT or SMB file systems. Currently, only local NTFS volumes support per-directory case sensitivity.

Case sensitivity inheritance

Previously, it was necessary to explicitly mark every directory you create as case sensitive. Now, we’ve made it so that the per-directory case sensitivity flag is inherited when creating a new directory. This means that new directories created in a case sensitive directory are automatically case sensitive.

The big advantage of this is that it’s now much easier to use certain Windows tools in case sensitive directories. For example, you can use the in-box tar.exe to extract an archive in a case sensitive directory, and be sure the entire directory subtree is case sensitive. Similarly if you clone a repository using Git for Windows, or if you create new directories using an editor such as Visual Studio Code. This makes it much easier to use Windows applications with case sensitive directories, without needing to modify those applications.

Case sensitivity mount options in DrvFs

When mounting Windows volumes in WSL with DrvFs, you can specify the default case sensitivity behavior using the case=off or case=dir mount option. With case=off , new directories are not case sensitive by default. With case=dir , they are case sensitive by default. In either case, directories already marked as case sensitive will be treated as case sensitive.

These options are not new, but combined with the system.wsl_case_sensitive extended attribute and case sensitivity inheritance, they give you greater control over where per-directory case sensitivity is used.

Now, if you mount DrvFs using case=off , it is easy to mark directories case sensitive when you want them to be, and since inheritance also applies to WSL even with case=off , you can be sure the entire subtree will be case sensitive.

The following example shows how a new directory created in a case sensitive directory is also case sensitive, even when using case=off :

We recommend that you start mounting your DrvFs volumes using case=off and only enable per-directory case sensitivity when you need it. This can be accomplished using the /etc/wsl.conf file. The following is an example wsl.conf file that sets case=off as the default for automounted DrvFs volumes:

In a future Windows Insider build, we will change the default behavior for DrvFs to be case=off if no options are specified, and you will need to explicitly mount with case=dir if you want to use the old behavior.

Thanks and Feedback

A big thanks for helping provide feedback on case-sensitivity. Be sure to continue providing feedback on the WSL GitHub repo and Tweeting us at #WSLinux.

Источник

Оцените статью