When I searched for a file where one could (semi)control brightness I accidentally found a nested sequence of directories like below
aneesh@nb-14:~$ cd /sys/class/graphics/fb0/device
aneesh@nb-14:/sys/class/graphics/fb0/device$ cd graphics/fb0/device
aneesh@nb-14:/sys/class/graphics/fb0/device/graphics/fb0/device$ l
driver@ graphics/ modalias power/ subsystem@ uevent
aneesh@nb-14:/sys/class/graphics/fb0/device/graphics/fb0/device$
/a/b/a/b/a/b...
, one can create a link to the directory /a
and paste it in the folder /a/b
. Is this the only way nested sequences can be formed?
Symbolically it's not obvious: To verify this I tried giving command l
(see above) and found symbols against each file/directory. I learnt from this forum itself that in the result of l
, the symbol @
is for indicating drivers and /
for directories. But no symbolic indication to show that a certain folder is actually a link to another one! Also, there's no manual entry about l
to find which symbol (if any) indicates file link.
The loop (nesting) you see actually serves A very important purpose.
Imagen "Give me the other device on the same device as that device". I know that's confusing in video card context but think of sound card.
"Give me the other outputs on the same card as output 5"
In order to do this you need some kind of "children on my parent" which is exactly what you have here. "Children of my parent" may only have 1 entry but that is ok to.
To add more complexity, the /sys folder isn't even really there. It's an enumeration of kernel stuffs. So it's kind of like a "easy to use api" for accessing kernel data. So not only can that lead to situations like your example, but there not even really files, so it's quite alright if it does.
To see if something is a link you can always use ls -la to display more verbose details. But keep in mind those files are not real, and may not be symbolic links in the true sense, and there for it is totally possible to have recursion without doing anything "wrong" or using links/etc.