The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Reading a file and writing the file name to a param file. thebeginer UNIX for Advanced & Expert Users 1 10-05-2007 05:38 PM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 05:25 AM
Creating breadth traversal binary tree slurpeyatari Shell Programming and Scripting 3 08-11-2005 04:28 PM
Command line traversal videsh77 UNIX for Dummies Questions & Answers 7 06-13-2005 06:05 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-09-2008
jack85 jack85 is offline
Registered User
  
 

Join Date: Oct 2008
Location: NJ
Posts: 2
Arrow need help in file traversal via FTS(3)

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)

-------------------------------------------------------------------------------------------------------

Last edited by jack85; 10-09-2008 at 05:04 AM.. Reason: updated
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:32 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0