[cs631apue] Readlink errors

Tejas @ Stevens tnadkarn at stevens.edu
Sat Oct 5 22:24:31 EDT 2013


Thanks, I did that a little while ago. Was a stupid mistake on my part.

Misusing strcat. All fixed.

Thanks,
Tejas

On Oct 5, 2013, at 10:08 PM, yluo4 <yluo4 at stevens.edu> wrote:

> You can use strerrno to see what the error says.
> 
> 
> On 10/05/2013 9:11 PM, Tejas Nadkarni wrote:
>> I take it back, it seems to work the first time but on future calls it
>> fails! This is stumping me. Here's my code. This is called for each
>> directory entry when using longformat.
>> char buf [PATH_MAX];
>> int r=0;
>> .
>> .
>> .
>> if it's a link...
>> r = readlink(strcat(p->fts_path,p->fts_name),buf,sizeof(buf)-1);
>> if (r>0){
>>   buf[r]='';
>>   printf(" %-s -> %s",p->fts_name,buf);
>> }else
>>   printf(" %-s -> %s",p->fts_name,"Could't read link");
>> Again, this works the first time it's run but after that fails!! :)
>> On Sat, Oct 5, 2013 at 8:59 PM, Tejas Nadkarni <tnadkarn at stevens.edu>
>> wrote:
>>> I'm using readlink to read symlinks to determine their actual target
>>> and print it out as part of the longformat. This seems to work for
>>> links I create but I've run into existing symlinks that don't work
>>> and I believe is a permissions issue.
>>> How are you handling this? 
>>> for example if I run "./ls -l /etc/" on my Ubuntu VM....
>>> It works on this...
>>> blkid.tab -> /dev/.blkid.tab
>>> but not on this...
>>> vtrgb -> Could't read link
>>> and many others.
>>> I've had no issues on symlinks I've created so far.
>>> Thoughts?
>> _______________________________________________
>> cs631apue mailing list
>> cs631apue at lists.stevens.edu
>> https://lists.stevens.edu/mailman/listinfo/cs631apue
> _______________________________________________
> cs631apue mailing list
> cs631apue at lists.stevens.edu
> https://lists.stevens.edu/mailman/listinfo/cs631apue



More information about the cs631apue mailing list