Ticket #3472: 3472-Documentation-for-vfs-gc.c.patch

File 3472-Documentation-for-vfs-gc.c.patch, 2.1 KB (added by mooffie, 7 years ago)
  • lib/vfs/gc.c

    From f97cd80bb41db632280a07b61390f6658a10a267 Mon Sep 17 00:00:00 2001
    From: Mooffie <mooffie@gmail.com>
    Date: Mon, 25 May 2015 20:20:40 +0300
    Subject: [PATCH] Documentation for vfs/gc.c
    
    ---
     lib/vfs/gc.c | 33 +++++++++++++++++++++++++++++++++
     1 file changed, 33 insertions(+)
    
    diff --git a/lib/vfs/gc.c b/lib/vfs/gc.c
    index 52c5f74..0a5d4b6 100644
    a b  
    5151 
    5252#include "gc.h" 
    5353 
     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 
    5487/*** global variables ****************************************************************************/ 
    5588 
    5689int vfs_timeout = 60;           /* VFS timeout in seconds */