| 54 | /* |
| 55 | * The garbage collection mechanism is based on "stamps". |
| 56 | * |
| 57 | * A stamp is a record that says "I'm a filesystem which is no longer in |
| 58 | * use. Free me when you get a chance." |
| 59 | * |
| 60 | * This file contains a set of functions used for managing this stamp. You |
| 61 | * should use them when you write your own filesystem. Here are some rules |
| 62 | * of thumb: |
| 63 | * |
| 64 | * (1) When the last open file in your filesystem gets closed, conditionally |
| 65 | * create a stamp. You do this with vfs_stamp_create(). (The meaning |
| 66 | * of "conditionaly" is explained below.) |
| 67 | * |
| 68 | * (2) When a file in your filesystem is opened, delete the stamp. You do |
| 69 | * this with vfs_rmstamp(). |
| 70 | * |
| 71 | * (3) When a path inside your filesystem is invoked, call vfs_stamp() to |
| 72 | * postpone the free'ing of your filesystem a bit. (This simply updates |
| 73 | * a timestamp variable inside the stamp.) |
| 74 | * |
| 75 | * Additionally, when a user navigates to a new directory in a panel (or a |
| 76 | * programmer uses mc_chdir()), a stamp is conditionally created for the |
| 77 | * previous directory's filesystem. This ensures that that filesystem is |
| 78 | * free'ed. (see: _do_panel_cd() -> vfs_release_path(); mc_chdir()). |
| 79 | * |
| 80 | * We've spoken here of "conditionally creating" a stamp. What we mean is |
| 81 | * that vfs_stamp_create() is to be used: this function creates a stamp |
| 82 | * only if no directories are open (aka "active") in your filesystem. (If |
| 83 | * there _are_ directories open, it means that the filesystem is in use, in |
| 84 | * which case we don't want to free it.) |
| 85 | */ |
| 86 | |