how and when to create the "." and ".." entry in Linux file systems?

From: Jidong Xiao
Date: Wed Nov 17 2021 - 21:20:26 EST


Hello,

I'm trying to learn how to implement a very simple file system in a
Linux system. I started with registering the file system, allocating
and initializing the superblock, and allocating the root inode of this
file system. Now after mount, I can "cd" into my file system root
directory - the directory where this file system is mounted.

Now my next goal is, in the root directory, if I run "ls -a", I should
see "." and "..". I think this behavior should be common among all
file systems, thus in my file system code, I likely don't need to do
anything fancy, but maybe just call some VFS function? If so, call
which function? Are these two entries (. and ..) supposed to be
created when the file system is mounted or later - like not created
until I run "ls -a"?

Thank you.

-Jidong