Link to home
Start Free TrialLog in
Avatar of eng_h

asked on

stimulate ls -l

Hi. If anyone can help me with ls –l  I appreciate that. I've written program in c to stimulate ls -l.
 it's works well except the link. I need to print out the line like this
 lrwxrwxrwx 1 admin admin 11 Feb 27 19:08 figC.18 -> ipc/fifo1.c.  
 but it’s just print   lrwxrwxrwx 1 admin admin 11 Feb 27 19:08 figC.18.  I need to make my program print the link also.
Thanks for your help
Avatar of phoffric

You saw , right?

Also, look at :

•S_ISBLK(mode) -- Is this a block special file? (usually a block-based device of some sort)
•S_ISCHR(mode) -- Is this a character special file? (again, usually a character-based device of some sort)
•S_ISDIR(mode) -- Is this a directory?
•S_ISFIFO(mode) -- Is this a pipe or FIFO special file?
•S_ISLNK(mode) -- Is this a symbolic link?
•S_ISREG(mode) -- Is this a regular file?
Avatar of phoffric

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eng_h


The solution was so helpful.
Avatar of eng_h


I used this part  in my program
                  char targetName[PATH_MAX + 1];
                if( readlink( pathName, targetName, PATH_MAX ) != -1 )
                    printf( "\t%s -> %s\n", pathName, targetName );
                      printf( "\t%s -> (invalid symbolic link!)\n", pathName );

and it worked with me.
Thanks so much for your time phoffric !!
Glad you found it helpful.