home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / lib / libpq / fsextension < prev    next >
Encoding:
Text File  |  1992-08-27  |  4.2 KB  |  114 lines

  1. /* $Header: /private/postgres/src/lib/libpq/RCS/fsextension,v 1.2 1992/07/08 07:11:38 joey Exp $ */
  2.  
  3. Relevant files:
  4. lib/libpq/be-fsstubs.c        back-end interface wrapper
  5. lib/H/tmp/libpq-fs.h         Constants and datatypes for use in
  6.                 user-level code.
  7. lib/catalog/pg_lobj.c        Relation mapping oids to
  8.                     persistant-cookies.
  9. lib/H/catalog/pg_lobj.h        Constants for object type (Inversion = 0,
  10.                 Unix = 1, etc...)
  11.  
  12. The LOprocs table in be-fsstubs.c is indexed on object type, e.g.
  13. Inversion = 0, Unix = 1, etc.  This is the interface expected of a
  14. large object (lib/libpq/be-fsstubs.c), along with its current
  15. definition.  These functions map pretty much to the Unix semantics.
  16. The large object functions can be oblivious to the catalog code except
  17. for LOcreate.  This routine must make an entry in the pg_naming
  18. relation.  For example, if the persistant-cookie is a variable length
  19. structure called 'newobj' and the pathname provided by the user is
  20. 'path', the code to add it to pg_naming is: (The constant 'Inversion'
  21. would differ depending upon objects.)
  22.  
  23.     /* Log this instance of large object into directory table. */
  24.     {
  25.       oid oidf;
  26.       if ((oidf = FilenameToOID(path)) == InvalidObjectId) { /* new file */
  27.         oidf = LOcreatOID(path,0); /* enter it in system relation */
  28.         /* enter cookie into table */
  29.         if (LOputOIDandLargeObjDesc(oidf, Inversion, (struct varlena *)newobj) < 0) {
  30. #if FSDB
  31.           elog(NOTICE,"LOputOIDandLargeObjDesc failed");
  32. #endif
  33.           }
  34.       }
  35.     }
  36.  
  37. If you are going to store a non-variable cookie, then you have to wrap
  38. it in a varlena structure.  Perhaps some of the information normally
  39. stored in inodes could be stored in the cookie.
  40.  
  41. static struct {
  42.     int bigcookie; 
  43. #define SMALL_INT 0     /* is integer wrapped in a varlena */
  44. #define BIG 1  /* must be passed as varlena*/
  45.     
  46.     void *(*LOcreate) ARGS((char *,int)); /* name,mode -> runtime-cookie */
  47.     void *(*LOopen) ARGS((void *,int)); /* persistant-cookie,mode -> runtime-cookie */
  48.     void (*LOclose) ARGS((void *)); /* runtime-cookie */
  49.     int (*LOread) ARGS((void *,char *,int)); /* rt-cookie,buf,length -> bytecount*/
  50.     int (*LOwrite) ARGS((void *,char *,int)); /*rt-cookie,buf,length -> bytecount*/
  51.     int (*LOseek) ARGS((void *,int,int)); /*rt-cookie,offset,whence -> bytecount */
  52.     int (*LOtell) ARGS((void *)); /*rt-cookie ->bytecount*/
  53.     int (*LOunixstat) ARGS((void *,struct pgstat *)); /* rt-cookie,stat ->errorcode*/
  54. } LOprocs[] = {
  55.     /* Inversion */
  56.     { SMALL_INT,Inversion_Create, Inversion_Open, Inversion_Close, 
  57.         Inversion_Read, Inversion_Write,
  58.     Inversion_Seek, Inversion_Tell, Inversion_UnixStat},
  59.     /* Unix */
  60.     { BIG, LOCreate, LOOpen, LOClose, LORead, LOWrite,
  61.     LOSeek, LOTell, LOUnixStat}
  62. };
  63.  
  64. There is also another table in (lib/catalog/pg_lobj.c) which stores
  65. methods that destroy the object, e.g. remove the unix file or destroy
  66. the relation:
  67.  
  68. static struct {
  69. #define SMALL_INT 0
  70. #define BIG 1
  71.     int bigcookie;
  72.     void (*LOdestroy)ARGS((void *));
  73. } LOprocs[] = {
  74.     /* Inversion */
  75.     { SMALL_INT, noaction }, /* not defined yet, probably destroy class */
  76.     /* Unix */
  77.     { BIG, LODestroyRef }
  78. };
  79.  
  80.  
  81. The persistant-cookies are stored on disk in the directory relation,
  82. so they should probably be small and contain no memory pointers.
  83.  
  84. The runtime-cookies are created upon calling open on an existing
  85. object or creat.
  86.  
  87. =================
  88. Some cosmetics for commands such as 'ls' which list ownership, access
  89. times, file size, etc were added.  They are optional and should not
  90. affect ability to create, read or write files.
  91.  
  92. The LOstat function expects a structure of type 'pgstat' and fills it
  93. with information about the object.  The 'pgstat' structure has the
  94. following definition (lib/H/tmp/libpq-fs.h):
  95.  
  96. struct pgstat {     /* just the fields we need from stat structure */
  97. /* Automatically set.  Object implementor need not worry. */
  98.     int st_ino;        /* Object Id of name in pg_naming relation */
  99.  
  100. /* object dependent accessibility.  Can be rwxrwxrwx for simplicity. */
  101.     int st_mode;
  102.  
  103.     unsigned int st_size;
  104.     unsigned int st_sizehigh;   /* high order bits */
  105. /* 2^64 == 1.8 x 10^20 bytes */
  106.  
  107. /* Ownership and time information */
  108.     int st_uid;
  109.     int st_atime;   
  110.     int st_mtime;
  111.     int st_ctime;
  112. };
  113.  
  114.