Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In a python script, I am creating a bunch of symbolic links chained together.

example: link1->link2->link3->.......->somefile.txt

I was wondering how you can change the max number of symlinks to be greater than 20?

share|improve this question
5  
Why would you want to do this? MAXSYMLINKS is defined in system headers (e.g. /usr/include/x86_64-linux-gnu/sys/param.h on my system), and is not intended to be modified by users. –  ire_and_curses Oct 28 '12 at 5:57
1  
Having to call readlink() over 20 times to get to a real file is not going to be good for performance. –  jordanm Oct 28 '12 at 13:55
1  
I am taking an ethical hacking class at school, which is pretty cool.One of the HACKS is called TOCTTOU, where you want to impact the performance by creating an elaborate directory/symbolic link maze. –  grebwerd Nov 1 '12 at 21:23
add comment

1 Answer

up vote 4 down vote accepted

On Linux (3.5 at least), it's hardcoded to 40 (see follow_link() in fs/namei.c), and note that it's the number of links followed when resolving all the components of a path, you can only change it by recompiling the kernel.

$ ln -s . 0
$ n=0; repeat 50 ln -s $((n++)) $n
$ ls -LdF 39
39/
$ ls -LdF 40
ls: cannot access 40: Too many levels of symbolic links
$ ls -LdF 20/18 10/10/10/6
10/10/10/6/  20/18/
$ ls -LdF 20/19 10/10/10/7
ls: cannot access 20/19: Too many levels of symbolic links
ls: cannot access 10/10/10/7: Too many levels of symbolic links
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.