LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-15-2009, 02:47 AM   #1
ador
LQ Newbie
 
Registered: Apr 2009
Posts: 3

Rep: Reputation: 0
Multiple . and .. in a folder


Here's the situation. I have a program running on Fedora 8 which creates a folder and saves some files in it. After a certain amount of time it will then delete this folder using the command:

rm -rf [folder name]

There's no problem with the logic of the program and it works well 99% of the time. However, I recently encountered a problem where the deleting of the folder encountered this error message:

rm: cannot remove directory `[folder name]': Directory not empty

Looking in the folder with ls shows that the folder is empty. Using the command ls -fl shows me this:

drwxr--r-- 2 root root 135168 2009-04-15 02:13 .
drwxrwxrwt 13 root root 4096 2009-04-15 01:51 ..
drwxr--r-- 2 root root 135168 2009-04-15 02:13 .
drwxrwxrwt 13 root root 4096 2009-04-15 01:51 ..

I'm thinking that I'm getting an error deleting this folder because of the duplicate . and ..

So now I'm wondering how this could have happened and how I can delete the folder.

I've tried following the different ways to delete the folder in the link below but still can't.

http://www.labtestproject.com/linuxcmd/rm.html

Any help would be appreciated.
 
Old 04-15-2009, 03:03 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Look at "ls -li" and see if the inodes are different.

I wonder if there is a file that has an illegal filename of ".." or if those aren't actually periods but a character with a similar typographical appearance.

However, rm -rf <dirname> should delete the files before the directory. Try the unlink command instead.

If the inode of one of the ".." filenames is different than the inode of the parent directory, you could use the find command:
find . -inum <inode#> option and -exec rm '{}' to try to delete it. Be careful you don't delete the parent directory by mistake.
Code:
ls -ldi testdir
1384578 drwxr-x--- 2 jschiwal jschiwal 4096 Apr 15 01:50 testdir
jschiwal@qosmio:~> ls -ldi .
458753 drwx--x--- 122 jschiwal jschiwal 20480 Apr 15 01:50 .
jschiwal@qosmio:~> cd testdir
jschiwal@qosmio:~/testdir> ls -lia
total 24
1384578 drwxr-x---   2 jschiwal jschiwal  4096 Apr 15 01:50 .
 458753 drwx--x--- 122 jschiwal jschiwal 20480 Apr 15 01:50 ..
You may also have a corrupt filesystem. Might want to check that out.

Also always be careful when deleting hidden files. Don't use "rm .*". That will also match ".." which is the parent directory. I use "rm .[^.]*" instead.

Last edited by jschiwal; 04-15-2009 at 03:50 AM.
 
Old 04-15-2009, 07:30 AM   #3
ador
LQ Newbie
 
Registered: Apr 2009
Posts: 3

Original Poster
Rep: Reputation: 0
With ls -lia I get

181934543 drwxr--r-- 2 root root 135168 2009-04-15 02:13 .
181934543 drwxr--r-- 2 root root 135168 2009-04-15 02:13 .
28639233 drwxrwxrwt 13 root root 4096 2009-04-15 01:51 ..
28639233 drwxrwxrwt 13 root root 4096 2009-04-15 01:51 ..

So the inodes are the same. I already tried deleting with the inode but could not.

I also tried unlinking the folder itself as well as the .. but I just get the error message that I can't do that because it is a directory.

I thought about this being a corrupt file system but I haven't seen any signs of problems in dmesg or the messages logs. I will probably have to add error checking on something like this but I was really hoping to just find out how this could have happened in the first place.
 
Old 04-15-2009, 07:48 AM   #4
maresmasb
Member
 
Registered: Apr 2009
Posts: 108

Rep: Reputation: 24
Your script seems to run as root. I don't know the purpose of your script, but you should avoid automated tasks with root permissions, unless it's unavoidable.

Having directory contents with the same name, especially if it's . and .. seems rather like filesystem corruption. Even more as 'rm -rf' is supposed to delete directories unregarded their contents. You should run fschk to sort it out.

Last edited by Tinkster; 10-30-2010 at 04:28 PM.
 
Old 04-17-2009, 01:07 AM   #5
ador
LQ Newbie
 
Registered: Apr 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Well, checking back on the server, it seems that it's having a problem deleting another folder. Different set of problems this time. Just trying to ls the files in the directory is returning an error.

In conclusion, it seems like what was suggested is true, that the file system might be corrupt.

Thanks for the replies.
 
  


Reply


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
Shared folder for multiple users droidix Linux - General 2 07-18-2008 11:44 PM
Setting up a server... Multiple group-rights to folder? husbyggarn Linux - Security 4 07-18-2008 09:11 AM
Package Folder into Multiple tar files??? mefman Linux - Newbie 9 04-01-2008 06:38 AM
FTP Folder accessible by multiple users question JohnnyAvocado Linux - Networking 1 01-13-2007 08:39 AM
One shared folder for multiple ftp users -- vsftpd rover Linux - Networking 0 06-17-2004 07:07 AM


All times are GMT -5. The time now is 08:30 PM.

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