head	1.13;
access;
symbols
	release_4_2:1.13
	aix_ok:1.11;
locks; strict;
comment	@ * @;


1.13
date	94.06.16.03.23.06;	author aoki;	state Exp;
branches;
next	1.12;

1.12
date	93.11.03.02.29.26;	author aoki;	state Exp;
branches;
next	1.11;

1.11
date	93.06.24.03.56.20;	author aoki;	state Exp;
branches;
next	1.10;

1.10
date	92.07.08.07.11.15;	author joey;	state Exp;
branches;
next	1.9;

1.9
date	92.02.28.02.31.49;	author mao;	state Exp;
branches;
next	1.8;

1.8
date	92.01.21.13.16.20;	author clarsen;	state Exp;
branches;
next	1.7;

1.7
date	92.01.17.04.35.08;	author clarsen;	state Exp;
branches;
next	1.6;

1.6
date	91.12.15.00.49.46;	author glass;	state Exp;
branches;
next	1.5;

1.5
date	91.12.03.19.31.19;	author clarsen;	state Exp;
branches;
next	1.4;

1.4
date	91.11.20.14.32.11;	author clarsen;	state Exp;
branches;
next	1.3;

1.3
date	91.11.20.13.53.58;	author clarsen;	state Exp;
branches;
next	1.2;

1.2
date	91.11.20.09.52.37;	author clarsen;	state Exp;
branches;
next	1.1;

1.1
date	91.11.18.16.53.41;	author clarsen;	state Exp;
branches;
next	;


desc
@baseline -- postgres fs additions
@


1.13
log
@SEEK_SET
fix for d_namlen
hack for struct stat st_?time problems
@
text
@/* ----------------------------------------------------------------
 *   FILE
 *	libpq-fs.h
 *
 *   DESCRIPTION
 *	definitions for using Inversion file system routines
 *
 *   NOTES
 *
 *   IDENTIFICATION
 *	$Header: /import/faerie/faerie/aoki/postgres/src/backend/tmp/RCS/libpq-fs.h,v 1.12 1993/11/03 02:29:26 aoki Exp aoki $
 * ----------------------------------------------------------------
 */

#ifndef libpq_fs_H
#define libpq_fs_H

#include "tmp/simplelists.h"
#include <sys/file.h>
#include <sys/stat.h>

#include <fcntl.h>		/* for O_ on some */

#include <unistd.h>		/* for SEEK_ on most */
#ifndef SEEK_SET
#include <stdio.h>		/* for SEEK_ on others */
#endif /* SEEK_SET */

/* UNIX compatibility junk.  This should be in all systems' include files,
   but this is not always the case. */

#ifndef MAXNAMLEN
#define MAXNAMLEN 255
#endif /* MAXNAMLEN */

struct pgdirent {
	unsigned long d_ino;
	unsigned short d_namlen;
	char d_name[MAXNAMLEN+1];
};

/*
 * SysV struct dirent doesn't have d_namlen.
 * This counts on d_name being last, which is moderately safe (ha) since 
 * it's the variable-length part of the structure.
 */
#ifdef SYSV_DIRENT
#define	D_NAMLEN(dp) \
	((dp)->d_reclen - offsetof(struct dirent, d_name[0]))
#else /* SYSV_DIRENT */
#define	D_NAMLEN(dp) \
	((dp)->d_namlen)
#endif /* SYSV_DIRENT */

/* for stat(2) */
#ifndef S_IRUSR
/* file modes */

#define S_IRWXU 00700           /* read, write, execute: owner */
#define S_IRUSR 00400           /*  read permission: owner */
#define S_IWUSR 00200           /*  write permission: owner */
#define S_IXUSR 00100           /*  execute permission: owner */

#define S_IRWXG 00070           /* read, write, execute: group */
#define S_IRGRP 00040           /*  read permission: group */
#define S_IWGRP 00020           /*  write permission: group */
#define S_IXGRP 00010           /*  execute permission: group */

#define S_IRWXO 00007           /* read, write, execute: other */
#define S_IROTH 00004           /*  read permission: other */
#define S_IWOTH 00002           /*  write permission: other */
#define S_IXOTH 00001           /*  execute permission: other */

#define _S_IFMT  0170000        /* type of file; sync with S_IFMT */
#define _S_IFBLK 0060000        /* block special; sync with S_IFBLK */
#define _S_IFCHR 0020000        /* character special sync with S_IFCHR */
#define _S_IFDIR 0040000        /* directory; sync with S_IFDIR */
#define _S_IFIFO 0010000        /* FIFO - named pipe; sync with S_IFIFO */
#define _S_IFREG 0100000        /* regular; sync with S_IFREG */

#define S_IFDIR _S_IFDIR
#define S_IFREG _S_IFREG

#define S_ISDIR( mode )         (((mode) & _S_IFMT) == _S_IFDIR)

#endif /* S_IRUSR */

/*
 * Inversion doesn't have links.
 */
#ifndef S_ISLNK
#define S_ISLNK(x) 0
#endif

/*
 *  Flags for inversion file system large objects.  Normally, creat()
 *  takes mode arguments, but we don't use them in inversion, since
 *  you get postgres protections.  Instead, we use the low sixteen bits
 *  of the integer mode argument to store the number of the storage
 *  manager to be used, and the high sixteen bits for flags.
 */

#define INV_SMGRMASK	0x0000ffff
#define	INV_ARCHIVE	0x00010000
#define	INV_WRITE	0x00020000
#define	INV_READ	0x00040000

struct pgstat { /* just the fields we need from stat structure */
    int st_ino;
    int st_mode;
    unsigned int st_size;
    unsigned int st_sizehigh;	/* high order bits */
/* 2^64 == 1.8 x 10^20 bytes */
    int st_uid;
    int st_atime_s;	/* just the seconds */
    int st_mtime_s;	/* since SysV and the new BSD both have */
    int st_ctime_s;	/* usec fields.. */
};

typedef struct Direntry_ {
    struct pgdirent d;
    SLNode Node;
} Direntry;

typedef struct PDIR_ {
    SLList dirlist;
    Direntry *current_entry;
} PDIR;

/* Error values for p_errno */
#define PEPERM           1               /* Not owner */
#define PENOENT          2               /* No such file or directory */
#define PEACCES          13              /* Permission denied */
#define PEEXIST          17              /* File exists */
#define PENOTDIR         20              /* Not a directory*/
#define PEISDIR          21              /* Is a directory */
#define PEINVAL          22              /* Invalid argument */
#define PENAMETOOLONG    63              /* File name too long */
#define PENOTEMPTY       66              /* Directory not empty */
#define PEPGIO           99              /* postgres backend had problems */

/*
 * prototypes for fe-pqufs.c.
 * Automatically generated using mkproto
 */
extern int p_open ARGS((char *fname, int mode));
extern int p_close ARGS((int fd));
extern int p_read ARGS((int fd, char *buf, int len));
extern int p_write ARGS((int fd, char *buf, int len));
extern int p_lseek ARGS((int fd, int offset, int whence));
extern int p_creat ARGS((char *path, int mode, int objtype));
extern int p_tell ARGS((int fd));
extern int p_mkdir ARGS((char *path, int mode));
extern int p_unlink ARGS((char *path));
extern int p_rmdir ARGS((char *path));
extern int p_ferror ARGS((int fd));
extern int p_rename ARGS((char *path, char *pathnew));
extern int p_stat ARGS((char *path, struct pgstat *statbuf));
extern PDIR *p_opendir ARGS((char *path));
extern struct pgdirent *p_readdir ARGS((PDIR *dirp));
extern void p_rewinddir ARGS((PDIR *dirp));
extern int p_telldir ARGS((PDIR *dirp));
extern void p_seekdir ARGS((PDIR *dirp, int pos));
extern int p_closedir ARGS((PDIR *dirp));
extern void p_closedir_free ARGS((PDIR *dirp));
extern int p_chdir ARGS((char *path));
extern char *p_getwd ARGS((char *path));
extern void p_dirflush ARGS((char *path));
extern void p_dirflushparent ARGS((char *path));
extern void PQufs_init ARGS((void));

#endif /* libpq_fs_H */
@


1.12
log
@missing SEEK_
@
text
@d11 1
a11 1
 *	$Header: /import/faerie/aoki/postgres/src/backend/tmp/RCS/libpq-fs.h,v 1.13 1993/11/03 02:11:46 aoki Exp aoki $
d22 8
a29 1
/* UNIX compatibility junk.  This should be in all system''s include files,
d42 12
a53 7
/* for lseek(2) */
#ifndef SEEK_SET
/* these normally come from <stdio.h> or <unistd.h> */
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#endif /* SEEK_SET */
d115 3
a117 3
    int st_atime;
    int st_mtime;
    int st_ctime;
@


1.11
log
@made MAXNAMLEN conditional on its non-existence :-)
added S_ISLNK here as 0 if not already defined
(Inversion doesn't use links anyway, so...)
@
text
@d1 13
a13 1
/* $Header: /usr/local/devel/postgres/src/backend/tmp/RCS/libpq-fs.h,v 1.10 1992/07/08 07:11:15 joey Exp $ */
d37 1
d39 2
d130 29
a158 19
int p_open ARGS((char *fname , int mode ));
int p_close ARGS((int fd ));
int p_read ARGS((int fd , char *buf , int len ));
int p_write ARGS((int fd , char *buf , int len ));
int p_lseek ARGS((int fd , int offset , int whence ));
int p_creat ARGS((char *path , int mode, int objtype ));
int p_tell ARGS((int fd ));
int p_mkdir ARGS((char *path , int mode ));
int p_unlink ARGS((char *path ));
int p_rmdir ARGS((char *path ));
int p_ferror ARGS((int fd ));
int p_rename ARGS((char *path , char *pathnew ));
int p_stat ARGS((char *path , struct pgstat *statbuf ));
PDIR *p_opendir ARGS((char *path ));
struct pgdirent *p_readdir ARGS((PDIR *dirp ));
void p_rewinddir ARGS((PDIR *dirp ));
int p_closedir ARGS((PDIR *dirp ));
int p_chdir ARGS((char *path ));
char *p_getwd ARGS((char *path ));
@


1.10
log
@add header
@
text
@d1 1
a1 1
/* $Header$ */
d8 1
d13 1
d15 2
d26 1
a26 1
#endif
d29 1
a29 1
#ifndef S_IRUSR /* this not defined means rest are probably not defined */
a53 2
#undef S_IFDIR
#undef S_IFREG
d59 7
d135 1
a135 1
#endif
@


1.9
log
@interface changes for inversion file system
@
text
@d1 2
@


1.8
log
@protofix
@
text
@d57 13
@


1.7
log
@add error values, 64bit file lengths and inode # to pgstat
@
text
@d48 2
d96 1
a96 1
int p_creat ARGS((char *path , int mode ));
@


1.6
log
@fixed prototype bug
@
text
@d56 1
d58 3
a60 1
    int st_size;
d62 3
d76 12
@


1.5
log
@change stat to pgstat + compat. functions
@
text
@d83 1
a83 1
int p_stat ARGS((char *path , struct stat *statbuf ));
@


1.4
log
@stubs for unix dep. structures.
@
text
@d25 1
d40 13
d55 4
a58 7
/* Temp workaround until we make unix stuff compile under all oses */
struct stat {
	int st_mode;
	int b;
	int c;
	int d;
	int e;
@


1.3
log
@unix compat changes
@
text
@d10 7
d41 8
a49 1

d51 1
a51 1
    struct dirent d;
d74 1
a74 1
struct dirent *p_readdir ARGS((PDIR *dirp ));
@


1.2
log
@remove OS dependent unixisms
@
text
@d5 1
a5 10
/* open(2) compatibility */
#define O_RDONLY        0               /* +1 == FREAD */
#define O_WRONLY        1               /* +1 == FWRITE */
#define O_RDWR          2               /* +1 == FREAD|FWRITE */
#define O_APPEND        _FAPPEND
#define O_CREAT         _FCREAT
#define O_TRUNC         _FTRUNC
#define _FAPPEND        0x0008  /* append (writes guaranteed at the end) */
#define _FCREAT         0x0200  /* open with file create */
#define _FTRUNC         0x0400  /* open with truncation */
d7 28
a34 8
struct  dirent {
        off_t           d_off;          /* offset of next disk dir entry */
        unsigned long   d_fileno;       /* file number of entry */
        unsigned short  d_reclen;       /* length of this record */
        unsigned short  d_namlen;       /* length of string in d_name */
        char            d_name[255+1];  /* name (up to MAXNAMLEN + 1) */
};
#define d_ino d_fileno          /* this is meaningless */
@


1.1
log
@Initial revision
@
text
@a3 1
#include <dirent.h>
d5 19
@
