Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-08-2002, 12:29 PM   #1
LQ Newbie
Registered: Apr 2002
Location: UK - Swansea
Posts: 3

Rep: Reputation: 0
Symbolic links

Why won't this code work????

        if(readlink(curdir,buf,(size_t)FILENAME_MAX) != -1){
          if(lstat(buf,&sbuf) == -1){
            fprintf(stderr,"Can't stat %s\n",filename);
          fprintf(stderr,"Can't readlink %s\n",filename);

mode = sbuf.st_mode;
if( S_ISLNK( mode ) ){ type = 'l'; /*symlink: This doesn't work*/
Old 04-08-2002, 10:50 PM   #2
Senior Member
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Sorry to say this but it worked for me.

int mode;

if ( S_ISLNK( stFileInfo.st_mode ))
   printf("is link\n");
mode = stFileInfo.st_mode;
if ( S_ISLNK( mode ))
   printf("is link Test2\n");
All I can suggest is running it through gdb. See if the value of sbuf.st_mode is the same as mode after the assignment.
Let me know if you need help with gdb.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
symbolic links durden2.0 Linux - Newbie 6 11-12-2008 04:06 AM
Symbolic Links petercool Linux - General 2 08-20-2003 12:15 PM
Symbolic links bkmesenbrink Linux - Newbie 2 11-13-2002 12:54 PM
symbolic links winger Linux - General 5 04-06-2002 06:16 PM
Symbolic links Valerie Linux - Newbie 12 03-31-2002 02:49 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:56 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration