[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "losing" a file in the ext2 file-system
At 03:57 PM 7/15/97 +0300, Amos Shapira wrote:
>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).
>
Well, OK, so every I-node holds its own permissions and stuff.
Nevertheless, it does my question is still relevant.
>> 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.
>
Yes, that's possible.
>> 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?)
>
My mistake, I meant hard links. (even, I'm not _that_ stupid.)
>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").
>
Well, I suppose that cat (1) and echo (1) check (!) to see if the file is a
directory and if it is print an error message to stderr. However, since
joe(1) from some reason does not do it when it reads the filename, it may
also allow it for writing. (after all, the owner user and group of the
directory cannot be changed with write(2), since they are not part of its
contents.)
Shlomi Fish
-----------------------------------------------------------------------------
Shlomi Fish Smart Link Ltd.
Home E-mail: shlomif@ibm.net Work E-mail: shlomi@slink.co.il
Home Page: http://www.slink.co.il/~shlomi
"Had I not been already insane, I would have long ago driven myself mad."
The Enemy and how I Helped to Fight it.
-----------------------------------------------------------------------------
Follow-Ups:
References: