[comp.unix.wizards] Removing erroneous directory entries: help needed

aponty@gpu.utcs.utoronto.ca (Adele Ponty) (05/09/91)

One of the users on our system managed to create an entry
in one of our user_data directories that appears at the top
of the directory listing as,  -k@  .  A long listing reveals 
it to be some sort of link they attempted to create;
l---------  -k@   ...  ...  -k@ -> df
I don't know how they managed this but can someone tell me how
to get rid of it?  I have a feeling that I may see more of these.
Thanks.
-- 
                                                 ==== ==M= 
 INTERNET:  aponty@gpu.utcs.utoronto.ca          ==== ==i=
     UUCP:  wheaties@intacc.uucp         (bbs)   ==== ==n=
            aponty@agora.rain.com  (alternate)   =======g=

urban@cbnewsl.att.com (john.urban) (05/09/91)

In article <1991May9.022627.8139@gpu.utcs.utoronto.ca> aponty@gpu.utcs.utoronto.ca (Adele Ponty) writes:
>One of the users on our system managed to create an entry
>in one of our user_data directories that appears at the top
>of the directory listing as,  -k@  .  A long listing reveals 
>it to be some sort of link they attempted to create;
>l---------  -k@   ...  ...  -k@ -> df
>I don't know how they managed this but can someone tell me how
>to get rid of it?  I have a feeling that I may see more of these.
>Thanks.
>-- 
>                                                 ==== ==M= 
> INTERNET:  aponty@gpu.utcs.utoronto.ca          ==== ==i=
>     UUCP:  wheaties@intacc.uucp         (bbs)   ==== ==n=
>            aponty@agora.rain.com  (alternate)   =======g=


See the answer I just posted in comp.unix.questions.  Next time if you're
going to post the same question to mulitple newsgroups, PLEASE specify
all the groups on the Newsgroups line.  i.e.:

Newsgroups: comp.unix.questions,comp.unix.wizards

Basically do: rm - -k\@
See comp.unix.questions for all the details.

Sincerely,

John Ben Urban
att!attunix!jbu

henderso@mpr.ca (Mark Henderson) (05/13/91)

In article <1991May9.022627.8139@gpu.utcs.utoronto.ca> aponty@gpu.utcs.utoronto.ca (Adele Ponty) writes:
>One of the users on our system managed to create an entry
>in one of our user_data directories that appears at the top
>of the directory listing as,  -k@  .  A long listing reveals 
>it to be some sort of link they attempted to create;
>l---------  -k@   ...  ...  -k@ -> df
>I don't know how they managed this but can someone tell me how
>to get rid of it?  I have a feeling that I may see more of these.
>Thanks.
>-- 
>                                                 ==== ==M= 
> INTERNET:  aponty@gpu.utcs.utoronto.ca          ==== ==i=
>     UUCP:  wheaties@intacc.uucp         (bbs)   ==== ==n=
>            aponty@agora.rain.com  (alternate)   =======g=

Use ls -i to find out the inode number of the file/link and then either
use
find . -inum xxxx -exec rm '{}' \;
or the following short program to delete the file.

/*
 * remove a file at a given inode number in the current directory usage: rm
 * <inode_number> useful for getting rid of files with strange names. Safer
 * than clri and can be run without being root.
 * Very simple-minded, but useful.
 * Usage:
 *	irm <inode-number>
 * The inode number can be obtained by using ls -i
 * So to get rid of file *****.???'\^C^D^Z
 * cd into the directory containing the file.
 * Do an ls -i and find the inode number of the file 
 * (say 30240) then type
 * irm 30240
 *
 * Mark Henderson - Tektronix, Inc.
 * 
 * BSD43 is for VAX BSD 4.3 (do not use BSD43 for SUN OS 4.0+) Tested under SUN
 * OS 4.0 and VAX BSD 4.3. Is BSD43 is not specified compiles for SUN OS 4.0/4.1
 */

#include <sys/types.h>
#include <stdio.h>
#ifdef BSD43
#include <sys/dir.h>
#else
#include <dirent.h>
#endif


main(argc, argv)
	int             argc;
	char           *argv[];
{
	ino_t           target;
	DIR            *dirp;
#ifdef BSD43
	struct direct  *dp;
#else
	struct dirent  *dp;
#endif
	if (argc != 2) {
		printf("\nusage irm <int>\n");
		exit(1);
	}
	target = atol(argv[1]);
	dirp = opendir(".");
	for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
		/* printf("%s %ld\n",dp->d_name, dp->d_fileno); */
		if ((dp->d_fileno) == target) {
			printf("\nFOUND: %s\n", dp->d_name);
			closedir(dirp);
			if (!unlink(dp->d_name))
				printf(" deleted\n");
			else
				printf(" delete failed\n");
			exit(0);
		}
	}
	printf("\nNOT FOUND\n");
	closedir(dirp);
}

dcon@cbnewsc.att.com (david.r.connet) (05/14/91)

In article <1991May12.175355.27106@mprgate.mpr.ca> henderso@mpr.ca (Mark Henderson) writes:
>In article <1991May9.022627.8139@gpu.utcs.utoronto.ca> aponty@gpu.utcs.utoronto.ca (Adele Ponty) writes:
>>One of the users on our system managed to create an entry
>>in one of our user_data directories that appears at the top
>>of the directory listing as,  -k@  .  A long listing reveals 
>>it to be some sort of link they attempted to create;
>>l---------  -k@   ...  ...  -k@ -> df
>>I don't know how they managed this but can someone tell me how
>>to get rid of it?  I have a feeling that I may see more of these.
>>Thanks.
>>-- 
>>                                                 ==== ==M= 
>> INTERNET:  aponty@gpu.utcs.utoronto.ca          ==== ==i=
>>     UUCP:  wheaties@intacc.uucp         (bbs)   ==== ==n=
>>            aponty@agora.rain.com  (alternate)   =======g=
>
>Use ls -i to find out the inode number of the file/link and then either
>use
>find . -inum xxxx -exec rm '{}' \;
>or the following short program to delete the file.
[deleted]

Or (sigh) more simply, 'rm -- -k@'.  See the rm man page for other
options (like -i).