for some reason, operating systems developers always try to abstract away everything to one thing and work with that thing!
like UNIX philosophy was "everything is a file".. literally everything, RAM, PC, processes, etc.. all treated as files despite their different nature!
today I discovered something, windows also has similar model.. it treats everything as an "object"
to see this in action we'll need to download WinObjEx tool from sysinternals.. it'll show you most of the objects on your machine
the specific objects I want to show you are those in global key in NT namespace.. this space contains objects such as your hard disk volumes, see this photo for example:
it shows that my PC contains 7 hard disk volumes, but the interesting part is their path.. it's "\Device\HarddiskVolumeX".. what is this?
and where is C: and D: drive letters we are used to?
well, this is a very hard truth but we were in a lifetime illusion, drive letters are just conventions from DOS days that windows pretends they're the hard disk reality, while they're just symbolic links to these paths!
want to see it in action??
this is the field of my D volume, and as you can see it's just a symbolic link for \Device\HarddiskVolume2!
another interesting question, if all hard disk volumes start with that \.. does this mean even NTFS is a tree-like filesystem?
yes!
at the very fundamental level, NTFS is pretty similar to root-based filesystems such as ext4!
the "root" of your hard disk in windows is \\?\,
my C: volume for example has this path:
\\?\C:\
let's try to use "dir" command to list the D:\ volume, I'll try it both in pwsh core and cmd.exe, in cmd.exe.. it gave me this result:
sound weird.. this time it showed nothing, not even an error!
well, I couldn't find why this specifically happen, but I could solve it!
you just need to add -LiteralPath argument to dir command and it'll happily give you the list:
dir -LiteralPath "\\?\D:\"
it gave me similar list to that of cmd.exe!
maybe LiteralPath tells dir to not interpret the path and path it directly to NT native API?
I'm not really sure!
but I just wanted to conclude my post with 2 things:
1- NT kernel is an object-oriented kernel
2- drive letters are just symbolic links, and NTFS is root-based like ext4 filesystem.
No comments:
Post a Comment
any inappropriate comments will be deleted and the commenter will get blocked permanently unless I'm free to fuck him.