implementing recycle bin in minix!!!! - Minix

This is a discussion on implementing recycle bin in minix!!!! - Minix ; Hello, I want to implement recycle bin in minix, so that when a user deletes a file, the file goes to the recycle bin. Later the user can restore the deleted file to its original location. Could anyone tell me ...

+ Reply to Thread
Results 1 to 11 of 11

Thread: implementing recycle bin in minix!!!!

  1. implementing recycle bin in minix!!!!

    Hello,
    I want to implement recycle bin in minix, so that when a user deletes a
    file, the file goes to the recycle bin. Later the user can restore the
    deleted file to its original location. Could anyone tell me how to
    proceed with this? I was able to figure out that, the file system of
    minix has to be modified, and changes have to be made to the
    unlink_file and search_dir functions in the link.c file....Am I goin in
    the right direction???

    Thanks in advance,

    VR


  2. Re: implementing recycle bin in minix!!!!


    VR wrote:
    > Hello,
    > I want to implement recycle bin in minix, so that when a user deletes a
    > file, the file goes to the recycle bin. Later the user can restore the
    > deleted file to its original location. Could anyone tell me how to
    > proceed with this? I was able to figure out that, the file system of
    > minix has to be modified, and changes have to be made to the
    > unlink_file and search_dir functions in the link.c file....Am I goin in
    > the right direction???
    >
    > Thanks in advance,
    >
    > VR


    Hello,

    Why changing minix fs ?
    you can just make a new rm
    For example if you call rm /prog/test.c
    then you will do mv /prog/test.c /.recyle_bin/prog/test.c
    if you call rm in the "recycle bin" then you call the real rm.


  3. Re: implementing recycle bin in minix!!!!


    VR wrote:
    > Hello,
    > I want to implement recycle bin in minix, so that when a user deletes a
    > file, the file goes to the recycle bin. Later the user can restore the
    > deleted file to its original location. Could anyone tell me how to
    > proceed with this? I was able to figure out that, the file system of
    > minix has to be modified, and changes have to be made to the
    > unlink_file and search_dir functions in the link.c file....Am I goin in
    > the right direction???



    OK, think of the implications of your idea before you jump into
    changing code.

    First off, deleting to a "recycle bin" is trivial, but restoring from
    it is not. Consider how you are going to handle the restore of a file
    that
    a) may have multiple versions in the recycle bin, or
    b) some other user owned and deleted, or
    c) was hardlinked to another file (still in existance), or
    d) was hardlinked to another file (deleted to recycle bin), or
    e) was hardlinked to another file (deleted, not in recycle bin), or
    f) was softlinked to another file (still in existance), or
    g) was softlinked to another file (deleted to recycle bin), or
    h) was softlinked to another file (deleted, not in recycle bin)

    Determine what you want to do in each case, along with how you want to
    do it. Remember that Minix is a simultaneous multi-user, multi-process
    operating system, and that different users can each delete (and
    potentially restore) files. You probably want a single user's restore
    to only restore files deleted /by that user/ (except, perhaps, for
    root, who should be able to restore any file). You want the restore to
    correctly restore files /at the path level/ even if directories in that
    path have been deleted.

    The simplest "delete" is just to move the file into a different
    directory. Of course, you have to keep metadata on where the file came
    from, and who deleted it. Since you want to reclaim filespace on the
    "real" delete, just having the file in a different directory might not
    be the easiest solution; you'll probably want to add hooks to do
    something when the link count reaches zero (except for files that are
    the targets of softlinks; you'll have to figure that one out for
    yourself).

    The restore will have to determine the old path and recreate it if
    necessary. It will have to resolve any hardlink and softlink issues,
    and any issues surrounding duplicate file names. It will have to
    provide some isolation between users; user A should not be able to
    restore a file deleted by user B (because that is a security issue);
    perhaps "recycle bin" files should retain the original permissions of
    the file, and (perhaps) the permissions of the directory from which the
    file has been deleted.

    Long time back, I suggested that a "recycle bin" might be implemented
    as a parallel directory to "lost+found", with the directory contents
    managed by the OS and utilities jointly. That suggestion was based on
    the idea of creating hardlinks in a "recyclebin" directory, which only
    works when both the linked file and the linking directory entry reside
    on the same filesystem. The drawback is that this implementation would
    not be user-specific, and extra code would have to implement the
    user-specific management of this recyclebin directory in userspace.

    An alternative is to create as many user-specific recyclebin
    directories as there are users, and manage the user-requirements that
    way. Of course, this complicates the kernel changes that would support
    the delete (and possibly the restore) of the file; now the kernel has
    to determine /which/ recyclebin to record the file deletion in, based
    on the UID (and perhaps the GID?) of the user. What happens if /that/
    recyclebin directory no longer exists? How does the kernel handle that
    contingency? What if user A deletes user B's recycle bin? Where does
    the recyclebin directory go, and who is permitted to restore it?

    These are the sorts of design issues that you'll have to think hard
    about before you jump in and make changes to the kernel code. Resolve
    these first, present your ideas here (or in some other relevant forum),
    and get some opinion on what actions are appropriate. Or, if you choose
    to implement this sort of feature for yourself alone, at least discuss
    the mechanics /after/ you have thought out the design issues.

    HTH
    --
    Lew Pitcher


  4. Re: implementing recycle bin in minix!!!!


    draconix wrote:
    > VR wrote:
    > > Hello,
    > > I want to implement recycle bin in minix, so that when a user deletes a
    > > file, the file goes to the recycle bin. Later the user can restore the
    > > deleted file to its original location. Could anyone tell me how to
    > > proceed with this? I was able to figure out that, the file system of
    > > minix has to be modified, and changes have to be made to the
    > > unlink_file and search_dir functions in the link.c file....Am I goin in
    > > the right direction???
    > >
    > > Thanks in advance,
    > >
    > > VR

    >
    > Hello,
    >
    > Why changing minix fs ?
    > you can just make a new rm
    > For example if you call rm /prog/test.c
    > then you will do mv /prog/test.c /.recyle_bin/prog/test.c
    > if you call rm in the "recycle bin" then you call the real rm.


    Thanks a lot for ur qucik reply....

    Do u mean I have to create a new system call to implement this new
    rm.....I was not able to find the code for rm....though I found the
    code for rmdir in fs in unlink_file function....

    I am still unsure how to proceed....


  5. Re: implementing recycle bin in minix!!!!


    Lew Pitcher wrote:
    > VR wrote:
    > > Hello,
    > > I want to implement recycle bin in minix, so that when a user deletes a

    [snip]
    >
    > Long time back, I suggested that a "recycle bin" might be implemented
    > as a parallel directory to "lost+found", with the directory contents
    > managed by the OS and utilities jointly.


    http://groups.google.ca/group/comp.o...4c2dd64471e0dc

    HTH
    --
    Lew Pitcher


  6. Re: implementing recycle bin in minix!!!!


    Lew Pitcher wrote:
    > VR wrote:
    > > Hello,
    > > I want to implement recycle bin in minix, so that when a user deletes a
    > > file, the file goes to the recycle bin. Later the user can restore the
    > > deleted file to its original location. Could anyone tell me how to
    > > proceed with this? I was able to figure out that, the file system of
    > > minix has to be modified, and changes have to be made to the
    > > unlink_file and search_dir functions in the link.c file....Am I goin in
    > > the right direction???

    >
    >
    > OK, think of the implications of your idea before you jump into
    > changing code.
    >
    > First off, deleting to a "recycle bin" is trivial, but restoring from
    > it is not. Consider how you are going to handle the restore of a file
    > that
    > a) may have multiple versions in the recycle bin, or
    > b) some other user owned and deleted, or
    > c) was hardlinked to another file (still in existance), or
    > d) was hardlinked to another file (deleted to recycle bin), or
    > e) was hardlinked to another file (deleted, not in recycle bin), or
    > f) was softlinked to another file (still in existance), or
    > g) was softlinked to another file (deleted to recycle bin), or
    > h) was softlinked to another file (deleted, not in recycle bin)
    >
    > Determine what you want to do in each case, along with how you want to
    > do it. Remember that Minix is a simultaneous multi-user, multi-process
    > operating system, and that different users can each delete (and
    > potentially restore) files. You probably want a single user's restore
    > to only restore files deleted /by that user/ (except, perhaps, for
    > root, who should be able to restore any file). You want the restore to
    > correctly restore files /at the path level/ even if directories in that
    > path have been deleted.
    >
    > The simplest "delete" is just to move the file into a different
    > directory. Of course, you have to keep metadata on where the file came
    > from, and who deleted it. Since you want to reclaim filespace on the
    > "real" delete, just having the file in a different directory might not
    > be the easiest solution; you'll probably want to add hooks to do
    > something when the link count reaches zero (except for files that are
    > the targets of softlinks; you'll have to figure that one out for
    > yourself).
    >
    > The restore will have to determine the old path and recreate it if
    > necessary. It will have to resolve any hardlink and softlink issues,
    > and any issues surrounding duplicate file names. It will have to
    > provide some isolation between users; user A should not be able to
    > restore a file deleted by user B (because that is a security issue);
    > perhaps "recycle bin" files should retain the original permissions of
    > the file, and (perhaps) the permissions of the directory from which the
    > file has been deleted.
    >
    > Long time back, I suggested that a "recycle bin" might be implemented
    > as a parallel directory to "lost+found", with the directory contents
    > managed by the OS and utilities jointly. That suggestion was based on
    > the idea of creating hardlinks in a "recyclebin" directory, which only
    > works when both the linked file and the linking directory entry reside
    > on the same filesystem. The drawback is that this implementation would
    > not be user-specific, and extra code would have to implement the
    > user-specific management of this recyclebin directory in userspace.
    >
    > An alternative is to create as many user-specific recyclebin
    > directories as there are users, and manage the user-requirements that
    > way. Of course, this complicates the kernel changes that would support
    > the delete (and possibly the restore) of the file; now the kernel has
    > to determine /which/ recyclebin to record the file deletion in, based
    > on the UID (and perhaps the GID?) of the user. What happens if /that/
    > recyclebin directory no longer exists? How does the kernel handle that
    > contingency? What if user A deletes user B's recycle bin? Where does
    > the recyclebin directory go, and who is permitted to restore it?
    >
    > These are the sorts of design issues that you'll have to think hard
    > about before you jump in and make changes to the kernel code. Resolve
    > these first, present your ideas here (or in some other relevant forum),
    > and get some opinion on what actions are appropriate. Or, if you choose
    > to implement this sort of feature for yourself alone, at least discuss
    > the mechanics /after/ you have thought out the design issues.
    >
    > HTH
    > --
    > Lew Pitcher


    thank you very much...I had not thought of all these issues. I just
    want to implement simple delete and restore for a single user....just
    the basic operation: sending the deleted file to recycle bin and
    restore them to their original location( assuming there are no
    duplicate files)..


  7. Re: implementing recycle bin in minix!!!!


    VR wrote:
    > Lew Pitcher wrote:
    > > VR wrote:
    > > > Hello,
    > > > I want to implement recycle bin in minix, so that when a user deletes a
    > > > file, the file goes to the recycle bin. Later the user can restore the
    > > > deleted file to its original location.

    [snip]
    > > OK, think of the implications of your idea before you jump into
    > > changing code.

    [snip]
    >
    > thank you very much...I had not thought of all these issues. I just
    > want to implement simple delete and restore for a single user....just
    > the basic operation: sending the deleted file to recycle bin and
    > restore them to their original location( assuming there are no
    > duplicate files)..


    OK, in that case, you probably should take draconix advice and simply
    make yourself a program to replace /for you/ the rm command. No fudging
    with the kernel necessary, and you don't foul up any other user on your
    system.

    HTH
    --
    Lew Pitcher


  8. Re: implementing recycle bin in minix!!!!


    VR a écrit :

    > Do u mean I have to create a new system call to implement this new
    > rm.....I was not able to find the code for rm....though I found the
    > code for rmdir in fs in unlink_file function....
    >
    > I am still unsure how to proceed....


    I'm not a minix hacker, so I can't help you about rm source code
    location.
    But I think you don't need it.
    Just rename your rm binary to rm_delete for example.

    then create a rm file ( a bash script if you have bash, or if you want
    create it in c)

    for parition /mnt/data you will have /mnt/.recycle_bin/ directrory
    for root partition you will have /.recycle+bin/ directory

    so when if you delete a file (let's say "/mnt/data/dir/file.c" you will
    have to do :
    - find used partition. (in /mnt/data or / ) (here /mnt/data/)
    - find path in this partition (here dir/file.c)
    - move this file (mv /mnt/data/dir/file.c
    /mnt/data/.recycle_bin/dir/file.c
    voila

    the undo command will do the same thing from recycle_bin to real
    directory.

    good luck


  9. Re: implementing recycle bin in minix!!!!

    > > > I want to implement recycle bin in minix, so that when a user deletes
    a
    > > > [...]

    > >
    > > Why changing minix fs ?
    > > you can just make a new rm
    > > [...]

    >
    > Thanks a lot for ur qucik reply....
    >
    > Do u mean I have to create a new system call to implement this new
    > rm.....I was not able to find the code for rm....though I found the
    > code for rmdir in fs in unlink_file function....
    >

    rm is a userspace program. You can replace it with a rm you wrote for
    yourself, preserving the original with a different name (e.g.
    rm.no_recycle_bin). Then you could simply run "rm" if you want to delete a
    file, but if run inside the recycle bin, it should then call the original
    rm.no_recycle_bin (you don't want to move a file from the bin into the same
    bin). That could even be a shell script.

    And taken further, you wouldn't need to change anything in kernel mode,
    neither would you need some changes in the filesystem drivers. Because
    changes there can render your system useless (if you, for example, destroy
    some sectors by mistake instead of only reading them, whatever).

    > I am still unsure how to proceed....


    Simply replacing "rm" is quite easy, you could then create a directory
    /.recyclebin/ and let deleted files be moved there.

    But, as already said, think about the metadata you would need to save (where
    did the file come from, maybe even compress it to save space of deleted
    files) and about the multi-user and multi-tasking things.

    Regards



  10. Re: implementing recycle bin in minix!!!!

    VR wrote:
    > Hello,
    > I want to implement recycle bin in minix, so that when a user deletes a
    > file, the file goes to the recycle bin. Later the user can restore the
    > deleted file to its original location. Could anyone tell me how to
    > proceed with this? I was able to figure out that, the file system of
    > minix has to be modified, and changes have to be made to the
    > unlink_file and search_dir functions in the link.c file....Am I goin in
    > the right direction???
    >
    > Thanks in advance,
    >
    > VR
    >

    Such a feature is useless as a core OS component; this is meant to be
    implemented by the desktop environment. To implement this as a OS
    feature would be a first -- No other modern OS has this feature. Windows
    doesn't. Mac OS X doesn't. Windows Explorer and Finder, the GUI
    *shells*, respectively, implement these. Any system calls on those OSes
    to delete a file happens immediately and the file is deleted
    right-then-and-there, and not moved to a trash folder.

    It's a nice thought, but a rather poor one to implement at the OS level.
    This is something best left to the desktop environment to handle.


    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.1 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFFR8YusjeOFtd+nycRAijkAJ9PQIOYlL2daR2+7j8Yt3 XUVzluNwCfdf45
    +ttCQnqKwmedbGtQpEaTNLk=
    =uXTU
    -----END PGP SIGNATURE-----


  11. Re: implementing recycle bin in minix!!!!

    Segin wrote:
    > Such a feature is useless as a core OS component; this is meant to be
    > implemented by the desktop environment. To implement this as a OS
    > feature would be a first


    It would not be a first. In VMS, the file system allowed you to restore
    a deleted file from a previous version.

    Ben

+ Reply to Thread