Directories which believe they are /dev files

Directories which believe they are /dev files

Post by The Crawford Brunt » Fri, 03 Jul 1998 04:00:00



Here is an interesting one for all you filesystem buffs :-)

I recently experienced a system crash with RH 5.1, resulting in a
semi-trashed ext2 filesystem.  After much learning curve climbing I managed
to fix most of the files which got corrupted by re-installing them from the
relevant RPMs.  

However, one thing which I haven't been able to fix is the fact that some
files believe thay are device files.  For example, doing a ls -l /bin/touch
gives this

crwx-w-r-T      1       63473   46917   237, 149        Nov 20  2035    /bin/touch

and ls -l /home/ftp this

b-wxr-srwx      1       61019   31485   3, 235          Apr 16  1949    /home/ftp

chmod, chattr and chroot don't seem to be able to change these files back
to their correct owners, nor filetypes.  (What exactly is a 'b' or 'c'
file?  And what kind of a permission is 's'?)

Also, I cannot rm/mv/cp over any of these, be I superuser or not.

Any clues on what to do in order to change these files back into their
correct types and owners would be appreciated, or hell, even how to delete
them.  (Bonus points if you can tell me how to get at those files stored
below the /home/ftp directory aswell :-)

Many thanks

David Laing
University of Cape Town

 
 
 

Directories which believe they are /dev files

Post by Clifford Ki » Fri, 03 Jul 1998 04:00:00


There was a response to a post about this sort of thing not long ago
that seemed to provide an answer.  Search DejaNews for "Removing files
from /lost+found".  Basically you should be able to use ls, debugfs and
fsck in this way:

Boot up into single user mode with the disk unmounted (or mounted
read-only if it's the root filesystem).  Then do

ls -i  # to get the inode numbers
debugfs -w  # to clear the inodes - this is interactive
  clri inode_number
  clri ...
  quit
e2fsck -fvy /dev/...  #  to detect and remove the files

The response to the previous post showed how to automate this when there
were numerous files.

BE AWARE that I've not tried this so use it at your own risk.

---


Quote:>Here is an interesting one for all you filesystem buffs :-)
>I recently experienced a system crash with RH 5.1, resulting in a
>semi-trashed ext2 filesystem.  After much learning curve climbing I managed
>to fix most of the files which got corrupted by re-installing them from the
>relevant RPMs.  
>However, one thing which I haven't been able to fix is the fact that some
>files believe thay are device files.  For example, doing a ls -l /bin/touch
>gives this
>crwx-w-r-T  1       63473   46917   237, 149        Nov 20  2035    /bin/touch
>and ls -l /home/ftp this
>b-wxr-srwx  1       61019   31485   3, 235          Apr 16  1949    /home/ftp
>chmod, chattr and chroot don't seem to be able to change these files back
>to their correct owners, nor filetypes.  (What exactly is a 'b' or 'c'
>file?  And what kind of a permission is 's'?)
>Also, I cannot rm/mv/cp over any of these, be I superuser or not.
>Any clues on what to do in order to change these files back into their
>correct types and owners would be appreciated, or hell, even how to delete
>them.  (Bonus points if you can tell me how to get at those files stored
>below the /home/ftp directory aswell :-)
>Many thanks
>David Laing
>University of Cape Town

--
Clifford Kite                                              Not a guru. (tm)


 
 
 

Directories which believe they are /dev files

Post by Elchonon Edelso » Sat, 04 Jul 1998 04:00:00



> Here is an interesting one for all you filesystem buffs :-)

> I recently experienced a system crash with RH 5.1, resulting in a
> semi-trashed ext2 filesystem.  After much learning curve climbing I managed
> to fix most of the files which got corrupted by re-installing them from the
> relevant RPMs.

> However, one thing which I haven't been able to fix is the fact that some
> files believe thay are device files.  For example, doing a ls -l /bin/touch
> gives this

> crwx-w-r-T      1       63473   46917   237, 149        Nov 20  2035    /bin/touch

> and ls -l /home/ftp this

> b-wxr-srwx      1       61019   31485   3, 235          Apr 16  1949    /home/ftp

> chmod, chattr and chroot don't seem to be able to change these files back
> to their correct owners, nor filetypes.  (What exactly is a 'b' or 'c'
> file?  And what kind of a permission is 's'?)

> Also, I cannot rm/mv/cp over any of these, be I superuser or not.

> Any clues on what to do in order to change these files back into their
> correct types and owners would be appreciated, or hell, even how to delete
> them.  (Bonus points if you can tell me how to get at those files stored
> below the /home/ftp directory aswell :-)

'b' and 'c' are Block Special and Character Special devices,
respectively.
's' is the Set?Id permission, being SetUid or setGid depending upon
where.
In this gase, because it is in the group permissions block, it is
SetGid.

You should be able to get change them back using the debugfs or ext2ed
programs. These are programs that allow you to edit a filesystem
structure.

I think that you should be able to correct the type bits to say "file"
and "directory", by comparing the permission bytes with those on a
normal
file and directory. Failing that, You should be able to get the file
back
unlinking them and running fsck again. I THINK that that will result in
the files and directories being relinked into the lost+found directory
for
the device. Hmm. No, scratch that. I don't see how unlinking would
repair
the filetype information, but you should be able to twiddle all the bits
using debugfs or ext2ed.

If you fail to retrieve the files, you should be able to get rid of
them by unlinking and clearing the inode.

Quote:> Many thanks

> David Laing
> University of Cape Town

--

IntelliSoft Corp.       http://isoft.com/
 
 
 

Directories which believe they are /dev files

Post by Loren Co » Sat, 04 Jul 1998 04:00:00




Quote:>Here is an interesting one for all you filesystem buffs :-)

>However, one thing which I haven't been able to fix is the fact that some
>files believe thay are device files.  For example, doing a ls -l /bin/touch
>gives this

>crwx-w-r-T  1       63473   46917   237, 149        Nov 20  2035    /bin/touch
>chmod, chattr and chroot don't seem to be able to change these files back
>to their correct owners, nor filetypes.  (What exactly is a 'b' or 'c'

read the manpage on MAKEDEV.  the -d flag will delete them.

this is strange, so i guess it't also unpredictable.  if you want to
preserve any possible data you might try cat /bin/touch > /tmp/foo.

loren

Quote:>file?  And what kind of a permission is 's'?)

>Also, I cannot rm/mv/cp over any of these, be I superuser or not.

>Any clues on what to do in order to change these files back into their
>correct types and owners would be appreciated, or hell, even how to delete
>them.  (Bonus points if you can tell me how to get at those files stored
>below the /home/ftp directory aswell :-)

>Many thanks

>David Laing
>University of Cape Town