Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'Directory not empty' error

Status
Not open for further replies.

Wishdiak

Technical User
Mar 7, 2004
1,787
US
For some reason, the directory /usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config/cpu seems to be 'stuck'. There are no files in it, and yet it can not be removed, even in single-user mode.

I've run fsck in single-user mode, but I still get the error

rm:/usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config/cpu: Directory not empty

when I try to delete it. Any ideas?

Wishdiak
A+, Network+, MCSA 2003 certified
 
UnixJunky,

I've done both of those. The problem seems to be that although ls shows no files in /usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config/cpu, it still tells me that the directory is not empty when I try to remove it. As a result, I can't portupgrade gcc 3.4.

# rm -r /usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config/cpu
rm: /usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config/cpu: Directory not empty
# cd /usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config/cpu
# ls -al
total 4
drwxr-xr-x 6 root wheel 512 Nov 24 00:16 ./
drwxr-xr-x 5 root wheel 512 Nov 24 00:16 ../


Wishdiak
A+, Network+, MCSA 2003 certified
 
UnixJunky,

Thanks for your help. Nothing shows in the output of 'ps aux' that links to this file.

I've rebooted into single-user mode and attempted to delete this directory, only to be told that it is not empty when it contains no files.

Wishdiak
A+, Network+, MCSA 2003 certified
 
use the 'f' with rm. 'rm -rf /usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config/cpu'
 
Also, you are not sitting in the directory when doing that are you?

And try running 'fuser /usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config/cpu' to see if it lists anything.
 
kHz,

Thanks for your help also. I am not sitting in the directory when trying to delete it.

# rm -rf /usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config/cpu
rm: /usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config/cpu: Directory not empty
# fuser /usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config/cpu
fuser: Command not found.

Wishdiak
A+, Network+, MCSA 2003 certified
 
Have you done a 'cd /usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config' and then 'rm -rf cpu' and see if that works?
 
kHz,

Yep.

# cd /usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config
# rm -rf cpu
rm: cpu: Directory not empty
# cd cpu
# ls -al
total 4
drwxr-xr-x 6 root wheel 512 Nov 24 00:16 ./
drwxr-xr-x 5 root wheel 512 Nov 24 00:16 ../

Wishdiak
A+, Network+, MCSA 2003 certified
 
Unseen characters is a possibility.

In ksh, do: set -A files $(ls .) #while sitting in the cpu directory

and then do: print ${files[@]} #to print all files
 
I don't know how to set arrays in csh. What I gave is using ksh.
 
kHz,

No problem, I installed ksh93 from ports. I assume that the lack of any output from

# cd /usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config/cpu
# set -A files $(ls .)
# print ${files[@]}

means that nothing was found with any unseen characters.

Wishdiak
A+, Network+, Security+, MCSA 2003 certified
 
You could try running it again, but instead of doing a print run 'rm ${files[@]}' then try the rm -rf on the direcotry again. Just in case there was something there.
 
kHz,

I really appreciate your help, as this problem is getting the best of me.

# cd /usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config/cpu
# set -A files $(ls .)
# rm ${files[@]}

returns

usage: rm [-f | -i] [-dPRrvW] file ...
unlink file

and I still can't rm -rf the directory.

Wishdiak
A+, Network+, Security+, MCSA 2003 certified
 
try:

# cd /usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config/cpu
# set -A files $(ls .)
# rm -rf ${files[@]}

Also, is /usr or /usr/ports filesystems? /usr/ports isn't mounted before /usr?
 
kHz,

/usr/ports isn't a mountpoint. /usr is the only mountpoint that relates to this.

# cd /usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config/cpu
# set -A files $(ls .)
# rm -rf ${files[@]}
# cd ..
# rm -rf cpu
rm: cpu: Directory not empty

Same error that I've been getting. Argh!

Wishdiak
A+, Network+, Security+, MCSA 2003 certified
 
Code:
#include <stdio.h>
#include <unistd.h>

#define TEST_FILE         "/usr/ports/lang/gcc34/work/gcc-3.4-20041112/libstdc++-v3/config/cpu"

main() {
        unlink(TEST_FILE);
        return(0);
}

That should do it.
 
kHz,

I'd think so too, although my c skills are a bit rusty. I pasted the code above into a file, and on execution got the error
Badly placed ()'s.

Wishdiak
A+, Network+, Security+, MCSA 2003 certified
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top