[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "losing" a file in the ext2 file-system
Shlomi Fish wrote:
>
> As far as my understanding of the Linux ext2 filesystem (and a UNIX fs in
> general) goes every file has its inode number which exclusively points to
> its content. A directory is simply a file that contains a list of
> filenames, their associated inode numbers, and other info such as
> permissions.
NO! You just showed that you didn't understand what an I-node
is all about. A directory holds ONLY the mapping of file names to
i-nodes, nothing else (ignoring fields required to manage the
directory's space itself). Permissions, as well as everything else
about the file (data blocks location, owner, group, times, NUMBER OF
**HARD** LINKS).
> I noticed that I can use the "joe" editor to edit directories,
joe(1) might let you look into the directory, but you are not
supposed to be able to write to it. I'm not sure about root these
days, but as far as I rember not even root was allowed to write(2)
to a directory.
> and it displays their binary content as if they were regular files.
>
> Now, suppose I use joe to edit a directory and (with the proper knowldege
> and calculations) delete the entry of a file which has no other symbolic
> links, and then "save" it. Will the:
Symbolic links are something completly different. A file does not
know how many or whether at all there are symlinks pointing to it.
(e.g. how is a file residing on an NFS server supposed to know about
a symlink created on one of the NFS clients? What if the client
unmounts the NFS filesystem then removes the symlink?)
Even more so - you can create "dangling" symlinks and nobody would
care.
> 1. kernel ext2 filesystem handler not allow it?
>
> 2. ext2 fs handler remove the file from the inode table?
>
> 3. The file will be stuck in the hard disk, thus occupying space, and not
> easily removeable?
You are not supposed to be able to write(2) to a directory. I don't
have joe to test this, and the editors I do have do not even try
to touch the directory. "cat /tmp" errors with "is a directory" and
so is "echo hhh >! /tmp" (both as "root").
So as far as I can see, your question is totally irrelevant.
--
--Amos Shapira | "Of course Australia was marked for
| glory, for its people had been chosen
amos@gezernet.co.il | by the finest judges in England."
| -- Anonymous
Follow-Ups:
References: