Hi friends,
I was trying to traverse a file using FTS(3) . this is the code below.. but I am getting segmentation error in the line fts_read(...) ,
anybody have any idea , why it is?
Please, help me. Thanks in advance.
-------------------------------------------------------------------------------------------------------
Program:
-------------------------------------------------------------------------------------------------------
FTS *fileStruct;
FTSENT *dirList, *fileInfo;
int ftsResult;
fileStruct = fts_open\(&argv[1], FTS_COMFOLLOW, 0\);
dirList = fts_children\(fileStruct, FTS_NAMEONLY\);
do
\{
fileInfo = fts\_read\(dirList->fts_pointer\);
fileStruct = fts_open\(\(char * const *\)dirList->fts\_link->fts_name, FTS_PHYSICAL, \(void *\)result\);
}while (dirList->fts_link != NULL);
ftsResult = fts_close\(fileStruct\);
-------------------------------------------------------------------------------------------------------
Result of Debugging:
-------------------------------------------------------------------------------------------------------
Starting program: a.out temp
0x0000000000400b78 in main ()
Current language: auto; currently asm
(gdb)
(gdb) n
Single stepping until exit from function main,
which has no line number information.
-- Done with option processing. -- optind is 1
first non-option arg: argv[1] = 'temp'
200810090259
destination directory path : temp/200810090259
checking
fileStruct is not null
Program received signal SIGSEGV, Segmentation fault.
0x00007fc797a4d5c8 in fts_read () from /lib/libc.so.6
(gdb) bt
#0 0x00007fc797a4d5c8 in fts_read () from /lib/libc.so.6
#1 0x0000000000400f4d in main ()
(gdb) Quit
(gdb)
-------------------------------------------------------------------------------------------------------