Roxen.git / server / modules / filesystems / filesystem.pike

version» Context lines:

Roxen.git/server/modules/filesystems/filesystem.pike:1:   // This is a roxen module. Copyright © 1996 - 1998, Idonex AB.      // 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.      inherit "module";   inherit "roxenlib";   inherit "socket";    - constant cvs_version= "$Id: filesystem.pike,v 1.49 1999/01/14 03:16:59 grubba Exp $"; + constant cvs_version= "$Id: filesystem.pike,v 1.50 1999/04/21 15:42:54 grubba Exp $";   constant thread_safe=1;         #include <module.h>   #include <roxen.h>   #include <stat.h>      #if DEBUG_LEVEL > 20   # ifndef FILESYSTEM_DEBUG   # define FILESYSTEM_DEBUG
Roxen.git/server/modules/filesystems/filesystem.pike:233:    return Array.filter(dir, dir_filter_function);   }         mapping putting = ([]);      void done_with_put( array(object) id )   {   // perror("Done with put.\n");    id[0]->close(); -  id[1]->write("HTTP/1.0 200 Transfer Complete.\r\nContent-Length: 0\r\n\r\n"); +  id[1]->set_blocking(); +  if (putting[id[1]]) { +  // Truncated! +  id[1]->write("400 Bad Request - Expected more data.\r\n" +  "Content-Length: 0\r\n\r\n"); +  } else { +  id[1]->write("HTTP/1.0 200 Transfer Complete.\r\n" +  "Content-Length: 0\r\n\r\n"); +  }    id[1]->close();    m_delete(putting, id[1]);    destruct(id[0]);    destruct(id[1]);   }      void got_put_data( array (object) id, string data )   {   // perror(strlen(data)+" .. "); -  id[0]->write( data ); -  putting[id[1]] -= strlen(data); -  if(putting[id[1]] <= 0) +  // Truncate at end. +  data = data[..putting[id[1]]]; +  +  int bytes = id[0]->write( data ); +  if (bytes < sizeof(data)) { +  // Out of disk! +  id[0]->close(); +  id[1]->set_blocking(); +  id[1]->write("HTTP/1.0 413 Disk full.\r\n" +  "Content-Length: 0\r\n\r\n"); +  id[1]->close(); +  m_delete(putting, id[1]); +  destruct(id[0]); +  destruct(id[1]); +  } else { +  putting[id[1]] -= bytes; +  if(putting[id[1]] <= 0) { +  putting[id[1]] = 0; // Paranoia    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[0];    return fs[0]?fs[0][ST_SIZE]:-1;    }    if(fs = file_stat(X))
Roxen.git/server/modules/filesystems/filesystem.pike:509:       privs = 0;       if(!to)    {    id->misc->error_code = 403;    TRACE_LEAVE("PUT: Open failed");    TRACE_LEAVE("Failure");    return 0;    } +  +  // FIXME: Race-condition.    chmod(f, 0666 & ~(id->misc->umask || 022)); -  +     putting[id->my_fd]=id->misc->len;    if(id->data && strlen(id->data))    {    putting[id->my_fd] -= strlen(id->data);    to->write( id->data );    }    if(!putting[id->my_fd]) {    TRACE_LEAVE("PUT: Just a string");    TRACE_LEAVE("Put: Success");    return http_string_answer("Ok");