ftw : file tree walk recursion level problem
ftw function of ftw.h is a recursive implementation for recursively walking down a directory tree. I want to know how deep can the recursion level be.
I am making a program using ftw in which I may have to give the root directory also for traversing. So how can I know that at what level of subdirectories the function will fail?? TIA |
Hi
I'm not 100% sure about this, but the stack is usually megabytes in size (8Mb size is default, but it can be set with "ulimit -s"). So unless it's set very low, or other parts of the program uses a lot of stack space, you can't reach that limit. MAX_PATH is usually 256 bytes, which means you can't go deeper than about 128 directories, and that doesn't take much stack space. Edit: I was mistaken, directories can be a lot deeper than I thought. But the stack still has a lot of space and can hold directories thousands of levels deep.. |
Quote:
So I tried it (on ubuntu 8.10 i386): Code:
hko:/tmp$ cat path_max.c |
thanks
thanks a lot guys.... that answered my question
I need to understand one more thing PATH_MAX is the maximum path length allowed on the system....can anyone change it on the system and if he does then what will be the maximum limit of the directory level. On my system also PATH_MAX is 4096 |
That would probably require modifying the C-code of fundamental parts of the operating system like libc and/or the kernel.
So, pretty unlikely that your program will be run on such a system. I suppose the find program also depends on this max directory tree recursion limit. |
okk...thanks...
Also, since PATH_MAX is 4096 on my system... so how much maximum level of the directories on my system can be |
All times are GMT -5. The time now is 08:27 PM. |