Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
strange "stat" behavior - symlink is not detected
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
swann25
n00b
n00b


Joined: 04 Dec 2006
Posts: 50
Location: Bucharest, Romania

PostPosted: Tue Mar 30, 2010 2:45 pm    Post subject: strange "stat" behavior - symlink is not detected Reply with quote

Hello.
I've encountered a strange problem on a server with XFS:
- I have a "parent_dir" that contains a "sub_dir"
- when doing "ls parent_dir", "sub_dir" is listed as normal dir
- "stat sub_dir" returns a normal dir:
Code:
Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 811h/2065d      Inode: 2684964793  Links: 3
Access: (0755/drwxr-xr-x)  Uid: (  999/id)   Gid: (  600/ftpusers)
Access: 2008-12-24 00:32:43.693275410 +0100
Modify: 2008-12-24 00:41:10.155913021 +0100
Change: 2010-03-25 18:41:47.789395168 +0100


- "ls sub_dir" gives a list of files
- I have a C++ program that traverse "parent_dir" (using "lstat" etc.) and it descends into "sub_dir"
- everything would indicate that "sub_dir" is just a normal dir

On the other hand:
- "stat parent_dir" outputs:
Code:
Links: 2


, therefore "parent_dir" has only 2 hard links, no subdirs; this would be correct only if "sub_dir" is symlink
- "find file sub_dir" returns nothing without "-L" option
- if using "find -L file sub_dir", file is found
- everything indicates that "sub_dir" is a symlink

I'm really lost here . Any help will be appreciated.
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9521
Location: beyond the rim

PostPosted: Tue Mar 30, 2010 3:31 pm    Post subject: Reply with quote

Simply try to unlink() or cp (without options) sub_dir, if it's a symlink it will work, if it's a directory it will fail.
Back to top
View user's profile Send private message
swann25
n00b
n00b


Joined: 04 Dec 2006
Posts: 50
Location: Bucharest, Romania

PostPosted: Wed Mar 31, 2010 3:44 pm    Post subject: Reply with quote

Hello.

"cp" fails if you copy a dir or a symlink to a dir, so it's not useful.
I would not try to remove it, because it's on a production server etc.

I believe it's the filesystem that got corrupted, but I would not run an xfs.check :(
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum