The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - General (http://hintsforums.macworld.com/forumdisplay.php?f=16)
-   -   Cannot delete zero byte files (http://hintsforums.macworld.com/showthread.php?t=3094)

Hunger Moon 05-24-2002 11:41 PM

Cannot delete zero byte files
 
This is doing my head in. I moved some files to the trash but I cannot empty them, getting a -35 error. Even as root I can't delete them as I'm informed they don't exist. An ls shows filenames but ls -l says they don't exist. rm -f doesn't work either. I've tried renaming, editing, moving. No dice. Can anyone offer a clue?

Thanks.

Simon

xchanyazy 05-25-2002 02:38 AM

Bizzare - I wonder, does touching them do anything?

touch ~/.Trashes/fileordir
rm -rf ~/.Trashes/fileordir

Hunger Moon 05-25-2002 11:34 AM

Bizarre indeed. I wish touch was the answer, but I already tried that. I get the response "no match". They are long filenames because they were mp3s brought from another machine:

[localhost:.Trash/PeterMaffay/Live] root# ls
Peter Maffay - Live Lange Schatten Tour 88 - 02. W??????-1.mp3
Peter Maffay - Live Lange Schatten Tour 88 - 02. W??????.mp3

I think the problem is partly that they originally had German characters in the filename - the "W??????" bit was originally "Wölfe". Basically the only command I've found that works on them is ls. ls -l says "no such file". I can't mv elsewhere. I can open them with vi and edit but not save them. I've never been in the situation where root was unable to remove files recursively. Curiouser and curiouser.

osxpez 05-25-2002 12:40 PM

What happens if you tab-complete one of the files? I don't think the ??? signs really are part of the name. It's just ls's way of displaying them. ö is often represented as \314\210 or some such. But when listed with ls it's shown as ??. It could be that your shell can tab-complete the filenames for you and that then you can rm them. Try with different shells, like tcsh, zsh and bash. I think that zsh could be the best bet.

Hunger Moon 05-25-2002 01:27 PM

Nope, that doesn't work :(

Tab complete shows exactly what you suggest, and I have previously tried this. Switching to zsh appears that it's going to allow deletion of the files. but the suckers are still there afterwards.

mervTormel 05-25-2002 01:42 PM

assuming that the files are named Psomething<funnyChars>something ...

what does

root# rm -i P*

accomplish?

not that this has nothing to do with permissions or root, but the squirrely chars to BSD. not too long ago, BSD had this sort of trouble with just spaces in a file name.

[edit: root powers necessary]

osxpez 05-25-2002 02:06 PM

Truly curious. I too created a file named "Peter Maffay - Live Lange Schatten Tour 88 - 02. Wölfe-1.mp3" and had no problems stat:ing it. It lists (using bash and ls) as "Peter Maffay - Live Lange Schatten Tour 88 - 02. W??lfe-1.mp3" which is more like expected than your filenames. I begun with thinking it had to do with the file names, but I'm open for other causes now... Since you can't stat the files I guess you can't find out who's owning them? I know that some system calls demand that you own the file you are dealing with. Maybe you have a guess who the owner might be and then you could maybe try to tab-complete-delete them with zsh as that user?

Hunger Moon 05-25-2002 03:08 PM

rm -i P* achieves nothing:

root# rm -i P*
rm: No match.

As for ownership, with the two parent directories owned by myself (the user snc) I'm assuming the files are too. Nonetheless if I switch user from root it doesn't help with rm-tab-complete:

snc% rm Peter\ Maffay\ -\ Live\ Lange\ Schatten\ Tour\ 88\ -\ 02.\ W??-1.mp3
rm: Peter Maffay - Live Lange Schatten Tour 88 - 02. W??-1.mp3: No such file or directory
snc% rm Peter\ Maffay\ -\ Live\ Lange\ Schatten\ Tour\ 88\ -\ 02.\ W??.mp3
rm: Peter Maffay - Live Lange Schatten Tour 88 - 02. W??.mp3: No such file or directory
snc% rm -i Peter\ Maffay\ -\ Live\ Lange\ Schatten\ Tour\ 88\ -\ 02.\ W??.mp3
rm: Peter Maffay - Live Lange Schatten Tour 88 - 02. W??.mp3: No such file or directory
snc% rm -f Peter\ Maffay\ -\ Live\ Lange\ Schatten\ Tour\ 88\ -\ 02.\ W??.mp3
snc% ls
Peter Maffay - Live Lange Schatten Tour 88 - 02. W??????-1.mp3
Peter Maffay - Live Lange Schatten Tour 88 - 02. W??????.mp3

mervTormel 05-25-2002 03:18 PM

it's the combination of spaces and squirrely chars.

remove the parent dir with extreme prejudice...

root# rm -rf /path/to/dir

if they're in /.Trashes ...

root# rm -rf /.Trashes

if they're on another volume ...

root# rm -rf /Volumes/<volname>/.Trashes


you get the idea.

Hunger Moon 05-25-2002 05:49 PM

No, that's not it. If it were that simple I would never have needed to post the problem, unfortunately. Almost my first action was to try terminating the parent directory with extreme prejudice. I get this response, hence the problem:

[localhost:~snc/.Trash] root# rm -rf PeterMaffay/
rm: PeterMaffay/Live: Directory not empty
rm: PeterMaffay: Directory not empty

The occurs when trying to nuke the .Trash directory. That's the root of why I am so stumped.

AKcrab 05-25-2002 06:03 PM

What about booting into OS 9, and deleting the files there?

Hunger Moon 05-25-2002 06:42 PM

Can't - I have no OS 9 stuff installed.

mervTormel 05-25-2002 07:27 PM

would you try the following? :
Code:

% /bin/ls -aiv1R  ~/.Trash/

658890 .
 21308 ..
659944 qw ö ö é foo.txt

is there anything in /lost+found ?

have you rebooted to single-user mode and fsck'd that volume?

Hunger Moon 05-25-2002 08:22 PM

root# /bin/ls -aivlR .Trash/
total 0
108026 drwx------ 3 snc staff 58 May 26 01:10 .
22703 drwxr-xr-x 27 snc staff 874 May 25 01:14 ..
88450 drwxrwxrwx 3 snc admin 58 May 25 16:32 PeterMaffay

.Trash//PeterMaffay:
total 0
88450 drwxrwxrwx 3 snc admin 58 May 25 16:32 .
108026 drwx------ 3 snc staff 58 May 26 01:10 ..
88451 drwxrwxrwx 4 snc admin 92 May 25 02:46 Live

.Trash//PeterMaffay/Live:
/bin/ls: Peter Maffay - Live Lange Schatten Tour 88 - 02. W??-1.mp3: No such file or directory
/bin/ls: Peter Maffay - Live Lange Schatten Tour 88 - 02. W??.mp3: No such file or directory
total 0
88451 drwxrwxrwx 4 snc admin 92 May 25 02:46 .
88450 drwxrwxrwx 3 snc admin 58 May 25 16:32 ..

I've rebooted to single-user mode and run fsck -y. It fixed the filesystem (there was an error claiming an invalid leaf node number (or something similar - I've forgotten already). Still can't blow the files away though as I get the old "no such file" message. In single-user mode it tells me the files and directories are read-only, even though ls -l shows the directories as drwxrwxrwx.

Hunger Moon 05-25-2002 08:27 PM

oh, and I have no /lost+found ....

mervTormel 05-25-2002 08:53 PM

Quote:

In single-user mode it tells me the files and directories are read-only, even though ls -l shows the directories as drwxrwxrwx.
in single-user mode, the volume is mounted read-only by default, so i suspect that file mode trickles down to anything you look at.

thanks for the lost+found report. i was going to ask for it again.

that /bin/ls command that i requested? the switch is a "one" not an "ell" .

could you try it again? ls -ivR -1 (one) .../Live/

and then i'll only need to see the interesting files. sorry about that vaguery.

these fellers are really stubborn and i suspect they've got a control char in that spot after the "02. W" that doesn't expand in tabbed completion mode. some control char that has no business being in a filename, like backspace or something that alters the name of the file before interpretation.

i would really like to get the magic incantation to constuct the filename that rm is going to pay attention to, but i suspect this is aggravating to you, so you let us know if you want us to keep monkeying.

btw, do you have fink installed? there are some switches in GNU's ls command that could help grok those files.

mervTormel 05-25-2002 09:03 PM

here's the output i'm looking for...
Code:

$ /bin/ls -ivR -1 foob/
660056 qw ö ö é foo copy 1.txt
660039 qw ö ö é foo copy.txt

i made some accent chars in some filenames and the -v switch is supposed to show them.

Hunger Moon 05-25-2002 09:24 PM

OK, here goes, unfortunately it doesn't give anything we didn't get before:

root# /bin/ls -ivR -1 Live/
/bin/ls: Peter Maffay - Live Lange Schatten Tour 88 - 02. W??-1.mp3: No such file or directory
/bin/ls: Peter Maffay - Live Lange Schatten Tour 88 - 02. W??.mp3: No such file or directory

I'm very happy to keep monkeying around because what's aggravating is I really want to know what's causing this, and I want an empty Trash can without reinstalling the machine.

No, I don't have fink installed.

mervTormel 05-25-2002 09:32 PM

okay, then, what does:
Code:

% echo Live/*
Live/qw ö ö é foo copy 1.txt Live/qw ö ö é foo copy.txt

get us?

would you be willing to install a binary GNU ls if i sent it to you?

[edit: consistancy of ls dir/*]

Hunger Moon 05-25-2002 09:51 PM

root# echo Live/*
echo: No match.

Yeah, sure I'll install that. Send it on over.

Hunger Moon 05-25-2002 10:30 PM

oh, and I have no /lost+found ....

mervTormel 05-25-2002 10:30 PM

if you would email me your email address, i will send you a gzip'd GNU ls

see Author Info: below

also, include your PATH variable, like so:

# echo $PATH
/Users/merv/bin:/sw/bin:/sw/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

i take it you're running the tcsh shell?

WillyT 05-25-2002 11:25 PM

which rm
 
Hunger Moon

Do you have an old fink installation. At one time a slightly broken rm was included in one of the file utilities packages.

so try:
Code:

[darwin:~] williamt% which rm
/bin/rm

if it comes back anything other than /bin/rm then you have the broken one biteing you.

Willy

stetner 05-25-2002 11:36 PM

Looks to me like the files have been removed, but the directory entries still exist. Obviously this should not happen.

I would do the 9 boot to remove them (even if you have to boot from CD into 9).

mrdandy 06-01-2002 03:32 AM

just for the record, I had the same problem with some Bjork MP3s, I think it has something to do with that dotted "o" when combined with coming over from a PC.

In any case, I got rid of the files by booting into OS9 and deleting them, though I think that was already suggested here....

mervTormel 06-01-2002 03:52 AM

thanks, mrdandy. we're looking for a command line solution. one should be able to create, move, and delete these file names in the shell.

stetner (hi doug); another user has reported this issue with files not yet in the trash. it's one of those 8-bit chars that changes the name of the file when its referenced. or it's a bugaboo in the core brainpan.

think maybe an applescript could create a funky filename that shell would choke on? that's my approach, tho i'm loathe to do anything in AS (too cobol for me).

this hinkyness will, most likely, be less of an issue in jaguar.

stetner 06-01-2002 10:25 AM

Ok, lets break out the compiler and see what we can find 8-)
Code:

% cat dir_read.c
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>

int main(int argc, const char * argv[])
{   

    int i;
    char *c;
    DIR *dirp;
    struct dirent *dp;

    dirp = opendir(argv[1]);
    if (dirp)
    {
        while ((dp = readdir(dirp)) != NULL)
        {
                printf("good readdir\n");
                printf("d_fileno %d\n", (int) dp->d_fileno);
                printf("d_reclen %d\n", (int)dp->d_reclen);
                printf("d_type %d\n", dp->d_type);
                printf("d_namlen %d\n", dp->d_namlen);

                c = dp->d_name;
                for ( i = 0; i < dp->d_namlen; i++ ,c++ )
                {
                        printf( "char %d - as a num - %d  as a char %c\n", i, (int)*c, *c );
                }
                printf( "%s\n" , dp->d_name);
                printf("======================\n");
        }
    (void)closedir(dirp);
    }
}

If you put the above code into a file called dir_read.c and type
Code:

cc -o dir_read dir_read.c
you will get an executable which will give output like (when passed a directory name, '.' in this case)
Code:

% ll
total 0
drwx------    4 stetner  staff          92 Jun  2 00:05 ./
drwxr-xr-x  79 stetner  staff        2642 Jun  2 00:02 ../
-rw-------    1 stetner  staff          0 Jun  2 00:04 a?b
-rw-------    1 stetner  staff          0 Jun  1 23:13 b

% ../dir_read .
good readdir
d_fileno 866265
d_reclen 12
d_type 4
d_namlen 1
char 0 - as a num - 46  as a char .
.
======================
good readdir
d_fileno 35922
d_reclen 12
d_type 4
d_namlen 2
char 0 - as a num - 46  as a char .
char 1 - as a num - 46  as a char .
..
======================
good readdir
d_fileno 866395
d_reclen 12
d_type 8
d_namlen 3
char 0 - as a num - 97  as a char a
char 1 - as a num - 127  as a char 
char 2 - as a num - 98  as a char b
ab
======================
good readdir
d_fileno 866266
d_reclen 12
d_type 8
d_namlen 1
char 0 - as a num - 98  as a char b
b
======================

So maybe that can shed some light on what is happening. Of course this may just crash if the readdir call dies, but maybe it will show something usefull. The 'fileno' is actually the inode number, and worst case, 'clri' could be used to blow away the offending inode and then fsck the disk (ACK, I just remembered that clri doesn't work on HFS+). Anyway, let us know what it spits out..... might be interesting.
Doug


All times are GMT -5. The time now is 06:17 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.