pleaseDo you feel dizzy when you stand up?



contribute
46

Live bugs

Why does Linux have /usr for a 9.57 KB file

Compiled from @foone twitter

Author: Uing

You can’t copy a 9.57 KB giant file

This year is 8012 2018, and this bug is from 1974. This is a limitation, to be exact, but it’s a limitation that even exists in the latest Windows 10! A pre-Star Wars bug as old as Watergate.




You too much

At the time this feature was developed, everything didn’t have a bar code because it hadn’t been invented yet; When the bug was introduced, there was only one phone company in the United States, and none of it was broken up (ATT was broken up in 1984). At the time, Spielberg was an unknown television director and box-office poison.

Even the greatest movie of all time, The Godfather Part II, has just been released (no arguments accepted)!

Well, where did it come from? In 1974, in a distant, primitive age of computing, Unix was only five years old. But the Unix wunderkind said: Everything is a file! Whether a socket, pipe, or console can be operated in the same way.

For example, if you want to print something, just write into the file using the printer as a file

cat to_print.txt > /dev/lp0Copy the code

If you want to display characters to the terminal, you just write to the /dev/tty file. To generate a random number, you only need to read from /dev/random. These special files are called device files.

For geeks, this is all too comfortable. Imagine dealing with anyone in the world and learning just five words: Hello, thank you, yes, no, goodbye. It’s just wonderful.

Gary Kiddal(IBM’s CP/M father) decided to add this feature to the newly developed CP/M system in 1974 to import port data into text files from the command line or print text files directly. All you need is a Unix-like /dev directory for your various device files.

But! But CP/M is a system that runs 8-bit computers. It had very little memory, only 4K, and no hard disk. It just plugged in an 8-inch floppy disk. File directory? It doesn’t exist! If you want to use another file, just replace the floppy disk.

If there is no directory, where is the Unix /dev directory? It’s everywhere! That is, if you want to print foo. TXT, use

PIP LST:=foo.txtCopy the code

TXT to the file LST, which is the CP/M printer. Because there is no file system, LST does not need to specify a directory. If you want to save the file after writing something, it will prompt you to enter the file name. You can type LST and print it out, or PTP is saved to tape (this was 1974, tape was the most important way to save data, remember the Unix tar stands for tape Archive).

HMM, that doesn’t seem right? If my file is in text format, will the program automatically save it to lst.txt instead of printing it out?

Aha! No, all lst.txt, lst.aux, lst.wat, lst.bug are LST.

Yes, you read that right, LST not only exists everywhere, but is the same regardless of format. It didn’t really matter considering you only had 4K of MEMORY back then.

CP/M was so successful that in the 1970s and early 1980s many commercial systems used this CP/M system. By the 1980s, IBM wanted to enter the PC market, but the CP/M migration to x86 was delayed for six months after the RELEASE of the IBM PC, and cost $240 per copy. DOS costs $40. You know which one to buy with your tits.

Yes, the DOS that made Microsoft rich. But that was still in the hands of Seattle Compute Products, developed by Tim Paterson. It was originally called QDOS, short for Quick and Dirty Operation System. The reason why CP/M is dirty is because there is no x86 version.

In order to be compatible with the original programs above CP/M, QDOS saves all special files, such as AUX, PRN, CON, LPT, etc.

Then Came Microsoft. Microsoft bought QDOS and renamed it MS-DOS, and when the new IBM XT was released in 1983, refactoring a lot and releasing DOS 2.0, the system finally supported directories (Unix was only supported 14 years earlier). Why support it? Because the IBM XT is finally offering hard drives. That’s a 10MB hard drive, so the files have to be in order. Microsoft was finally able to create a C: folder to put all the special device files in, like Unix’s /dev.

But, our buts! Microsoft as compatibility maniac, loudly say: I don’t! To be compatible with all batch scripts from previous QDOS, Microsoft keeps these special device files in all folders (literally) on your hard drive.

Fortunately, we are already using mS-DOS 2.0. However, when Windows 95 was released, it was built on top of DOS, so Windows 95 inherited all the behavior.

The good news is we already use this Windows 95. Windows is now built on Windows NT instead of Windows 95. However, Windows XP wanted to be compatible with Windows 95 and Windows NT, so XP inherited this feature as well.

The good news is that most of us don’t use XP anymore (except in China). But… I’m running out of buts. Yes, Windows 7, Windows 8, Windows 10 are all compatible with all behaviors. So we inherited the bug from 44 years ago.

To try it out, just create a new aux.txt or prn.txt file in any Windows folder and you’ll see this

Your is invalid

We’ve always had this limitation on Windows because Gary Kiddal was drawn to Unix’s “Everything is a file.” People born in that era had kids who could drink alcohol (21 in the US), and we couldn’t have con.dom on Windows yet.

Microsoft also lists all the unusable ones: CON, PRN, AUX, NUL, COM1-9, LPT1-9.

Let’s go back to the beginning, so you may be wondering how foone got into the problem of copying the “giant file” aux.h. Because he was using Linux, Linux supports reading and writing NTFS. And these special file names are not implemented at the file system level, but at the system level! That is, you can use these file names in NTFS, but you can’t use them in Windows…

You may run into this problem when copying some files to Windows if you name them as casually as you would a child.

Why does Linux have /usr

Since I (Foone) wrote that a decision on the CP/M system in 1974 affected Windows 10, some people have said, “That’s why I use Linux!”

Slow! Linux is a branch of Unix (no debate), Unix is older than CP/M (no debate), and the fact is that some design decisions are older than the previous one, and that’s the /usr folder.

If you look under the Linux root directory, you will see many classic folders, such as /bin, /lib, /etc, /sbin.

Many of your

Let’s take a look at /usr. /usr also has bin/sbin/lib /.

The same goes for you

If a newbie asks you why, tell him or her that everything under /usr does not affect the system, and everything under root is the most important. When you do emergency maintenance, you can do without /usr, but not without root.

For example, the classic bash(which allows you to improve your hard drive) and fdisk (which you want to do with your hard drive before you die) are placed under /bin/ and /sbin/ in the root directory, Firefox (the main reason why you want to use fdisk for your hard drive) is under /usr/bin. After all, when your system crashes or you’re about to die, you want to bash fDisk to do some fixes or eventually destroy your hard drive, not tweet a selfie.

But this should be done because of /usr, not why we have a /usr.

Back in 1971, two years after Unix was born at Bell LABS, the two titans finally switched gears, upgrading from PDP-7 to PDP-11. This was a $20,000 machine, which is equivalent to $133,000 today.

Most importantly, the machine has more storage space. They bought an RK11 controller that supports up to eight hard drives. But money is not unlimited, so the two mansions can only buy two RK05 hard drives, each up to 2.5MB.

It used to be that in PDP-7 all file systems were in one partition, and by then there were /bin and /usr. Yes, /usr was originally there, but it was used as a user directory, which is now the /home directory.

God says: Make a difference. So the first drive is used for the root directory, which is used for the development system, and the second drive is used for user stuff, which is then mounted under /usr. The user directory is full of small things, so that’s 2.5MB of almost unlimited space.

God said: I x! The first plate is full! As an actively developed system, it is sure to generate a large number of binaries, and the various debug tools are enormous. It is possible to buy another RK05, but there is no money. And it seems that the user directory /usr is not very full…

God says: Copying and pasting is holy. So they made a copy of the entire system file architecture and pasted it under /usr, hence /usr/bin, /usr/lib. But which files to move over? It must be something that will not affect the system boot, since you need to boot the system first and then mount /usr to the root directory.

God says: That’s settled. So until the latest version of Ubuntu(a popular Linux), 18.10, you had /bin and /usr/bin on your system because two geeks couldn’t afford 2.5MB hard drives 45 years ago.

conclusion

This is not a bug, this is a feature! Feature, okay?

Foone twitter.

Creative Commons Agreement (BY-NC) released.



Praise a (44)