当前位置: 主页 > 系统 >

Windows上的保留文件名

时间:2021-11-22  作者:haden   点击:
【摘要】## 0x0 起因本来想在Windows上用git下载查看Linux源码,但是git报错:```remote: Counting objects: 6012062, done.remote: Compressing objects: 100% (1031/1031), done.remote: Total 6012062 (delta 893), reused 342 (delta 342), pa

0x0 起因

本来想在Windows上用git下载查看Linux源码,但是git报错:

remote: Counting objects: 6012062, done.
remote: Compressing objects: 100% (1031/1031), done.
remote: Total 6012062 (delta 893), reused 342 (delta 342), pack-reused 6010689
Receiving objects: 100% (6012062/6012062), 2.06 GiB | 3.62 MiB/s, done.
Resolving deltas: 100% (4997555/4997555), done.
error: unable to create file drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c: No such file or directory
error: unable to create file drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.h: No such file or directory
error: unable to create file include/soc/arc/aux.h: No such file or directory
Checking out files: 100% (61359/61359), done.
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'

查看 git status 看到一堆被删除的文件。

0x1 原因

Windows上有些文件名是无法使用的,比如 auxcom1等。这些是系统保留的设备名,也是为什么clone会失败的原因。
还有就是Linux文件名区分大小心,而Windows不区分,Linux 内核工程里恰好有一些大小写不同的文件。这些导致了git的错误。

想要参与Linux内核开发,还是要用Linux系统!

0x2 深入

所以有那些文件不能使用呢?

CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9

这些名字不能用作任何文件的名字,甚至加后缀名也不行。无法创建 con.txtcon.jpg文件。而Windows不区分大小心,所以无论是CONcon还是CoN都是不允许的。

这一切要从1974年说起。在UNIX中,“一切都是文件”。(在今天的Linux之类的类似UNIX的操作系统中也是如此。)硬件设备在特殊路径中表示,例如第一台打印机的 /dev/lp0 和控制台的 /dev/tty

1974年,CP/M 操作系统将相同的概念添加系统中。不幸的是,CP/M 是为内存很少且没有硬盘驱动器的计算机设计的。它使用多个磁盘,没有目录,因此代表设备的那些特殊文件有效地出现在每个磁盘上的任何地方。因此,在保存文本文件时,您可以告诉文本编辑器将其“保存”到打印机设备,然后再进行打印。但是文本编辑器和其他程序喜欢添加文件扩展名,例如 .txt,因此 CP/M 忽略了这些设备文件的文件扩展名。 换句话说,如果文本编辑器尝试将文件保存为打印机设备的名称,后跟 .txt,则 CP/M 只是假定它是在指打印机设备,而忽略了文件扩展名。

PC-DOS保留了 CP/M 系统的功能。 PC-DOS 2.0 在1983年增加了目录功能,但是微软选择让这些设备文件可以出现在所有目录中以实现与现有 DOS 软件的兼容。

最终,Windows95 操作系统出现,它是基于 DOS 构建的。虽然 Windows NT 并非基于 DOS 系统,但希望与 Windows95 保持兼容性。

现在,我们任然不能命名文件 con.txtaux.mp3,因为 Windows 希望和可能使用这项功能的古老程序保持兼容。

原文:https://www.howtogeek.com/fyi/windows-10-still-wont-let-you-use-these-file-names-reserved-in-1974/

顶一下
(0)
0%
踩一下
(0)
0%
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
验证码: 点击我更换图片

推荐内容