Branch: Tag:

1997-01-29

1997-01-29 04:59:46 by Per Hedbor <ph@opera.com>

1.2

Rev: server/base_server/color.pike:1.3
Rev: server/base_server/config/builders.pike:1.2
Rev: server/base_server/config/describers.pike:1.17
Rev: server/base_server/config/savers.pike:1.3
Rev: server/base_server/configuration.pike:1.11
Rev: server/base_server/http.pike:1.6
Rev: server/base_server/mainconfig.pike:1.30
Rev: server/base_server/module_support.pike:1.8
Rev: server/base_server/newdecode.pike:1.4
Rev: server/base_server/proxyauth.pike:1.2
Rev: server/base_server/read_config.pike:1.7
Rev: server/base_server/roxen.pike:1.32
Rev: server/etc/include/config.h:1.5
Rev: server/etc/include/fifo.pre.pike:1.2
Rev: server/etc/roxen_master.pike:1.18
Rev: server/etc/supports:1.12
Rev: server/languages/swedish.pike:1.6
Rev: server/modules/filesystems/filesystem.pike:1.8
Rev: server/modules/filters/hostredirect.pike:1.6
Rev: server/modules/graphics/graphic_text.pike:1.24
Rev: server/modules/logging/home_logger.pike:1.7
Rev: server/modules/scripting/cgi.pike:1.10
Rev: server/modules/tags/htmlparse.pike:1.21
Rev: server/protocols/ftp.pike:1.5
Rev: server/protocols/gopher.pike:1.4
Rev: server/protocols/http.pike:1.11
Rev: server/protocols/ssl.pike:1.5
Rev: server/protocols/ssleay.pike:1.4

3:   // This is a virtual "file-system".   // It will be located somewhere in the name-space of the server.   // Also inherited by some of the other filesystems. - string cvs_version = "$Id: filesystem.pike,v 1.7 1997/01/26 23:56:47 per Exp $"; + string cvs_version = "$Id: filesystem.pike,v 1.8 1997/01/29 04:59:40 per Exp $";   #include <module.h> -  + #include <stat.h>      #if DEBUG_LEVEL > 20   # ifndef FILESYSTEM_DEBUG
76:    "Only allow authenticated users to use methods other than "    "GET and POST. If unset, this filesystem will be a _very_ "    "public one (anyone can edit files located on it)"); +  +  defvar("stat_cache", 1, "Cache the results of stat(2)", +  TYPE_FLAG, +  "This can speed up the retrieval of files up to 60/70% if you" +  " use NFS, but it does use some memory.");   }      
91:   }      string path; + int stat_cache;      void start()   {    path = QUERY(searchpath); -  +  stat_cache = QUERY(stat_cache);   #ifdef FILESYSTEM_DEBUG    perror("FILESYSTEM: Online at "+QUERY(mountpoint)+" (path="+path+")\n");   #endif
108:      mixed stat_file( mixed f, mixed id )   { +  if(!stat_cache)    return file_stat(path + f); /* No security currently in this function */ -  +  array fs; +  if(!id->pragma["no-cache"]&&(fs=cache_lookup("stat_cache",path+f))) +  return fs; +  fs = file_stat(path+f); +  cache_set("stat_cache",path+f,fs); +  return fs;   }      string real_file( mixed f, mixed id )
126:    return 1;   }    -  +    array find_dir( string f, object id )   {    mixed ret;
143:    return 0;    }    -  +     // Access to this dir is not allowed.    if(sizeof(dir & ({".nodiraccess",".www_not_browsable",".nodir_access"})))    {
183:    done_with_put( id );   }    + int _file_size(string X,object id) + { +  array fs; +  if(!id->pragma["no-cache"]&&(fs=cache_lookup("stat_cache",(X)))) +  { +  id->misc->stat = fs; +  return fs[ST_SIZE]; +  } +  if(fs = file_stat(X)) +  { +  id->misc->stat = fs; +  cache_set("stat_cache",(X),fs); +  return fs[ST_SIZE]; +  } +  return -1; + } +  + #define FILE_SIZE(X) (stat_cache?_file_size((X),id):file_size(X)) +    mixed find_file( string f, object id )   {    object o;
191: Inside #if defined(FILESYSTEM_DEBUG)
  #ifdef FILESYSTEM_DEBUG    perror("FILESYSTEM: Request for "+f+"\n");   #endif +  size = FILE_SIZE( f = path + f );    -  size = file_size( f = path + f ); -  +     switch(id->method)    {    case "GET":