How can we implement undelete functionality in Minix?.
This is a linux questions list not a minix questions list. But since linux was started as a project to improve minix I will try to answer your question...except to do so for linux (answers may also apply to minix "mutatis mutandi").
The above question can be understood in many ways:
- Can one use a file system with undelete features under linux?
- Does the minix file system have some mechanism which one can use to undelete a file?
- Is there a way to change the minix file system so that it supports an "undelete" system call?
Essentially the answer to all three questions is "yes but beware".
A. The answer to the first question is to use a file system which supports undeletion and that can be used with user-level tools under minix (without "mount"ing) such as "mtools" for MS Dos systems. The newer ext2fs also has undelete features which can be used with e2tools.
B. The minix file system (like early versions of ext2) does not support the retention of the indirect block data upon file deletion. This means that files beyond a certain size cannot not be restored. Smaller files can be recovered using debugfs.
C. Of course, it is possible to improve the minix file system in many ways---for example see "ext2fs". More seriously, if you want to implement undeletion for minixfs, it should be possible to back-port (from the recent ext2fs) the changes made to the deletion mechanism in order to retain the indirect block data (as far as I recall minixfs anyway does not support multiple indirection levels). Unfortunately, even though minix is "micro-kernel" and so supposedly modular in design, it is far more difficult to do the necessary testing under minix than to do the same testing under linux!
However, note that:
Most *nix editors edit a file "in-place" which means that the allocated blocks are over-written. This means that no file deletion actually takes place when the editing is done and so no undeletion is possible.
In any file system, if the de-allocated blocks are used by another file (for example because disk space is in short supply), then the file cannot be recovered.
Since linux (and minix) are multi-user and multi-tasking many more files are opened, read and written than those for which such an action is explicitly requested by the user. This worsens the problem (II) above.
Overall, one is better off using some form of file versioning as a way to prevent "accidental" deletion under *nix---and of course, there are very many different "backup" tools.
In case this question came out a course on Minix (either self-taught or with a professor :)) please note that it is probably better to learn with Linux nowadays. "The Linux Kernel" by Rusling is a good place to start (it is available online from The Linux Documentation Project).