[Pvfs2-cvs] commit by walt in pvfs2/src/client/usrint: Makefile README iocommon.c iocommon.h openfile-util.c openfile-util.h posix-pvfs.c posix-pvfs.h posix.c stdio-pvfs.h stdio.c usrint.h

CVS commit program cvs at parl.clemson.edu
Tue Feb 8 16:39:34 EST 2011


Update of /projects/cvsroot/pvfs2/src/client/usrint
In directory parlweb1:/tmp/cvs-serv32608

Added Files:
      Tag: Orange-Branch
	Makefile README iocommon.c iocommon.h openfile-util.c 
	openfile-util.h posix-pvfs.c posix-pvfs.h posix.c stdio-pvfs.h 
	stdio.c usrint.h 
Log Message:

Source files for new OrangeFS user interface



--- /dev/null	2004-06-24 14:04:38.000000000 -0400
+++ Makefile	2011-02-08 16:39:34.000000000 -0500
@@ -0,0 +1,21 @@
+
+PVFSDIR=../../../
+INCDIR=-I. -I$(PVFSDIR)/include
+LIBDIR=
+
+CFLAGS=$(INCDIR) $(LIBDIR)
+
+OBJS=iocommon.o openfile-util.o posix-pvfs.o posix.o stdio.o
+
+INCS=usrint.h iocommon.h stdio-pvfs.h posix-pvfs.h openfile-util.h
+
+all: $(OBJS)
+
+clean: 
+	rm *.o
+
+iocommon.o:$(INCS)
+openfile-util.o:$(INCS)
+posix-pvfs.o:$(INCS)
+posix.o:$(INCS)
+stdio.o:$(INCS)

--- /dev/null	2004-06-24 14:04:38.000000000 -0400
+++ README	2011-02-08 16:39:34.000000000 -0500
@@ -0,0 +1,42 @@
+
+These codes stack up as follows:
+
+stdio
+posix
+posix-pvfs
+iocommon/openfile-util
+libpvfs
+
+posix also calls out to glibc for non-pvfs file systems.
+user code is expected to call in a stdio, posix, and/or posix-pvfs
+
+stdio
+
+This is an actual implementation of stdio based on the joined file
+descriptor/pointer implemented in openfile-util - this is here mostly
+so calls to libc don't bypass our system calls.
+
+posix
+
+These are wrappers that either call the glibc or the pvfs version
+
+posix-pvfs
+
+These implement the system calls for pvfs using the iocommon calls
+
+iocommon
+
+These are based on the codes in the pvfs apps and other implementations
+that access pvfs via the sysint calls
+
+openfile-util
+
+These are data structures used in the stdio/posix implementation.  Mostly
+an open file table and method tables, various other functions and structures
+needed for those implementations
+
+libpvfs
+
+This is the client sysint code - not in this directory
+
+WBL

--- /dev/null	2004-06-24 14:04:38.000000000 -0400
+++ iocommon.c	2011-02-08 16:39:34.000000000 -0500
@@ -0,0 +1,893 @@
+#include <usrint.h>
+
+int init=0;
+
+/* Perform PVFS initialization if not already finished */
+void iocommon_ensure_init()
+{
+
+    /* Initialize the file system with mount points */
+    int ret;
+    if (!init){
+        ret = PVFS_util_init_defaults();
+        assert(ret==PVFS_FD_SUCCESS);
+        init=1;
+    }
+
+}
+
+void iocommon_cred(PVFS_credentials **credentials)
+{
+    static PVFS_credentials creds_buf;
+    static int cred_init = 0;
+
+    if(!cred_init)
+    {
+        memset(&creds_buf, 0, sizeof(creds_buf));
+        creds_buf.uid = getuid();
+        creds_buf.gid = getgid();
+        cred_init = 1;
+    }
+
+    *credentials = &creds_buf;
+}
+
+int iocommon_fsync(pvfs_descriptor *pd)
+{
+    PVFS_credentials *credentials;
+    iocommon_cred(&credentials);
+    return PVFS_sys_flush(pd->pvfs_ref, credentials, PVFS_HINT_NULL);
+}
+
+/*
+ * Find the PVFS handle to an object (file, dir sym) 
+ * assumes an absoluate path
+ */
+int iocommon_lookup_absolute( const char *abs_path, PVFS_object_ref *ref)
+{
+    int rc;
+    char pvfs_path[256];
+    PVFS_fs_id lookup_fs_id;
+
+    /* Determine the fs_id and pvfs_path */
+    rc = PVFS_util_resolve(abs_path, &lookup_fs_id, pvfs_path, 256);
+
+    if (0 == rc)
+    {
+        PVFS_credentials *credentials;
+        PVFS_sysresp_lookup resp_lookup;
+
+        iocommon_cred(&credentials);
+        rc = PVFS_sys_lookup(lookup_fs_id, pvfs_path,
+                             credentials, &resp_lookup,
+                             PVFS2_LOOKUP_LINK_FOLLOW, NULL);
+        *ref = resp_lookup.ref;
+    }
+    else
+    {
+        fprintf(stderr, "Error: No matching fstab entry for %s\n", abs_path);
+    }
+
+    return rc;
+}
+
+/*
+ * Lookup a file via the PVFS system interface
+ */
+int iocommon_lookup_relative(const char *rel_path,
+                             PVFS_object_ref parent_ref, /* by value */
+                             int follow_links,
+                             PVFS_object_ref *ref )
+{
+    int rc;
+    PVFS_credentials *credentials;
+    PVFS_sysresp_lookup resp_lookup;
+
+    /* Set credentials */
+    iocommon_cred(&credentials);
+
+    /* Contact server */
+    rc = PVFS_sys_ref_lookup(parent_ref.fs_id,
+                             (char*)rel_path,
+                             parent_ref,
+                             credentials,
+                             &resp_lookup,
+                             follow_links,
+                             PVFS_HINT_NULL);
+    *ref = resp_lookup.ref;
+
+    return rc;
+}
+
+/*
+ * Create a file via the PVFS system interface
+ */
+int iocommon_create_file( const char *filename,
+                             mode_t file_permission,
+                             PVFS_hint file_creation_param,
+                             PVFS_object_ref parent_ref,
+                             PVFS_object_ref *ref )
+{
+    int rc;
+    mode_t mode_mask;
+    mode_t user_mode;
+    PVFS_sys_attr attributes;
+    PVFS_credentials *credentials;
+    PVFS_sysresp_create resp_create;
+
+    /* Create distribution var */
+    PVFS_sys_dist *dist=NULL;
+
+    /* this is not right - need to pull parameters out of hints */
+    /* investigate PVFS hint mechanism */
+#if 0
+    if (file_creation_param.striping_unit > 0)
+    {
+        dist = PVFS_sys_dist_lookup("simple_stripe");
+        if (PVFS_sys_dist_setparam(dist, "strip_size",
+                                  &(file_creation_param.striping_unit)) < 0)
+        {
+            fprintf(stderr, "Error: failed to set striping_factor\n");
+        }
+    }
+#endif
+
+    /* Set attributes */
+    memset(&attributes, 0, sizeof(attributes));
+    attributes.owner = getuid();
+    attributes.group = getgid();
+    attributes.atime = time(NULL);
+    attributes.mtime = attributes.atime;
+    attributes.ctime = attributes.atime;
+    attributes.mask = PVFS_ATTR_SYS_ALL_SETABLE;
+
+#if 0
+    if (file_creation_param.striping_factor > 0){
+        attributes.dfile_count = file_creation_param.striping_factor;
+        attributes.mask |= PVFS_ATTR_SYS_DFILE_COUNT;
+    }
+#endif
+
+    /* Extract the users umask (and restore it to the original value) */
+    mode_mask = umask(0);
+    umask(mode_mask);
+    user_mode = file_permission & ~mode_mask;
+
+    /* Set file permissions */
+    if (user_mode & S_IXOTH)
+    {
+        attributes.perms |= PVFS_O_EXECUTE;
+    }
+    if (user_mode & S_IWOTH)
+    {
+        attributes.perms |= PVFS_O_WRITE;
+    }
+    if (user_mode & S_IROTH)
+    {
+        attributes.perms |= PVFS_O_READ;
+    }
+    if (user_mode & S_IXGRP)
+    {
+        attributes.perms |= PVFS_G_EXECUTE;
+    }
+    if (user_mode & S_IWGRP)
+    {
+        attributes.perms |= PVFS_G_WRITE;
+    }
+    if (user_mode & S_IRGRP)
+    {
+        attributes.perms |= PVFS_G_READ;
+    }
+    if (user_mode & S_IXUSR)
+    {
+        attributes.perms |= PVFS_U_EXECUTE;
+    }
+    if (user_mode & S_IWUSR)
+    {
+        attributes.perms |= PVFS_U_WRITE;
+    }
+    if (user_mode & S_IRUSR)
+    {
+        attributes.perms |= PVFS_U_READ;
+    }
+
+    /* Set credentials */
+    iocommon_cred(&credentials);
+
+    /* Contact server */
+    rc = PVFS_sys_create((char*)filename,
+                         parent_ref,
+                         attributes,
+                         credentials,
+                         dist,
+                         &resp_create,
+                         NULL,
+                         NULL);
+    *ref = resp_create.ref;
+
+    if (dist) PINT_dist_free(dist);
+
+    return rc;
+}
+
+
+/* pvfs_open implementation, return file info in fd */
+/* assumes path is fully qualified */
+/* if pdir is not NULL, it is the parent directory */
+pvfs_descriptor *iocommon_open(const char *pathname, int flag,
+                               PVFS_hint file_creation_param,
+                               mode_t file_permission,
+                               PVFS_object_ref *pdir)
+{
+    int rc;
+    int follow_link;
+    char *directory;
+    char *filename;
+    PVFS_object_ref file_ref;
+    PVFS_object_ref parent_ref;
+    int fs_id = 0;
+    pvfs_descriptor *pd = NULL; /* invalid pd until file is opened */
+
+    /* Split the path into a directory and file */
+    rc = split_pathname(pathname, &directory, &filename);
+    if (0 != rc && (0 == directory || 0 == filename))
+    {
+        errno = ENOMEM;
+        return pd;
+    }
+    else if (rc != 0)
+    {
+        fprintf(stderr, "Error: %s is not a legal PVFS path.\n", pathname);
+        errno = EACCES;
+        return pd;
+    }
+
+    /* Check the flag to determine if links are followed */
+    if (flag & O_NOFOLLOW)
+    {
+        follow_link = PVFS2_LOOKUP_LINK_NO_FOLLOW;
+    }
+    else
+    {
+        follow_link = PVFS2_LOOKUP_LINK_FOLLOW;
+    }
+
+    /* Get reference for the parent directory */
+    rc = iocommon_lookup_absolute(directory, &parent_ref);
+    if (0 == rc)
+    {
+
+        /* An open procedure safe for multiprocessing */
+
+        //Attempt to find file
+        rc = iocommon_lookup_relative(filename, parent_ref, follow_link, &file_ref);
+
+        //File was found
+        if (rc==0){
+            //if EXCLUSIVE, fail
+            if ((flag & O_EXCL) && (flag & O_CREAT)){
+                return pd;
+            }
+        }
+        //File wasn't found
+        else {
+            //create file?
+            if (flag & O_CREAT){
+                rc = iocommon_create_file(filename, file_permission, file_creation_param, parent_ref, &file_ref);
+                //create failed, the file must have been created by a different process
+                if (rc){
+                    //get existing handle
+                    rc = iocommon_lookup_relative(filename, parent_ref, follow_link, &file_ref);
+                }
+            }
+        }
+    }
+    else
+    {
+        errno = ENOTDIR;
+        return pd;
+    }
+
+    /* Free directory and filename memory */
+    free(directory);
+    free(filename);
+
+    /* Translate the pvfs reference into a file descriptor */
+    if (0 == rc)
+    {
+       /* Set the file information */
+       /* create fd object */
+       pd = pvfs_alloc_descriptor(&pvfs_ops);
+       pd->pvfs_ref = file_ref;
+       pd->flags = flag;
+       pd->is_in_use = 1;    //indicate fd is valid!
+    }
+    else
+    {
+        /* Inidicate that an error occurred */
+        errno = EACCES;
+        return pd;
+    }
+
+    /* Truncate the file if neccesary */
+    if (flag & O_TRUNC)
+    {
+        PVFS_credentials *credentials;
+        iocommon_cred(&credentials);
+        PVFS_sys_truncate(file_ref, 0, credentials, NULL);
+    }
+
+    /* Move to the end of file if necessary */
+    if (flag & O_APPEND)
+        iocommon_lseek(pd, 0, 0, SEEK_END);
+
+    return pd;
+}
+
+off64_t iocommon_lseek(pvfs_descriptor *pd, off64_t offset,
+            PVFS_size unit_size, int whence)
+{
+
+    if (0 == pd)
+    {
+        errno = EBADF;
+        return PVFS_FD_FAILURE;
+    }
+
+    switch(whence)
+    {
+        case SEEK_SET:
+        {
+            pd->file_pointer = offset*unit_size;
+            break;
+        }
+        case SEEK_CUR:
+        {
+            pd->file_pointer += offset*unit_size;
+            break;
+        }
+        case SEEK_END:
+        {
+            PVFS_credentials *credentials;
+            PVFS_sysresp_getattr attributes_resp;
+
+            /* Construct credentials*/
+            iocommon_cred(&credentials);
+
+            /* Get the file's size in bytes as the ending offset */
+            PVFS_sys_getattr(pd->pvfs_ref, PVFS_ATTR_SYS_SIZE,
+                             credentials, &attributes_resp, NULL);
+
+            pd->file_pointer = attributes_resp.attr.size + offset*unit_size;
+            break;
+        }
+        default:
+        {
+            errno = EINVAL;
+            return PVFS_FD_FAILURE;
+        }
+    }
+    return pd->file_pointer;
+}
+
+/*
+ * pvfs_unlink implementation
+ * need to verify this is a file or symlink
+ * use rmdir for directory
+ */
+int iocommon_remove (const char *pathname, int dirflag) 
+{
+    int rc = 0;
+    char *parentdir = 0;
+    char *file = 0;
+    PVFS_object_ref parent_ref;
+    PVFS_credentials *credentials;
+    PVFS_sys_attr attr;
+
+    /* Initialize the system interface for this process */
+    iocommon_ensure_init();
+    iocommon_cred(&credentials);
+
+    if (0 == rc)
+    {
+        rc = split_pathname(pathname, &parentdir, &file);
+    }
+
+    if (0 == rc)
+    {
+        rc = iocommon_lookup_absolute(parentdir, &parent_ref);
+    }
+    /* need to verify this is a file or symlink */
+    /* WBL - What is going on here ??? */
+    iocommon_lookup_relative(parentdir, parent_ref,
+                PVFS2_LOOKUP_LINK_NO_FOLLOW, &parent_ref);
+    iocommon_getattr(parent_ref, &attr);
+    if ((attr.objtype & PVFS_TYPE_DIRECTORY) && dirflag)
+    {
+        errno = EISDIR;
+        return -1;
+    }
+    else if (!(attr.objtype & PVFS_TYPE_DIRECTORY) && !dirflag)
+    {
+        errno = ENOTDIR;
+        return -1;
+    }
+
+    if (0 == rc)
+    {
+        rc = PVFS_sys_remove(file, parent_ref, credentials, PVFS_HINT_NULL);
+    }
+
+    free(parentdir);
+    free(file);
+    if (0 != rc)
+    {
+        return -1;
+    }
+    return 0;
+}
+
+int iocommon_unlink(const char *pathname)
+{
+    return iocommon_remove(pathname, 1);
+}
+
+int iocommon_rmdir(const char *pathname)
+{
+    return iocommon_remove(pathname, 0);
+}
+
+/* if dir(s) are NULL, assume name is absolute */
+int iocommon_rename(pvfs_descriptor *olddir, const char *oldname,
+                    pvfs_descriptor *newdir, const char *newname)
+{
+    int rc;
+    char *oldent, *newent, *oldpath, *newpath;
+    PVFS_object_ref oldref, newref;
+    PVFS_credentials *creds;
+    PVFS_hint hints = PVFS_HINT_NULL;
+
+    iocommon_cred(&creds);
+    if (olddir)
+    {
+        /* do relative lookup */
+    }
+    else
+    {
+        /* do absolute lookup */
+        rc = split_pathname(oldname, &oldpath, &oldent);
+        rc = iocommon_lookup_absolute(oldpath, &oldref);
+    }
+    if (newdir)
+    {
+        /* do relative lookup */
+    }
+    else
+    {
+        /* do absolute lookup */
+        rc = split_pathname(newname, &newpath, &newent);
+        rc = iocommon_lookup_absolute(newpath, &newref);
+    }
+    rc = PVFS_sys_rename(oldent, oldref, newent, newref, creds, hints);
+    return rc;
+}
+
+/* do a blocking read or write
+ * extra_offset = extra padding to the pd's offset, independent of the pd's offset */
+int iocommon_readorwrite( enum PVFS_io_type which,
+        pvfs_descriptor *pd, PVFS_size offset, void *buf,
+        PVFS_Request etype_req, PVFS_Request file_req, size_t count)
+        //returned by nonblocking operations
+{
+        int rc;
+        PVFS_Request contig_memory_req;
+        PVFS_credentials *creds;
+        PVFS_sysresp_io read_resp;
+        PVFS_size req_size;
+
+        memset(&contig_memory_req, 0, sizeof(PVFS_Request));
+
+        //Ensure descriptor is used for the correct type of access
+        if (which==PVFS_IO_READ && (O_WRONLY & pd->flags)){
+            errno = EBADF;
+            return PVFS_FD_FAILURE;
+        }
+        else if (which==PVFS_IO_WRITE && (O_RDONLY == (pd->flags & O_ACCMODE)))
+        {
+            errno = EBADF;
+            return PVFS_FD_FAILURE;
+        }
+
+        /* Create the memory request of a contiguous region: 'mem_req' x count  */
+        rc = PVFS_Request_contiguous(count, etype_req, &contig_memory_req);
+
+        iocommon_cred(&creds);
+
+           rc = PVFS_sys_io(pd->pvfs_ref, file_req, offset, buf,
+                            contig_memory_req, creds, &read_resp,
+                            which, PVFS_HINT_NULL);
+
+        if (0 != rc)
+        {
+            errno = EIO;
+            return PVFS_FD_FAILURE;
+        }
+
+        PVFS_Request_size(contig_memory_req, &req_size);
+        pd->file_pointer += req_size;
+
+        PVFS_Request_free(&contig_memory_req);
+        return PVFS_FD_SUCCESS;
+}
+
+/*
+ * [Do a nonblocking read or write]
+ * extra_offset = extra padding to the pd's offset,
+ * independent of the pd's offset
+ * Returns an op_id, response, and ret_mem_request
+ * (which represents an etype_req*count region)
+ * Note that the none of the PVFS_Requests are freed
+ */
+int iocommon_ireadorwrite( enum PVFS_io_type which,
+        pvfs_descriptor *pd, PVFS_size extra_offset, void *buf,
+        PVFS_Request etype_req, PVFS_Request file_req, size_t count,
+        PVFS_sys_op_id *ret_op_id, PVFS_sysresp_io *ret_resp,
+        PVFS_Request *ret_memory_req)
+{
+        int rc;
+        PVFS_Request contig_memory_req;
+        PVFS_credentials *credentials;
+        PVFS_size req_size;
+
+        //Ensure descriptor is used for the correct type of access
+        if (which==PVFS_IO_READ && (O_WRONLY & pd->flags)){
+            errno = EBADF;
+            return PVFS_FD_FAILURE;
+        }
+        else if (which==PVFS_IO_WRITE && (O_RDONLY == (pd->flags & O_ACCMODE)))
+        {
+            errno = EBADF;
+            return PVFS_FD_FAILURE;
+        }
+
+        //Create the memory request of a contiguous region: 'mem_req' x count
+        rc = PVFS_Request_contiguous(count, etype_req, &contig_memory_req);
+
+        iocommon_cred(&credentials);
+
+        rc = PVFS_isys_io(pd->pvfs_ref, file_req,
+                          pd->file_pointer+extra_offset,
+                          buf, contig_memory_req,
+                          credentials,
+                          ret_resp,
+                          which,
+                          ret_op_id, PVFS_HINT_NULL, NULL);
+
+        assert(*ret_op_id!=-1);//TODO: handle this
+
+        if (rc!=0){
+            errno = EIO;
+            return PVFS_FD_FAILURE;
+        }
+
+        PVFS_Request_size(contig_memory_req, &req_size);
+        pd->file_pointer += req_size;
+
+        *ret_memory_req = contig_memory_req;
+
+        return PVFS_FD_SUCCESS;
+}
+
+int iocommon_getattr(PVFS_object_ref obj, PVFS_sys_attr *attr)
+{
+    int                  ret = 0;
+    PVFS_credentials     *credentials;
+    PVFS_sysresp_getattr getattr_response;
+
+    /* check credentials */
+    iocommon_cred(&credentials);
+
+    /* now get attributes */
+    ret = PVFS_sys_getattr(obj,
+                           PVFS_ATTR_SYS_ALL_NOHINT,
+                           credentials,
+                           &getattr_response, NULL);
+
+    *attr = getattr_response.attr;
+
+    if(ret < 0)
+    {
+        errno = EACCES; /* need to get proper return code */
+        return -1;
+    }
+
+    return 0;
+}
+
+/* WBL - question - should attr not be a pointer */
+int iocommon_setattr(PVFS_object_ref obj, PVFS_sys_attr *attr)
+{
+    int                  ret = 0;
+    PVFS_credentials     *credentials;
+
+    /* check credentials */
+    iocommon_cred(&credentials);
+
+    /* now get attributes */
+    ret = PVFS_sys_setattr(obj, *attr, credentials, NULL);
+
+    if(ret < 0)
+    {
+        errno = EACCES; /* need to get proper return code */
+        return -1;
+    }
+
+    return 0;
+}
+
+int iocommon_stat(pvfs_descriptor *pd, struct stat *buf)
+{
+    int                  ret = 0;
+    PVFS_sys_attr        attr;
+
+    iocommon_getattr(pd->pvfs_ref, &attr);
+
+    /* copy attributes into standard stat struct */
+    buf->st_dev = pd->pvfs_ref.fs_id;
+    buf->st_ino = pd->pvfs_ref.handle;
+    buf->st_mode = attr.perms;
+    if (attr.objtype & PVFS_TYPE_METAFILE)
+        buf->st_mode |= S_IFREG;
+    if (attr.objtype & PVFS_TYPE_DIRECTORY)
+        buf->st_mode |= S_IFDIR;
+    if (attr.objtype & PVFS_TYPE_SYMLINK)
+        buf->st_mode |= S_IFLNK;
+    buf->st_nlink = 1; /* PVFS does not allow hard links */
+    buf->st_uid = attr.owner;
+    buf->st_gid = attr.group;
+    buf->st_rdev = 0; /* no dev special files */
+    buf->st_size = attr.size;
+    buf->st_blksize = attr.blksize;
+    buf->st_blocks = 0; /* don't have blocks at this time */
+    buf->st_atime = attr.atime;
+    buf->st_mtime = attr.mtime;
+    buf->st_ctime = attr.ctime;
+
+    return 0;
+}
+
+/*
+ * The only difference here is that buf is stat64 which
+ * means some of its fields are defined as different types
+ */
+int iocommon_stat64(pvfs_descriptor *pd, struct stat64 *buf)
+{
+    int                  ret = 0;
+    PVFS_sys_attr        attr;
+
+    iocommon_getattr(pd->pvfs_ref, &attr);
+
+    /* copy attributes into standard stat struct */
+    buf->st_dev = pd->pvfs_ref.fs_id;
+    buf->st_ino = pd->pvfs_ref.handle;
+    buf->st_mode = attr.perms;
+    if (attr.objtype & PVFS_TYPE_METAFILE)
+        buf->st_mode |= S_IFREG;
+    if (attr.objtype & PVFS_TYPE_DIRECTORY)
+        buf->st_mode |= S_IFDIR;
+    if (attr.objtype & PVFS_TYPE_SYMLINK)
+        buf->st_mode |= S_IFLNK;
+    buf->st_nlink = 1; /* PVFS does not allow hard links */
+    buf->st_uid = attr.owner;
+    buf->st_gid = attr.group;
+    buf->st_rdev = 0; /* no dev special files */
+    buf->st_size = attr.size;
+    buf->st_blksize = attr.blksize;
+    buf->st_blocks = 0; /* don't have blocks at this time */
+    buf->st_atime = attr.atime;
+    buf->st_mtime = attr.mtime;
+    buf->st_ctime = attr.ctime;
+
+    return 0;
+}
+
+int iocommon_chown(pvfs_descriptor *pd, uid_t owner, gid_t group)
+{
+    int                  ret = 0;
+    PVFS_sys_attr        attr;
+
+    if (owner != -1)
+        attr.owner = owner;
+    if (owner != -1)
+        attr.group = group;
+    attr.mask = PVFS_ATTR_SYS_UID | PVFS_ATTR_SYS_GID;
+
+    ret = iocommon_setattr(pd->pvfs_ref, &attr);
+
+    return ret;
+}
+
+int iocommon_chmod(pvfs_descriptor *pd, mode_t mode)
+{
+    int                  ret = 0;
+    PVFS_sys_attr        attr;
+
+    attr.perms = mode & 07777; /* mask off any stray bits */
+    attr.mask = PVFS_ATTR_SYS_PERM;
+
+    ret = iocommon_setattr(pd->pvfs_ref, &attr);
+
+    return ret;
+}
+
+iocommon_make_directory(const char *pvfs_path, const int mode)
+{
+    int ret = 0;
+    char parent_dir[PVFS_NAME_MAX] = "";
+    char base[PVFS_NAME_MAX]  = "";
+    char realpath[PVFS_NAME_MAX]  = "";
+    char * parentdir_ptr = NULL;
+    char * basename_ptr = NULL;
+    PVFS_sys_attr       attr;
+    PVFS_sysresp_lookup resp_lookup;
+    PVFS_object_ref     parent_ref;
+    PVFS_sysresp_mkdir  resp_mkdir;
+    PVFS_credentials    *credentials;
+
+    /* Initialize any variables */
+    memset(&attr,        0, sizeof(attr));
+    memset(&resp_lookup, 0, sizeof(resp_lookup));
+    memset(&parent_ref,  0, sizeof(parent_ref));
+    memset(&resp_mkdir,  0, sizeof(resp_mkdir));
+
+    iocommon_cred(&credentials);
+
+    /*
+     * Copy the file name into structures to be passed to dirname and basename
+     * These calls change the parameter, so we don't want to mess with original
+     */
+    strcpy(parent_dir, pvfs_path);
+    strcpy(base, pvfs_path);
+
+    parentdir_ptr = dirname(parent_dir);
+    basename_ptr  = basename(base);
+
+    /* Make sure we don't try and create the root directory */
+    if( strcmp(basename_ptr, "/") == 0 )
+    {
+        errno = EEXIST;
+        return(-1);
+    }
+
+    /* lookup parent */
+    ret = iocommon_lookup_absolute(parentdir_ptr, &parent_ref);
+   
+    /* Set the attributes for the new directory */
+    attr.owner = credentials->uid;
+    attr.group = credentials->gid;
+    attr.perms = mode;
+    attr.mask = (PVFS_ATTR_SYS_ALL_SETABLE);
+
+    /* Clear out any info from previous calls */
+    memset(&resp_mkdir, 0, sizeof(PVFS_sysresp_mkdir));
+
+    ret = PVFS_sys_mkdir(basename_ptr,
+                         parent_ref,
+                         attr,
+                         credentials,
+                         &resp_mkdir, NULL);
+
+    if (ret != 0)
+    {
+        errno = ret;
+        return(-1);
+    }
+   
+    return(0);
+}
+
+int iocommon_readlink(pvfs_descriptor *pd, char *buf, int size)
+{
+    int                  ret = 0;
+    PVFS_sys_attr        attr;
+
+    iocommon_getattr(pd->pvfs_ref, &attr);
+
+    /* copy attributes into standard stat struct */
+    if (attr.objtype & PVFS_TYPE_SYMLINK)
+    {
+        strncpy(buf, attr.link_target, size);
+    }
+    else
+    {
+        errno = EINVAL;
+        return -1;
+    }
+
+    return 0;
+}
+
+int iocommon_symlink(const char  *pvfs_path,
+                     const char  *link_target)
+{
+    int ret = 0;
+    char parent_dir[PVFS_NAME_MAX] = "";
+    char base[PVFS_NAME_MAX]  = "";
+    char realpath[PVFS_NAME_MAX]  = "";
+    char * parentdir_ptr = NULL;
+    char * basename_ptr = NULL;
+    PVFS_sys_attr       attr;
+    PVFS_object_ref     parent_ref;
+    PVFS_sysresp_symlink  resp_symlink;
+    PVFS_credentials    *credentials;
+
+    /* Initialize any variables */
+    memset(&attr,        0, sizeof(attr));
+    memset(&parent_ref,  0, sizeof(parent_ref));
+    memset(&resp_symlink,0, sizeof(resp_symlink));
+
+    iocommon_cred(&credentials);
+
+    /*
+     * Copy the file name into structures to be passed to dirname and basename
+     * These calls change the parameter, so we don't want to mess with original
+     */
+    strcpy(parent_dir, pvfs_path);
+    strcpy(base,  pvfs_path);
+
+    parentdir_ptr = dirname(parent_dir);
+    basename_ptr  = basename(base);
+
+    /* Make sure we don't try and create the root directory */
+    if( strcmp(basename_ptr, "/") == 0 )
+    {
+        errno = EEXIST;
+        return(-1);
+    }
+
+    /* lookup parent */
+    ret = iocommon_lookup_absolute(parentdir_ptr, &parent_ref);
+   
+    /* Set the attributes for the new directory */
+    attr.owner = credentials->uid;
+    attr.group = credentials->gid;
+    attr.perms = 0777;
+    attr.mask = (PVFS_ATTR_SYS_ALL_SETABLE);
+
+    /* Clear out any info from previous calls */
+    memset(&resp_symlink, 0, sizeof(PVFS_sysresp_symlink));
+
+    ret = PVFS_sys_symlink(basename_ptr,
+                           parent_ref,
+                           (char *)link_target,
+                           attr,
+                           credentials,
+                           &resp_symlink,
+                           NULL);
+
+    if (ret != 0)
+    {
+        errno = ret;
+        return(-1);
+    }
+   
+    return(0);
+}
+
+int iocommon_getdents()
+{
+}
+
+int iocommon_access()
+{
+}
+
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=4 sts=4 sw=4 expandtab
+ */
+

--- /dev/null	2004-06-24 14:04:38.000000000 -0400
+++ iocommon.h	2011-02-08 16:39:34.000000000 -0500
@@ -0,0 +1,133 @@
+#ifndef IOCOMMON_H
+#define IOCOMMON_H 1
+
+#include <pvfs2.h>
+#include <pvfs2-types.h>
+#include <pvfs2-request.h>
+#include <pvfs2-debug.h>
+
+/* Define GNU's O_NOFOLLOW flag to be false if its not set */
+#ifndef O_NOFOLLOW
+#define O_NOFOLLOW 0
+#endif
+
+// Base pvfs file handle info:
+// native-lib and mpi-io both wrap around pvfs_descriptor for their file table entries
+
+#define PVFS_NULL_OBJ ((PVFS_object_ref *)NULL)
+
+/* prototypes */
+
+/* Perform PVFS initialization if not already finished */
+void iocommon_ensure_init();
+
+void iocommon_cred(PVFS_credentials **credentials);
+
+int iocommon_fsync(pvfs_descriptor *pvfs_info);
+
+/*
+ * Find the PVFS handle to an object (file, dir sym) 
+ * assumes an absoluate path
+ */
+int iocommon_lookup_absolute( const char *abs_path, PVFS_object_ref *ref);
+
+/*
+ * Lookup a file via the PVFS system interface
+ */
+int iocommon_lookup_relative( const char *rel_path,
+                             PVFS_object_ref parent_ref,
+                             int follow_links,
+                             PVFS_object_ref *ref );
+
+/*
+ * Create a file via the PVFS system interface
+ */
+int iocommon_create_file( const char *filename,
+			 mode_t file_permission,
+			 PVFS_hint file_creation_param,
+                         PVFS_object_ref parent_ref,
+                         PVFS_object_ref *ref );
+
+
+/* pvfs_open implementation, return file info in fd */
+/* assumes path is fully qualified */
+/* if pdir is not NULL, it is the parent directory */
+pvfs_descriptor *iocommon_open(const char *pathname, int flag,
+                               PVFS_hint file_creation_param,
+                               mode_t file_permission,
+                               PVFS_object_ref *pdir);
+
+off64_t iocommon_lseek(pvfs_descriptor *pd, off64_t offset, PVFS_size unit_size, int whence);
+
+/*
+ * pvfs_unlink implementation
+ * need to verify this is a file or symlink
+ * use rmdir for directory
+ */
+int iocommon_remove (const char *pathname, int dirflag) ;
+
+int iocommon_unlink(const char *pathname);
+
+int iocommon_rmdir(const char *pathname);
+
+/* if dir(s) are NULL, assume name is absolute */
+int iocommon_rename(pvfs_descriptor *olddir, const char *oldname,
+                    pvfs_descriptor *newdir, const char *newname);
+
+/* do a blocking read or write
+ * extra_offset = extra padding to the pd's offset, independent of the pd's offset */
+int iocommon_readorwrite( enum PVFS_io_type which,
+		pvfs_descriptor *pd, PVFS_size offset, void *buf,
+        PVFS_Request etype_req, PVFS_Request file_req, size_t count);
+        //returned by nonblocking operations
+
+/*
+ * [Do a nonblocking read or write]
+ * extra_offset = extra padding to the pd's offset,
+ * independent of the pd's offset
+ * Returns an op_id, response, and ret_mem_request
+ * (which represents an etype_req*count region)
+ * Note that the none of the PVFS_Requests are freed
+ */
+int iocommon_ireadorwrite( enum PVFS_io_type which,
+		pvfs_descriptor *pd, PVFS_size extra_offset, void *buf,
+        PVFS_Request etype_req, PVFS_Request file_req, size_t count,
+		PVFS_sys_op_id *ret_op_id, PVFS_sysresp_io *ret_resp,
+        PVFS_Request *ret_memory_req);
+
+int iocommon_getattr(PVFS_object_ref obj, PVFS_sys_attr *attr);
+
+int iocommon_setattr(PVFS_object_ref obj, PVFS_sys_attr *attr);
+
+int iocommon_stat(pvfs_descriptor *pd, struct stat *buf);
+
+/*
+ * The only difference here is that buf is stat64 which
+ * means some of its fields are defined as different types
+ */
+int iocommon_stat64(pvfs_descriptor *pd, struct stat64 *buf);
+
+int iocommon_chown(pvfs_descriptor *pd, uid_t owner, gid_t group);
+
+int iocommon_chmod(pvfs_descriptor *pd, mode_t mode);
+
+int iocommon_make_directory(const char *pvfs_path, const int mode);
+
+int iocommon_readlink(pvfs_descriptor *pd, char *buf, int size);
+
+int iocommon_symlink(const char *pvfs_path, const char *link_target);
+
+int iocommon_getdents();
+
+int iocommon_access();
+
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
+
+#endif

--- /dev/null	2004-06-24 14:04:38.000000000 -0400
+++ openfile-util.c	2011-02-08 16:39:34.000000000 -0500
@@ -0,0 +1,381 @@
+#include <usrint.h>
+
+static int pvfs_is_sys_initialized = 0; 
+
+#define PREALLOC 3
+static int descriptor_table_count = 0; 
+static int descriptor_table_size = 0; 
+static int next_descriptor = 0; 
+static pvfs_descriptor **descriptor_table; 
+
+pvfs_descriptor pvfs_stdin =
+{
+    .fd = 0,
+    .fsops = &glibc_ops,
+    .posix_fd = STDIN_FILENO,
+    .pvfs_ref.fs_id = 0,
+    .pvfs_ref.handle = 0,
+    .flags = O_RDONLY,
+    .file_pointer = 0,
+    .is_in_use = 1,
+    .dirty = 0,
+    .buf = NULL,
+    .buftotal = 0,
+    .bufsize = 0,
+    .buf_off = 0,
+    .bufptr = NULL
+};
+
+pvfs_descriptor pvfs_stdout =
+{
+    .fd = 1,
+    .fsops = &glibc_ops,
+    .posix_fd = STDOUT_FILENO,
+    .pvfs_ref.fs_id = 0,
+    .pvfs_ref.handle = 0,
+    .flags = O_WRONLY | O_APPEND,
+    .file_pointer = 0,
+    .is_in_use = 1,
+    .dirty = 0,
+    .buf = NULL,
+    .buftotal = 0,
+    .bufsize = 0,
+    .buf_off = 0,
+    .bufptr = NULL
+};
+
+pvfs_descriptor pvfs_stderr =
+{
+    .fd = 2,
+    .fsops = &glibc_ops,
+    .posix_fd = STDERR_FILENO,
+    .pvfs_ref.fs_id = 0,
+    .pvfs_ref.handle = 0,
+    .flags = O_WRONLY | O_APPEND,
+    .file_pointer = 0,
+    .is_in_use = 1,
+    .dirty = 0,
+    .buf = NULL,
+    .buftotal = 0,
+    .bufsize = 0,
+    .buf_off = 0,
+    .bufptr = NULL
+};
+
+
+/* 
+ * Perform PVFS initialization tasks
+ */ 
+
+int pvfs_sys_init() { 
+	struct rlimit rl; 
+	int rc; 
+
+	/* initalize the file system */ 
+	PVFS_util_init_defaults(); 
+
+	rc = getrlimit(RLIMIT_NOFILE, &rl); 
+	/* need to check for "INFINITY" */
+
+	descriptor_table_size = rl.rlim_max;
+	descriptor_table =
+			(pvfs_descriptor **)malloc(sizeof(pvfs_descriptor *) *
+			descriptor_table_size);
+	memset(descriptor_table, 0,
+			(sizeof(pvfs_descriptor *) * descriptor_table_size));
+    descriptor_table[0] = &pvfs_stdin;
+    descriptor_table[1] = &pvfs_stdout;
+    descriptor_table[2] = &pvfs_stderr;
+	next_descriptor = PREALLOC;
+
+	/* Mark the initialization complete */ 
+	pvfs_is_sys_initialized = 1; 
+	return PVFS_FD_SUCCESS; 
+}
+
+int pvfs_descriptor_table_size(void)
+{
+    return descriptor_table_size;
+}
+
+
+/*
+ * Allocate a new pvfs_descriptor
+ * initialize fsops to the given set
+ */
+ pvfs_descriptor *pvfs_alloc_descriptor(posix_ops *fsops)
+ {
+ 	int i; 
+	if (descriptor_table_count == (descriptor_table_size - PREALLOC))
+	{
+		// print error
+		return NULL;
+	}
+
+   /* find next empty slot in table */
+	for (i = next_descriptor; descriptor_table[i];
+			i = (i == descriptor_table_size-1) ? PREALLOC : i++);
+
+   /* found a slot */
+	descriptor_table[i] = malloc(sizeof(pvfs_descriptor));
+	if (descriptor_table[i] == NULL)
+	{
+		// print error
+		return NULL;
+	}
+	next_descriptor = ((i == descriptor_table_size-1) ? PREALLOC : i++);
+	descriptor_table_count++;
+
+	/* fill in descriptor */
+	descriptor_table[i]->fd = i;
+	descriptor_table[i]->dup_cnt = 1;
+	descriptor_table[i]->fsops = fsops;
+	descriptor_table[i]->posix_fd = i;
+	descriptor_table[i]->pvfs_ref.fs_id = 0;
+	descriptor_table[i]->pvfs_ref.handle = 0;
+	descriptor_table[i]->flags = 0;
+	descriptor_table[i]->file_pointer = 0;
+	descriptor_table[i]->is_in_use = 0;
+	descriptor_table[i]->dirty = 0;
+	descriptor_table[i]->eof = 0;
+	descriptor_table[i]->error = 0;
+	descriptor_table[i]->buf = NULL;
+	descriptor_table[i]->buftotal = 0;
+	descriptor_table[i]->bufsize = 0;
+	descriptor_table[i]->buf_off = 0;
+	descriptor_table[i]->bufptr = NULL;
+
+   return descriptor_table[i];
+}
+
+/*
+ * Function for dupliating a descriptor - used in dup and dup2 calls
+ */
+int pvfs_dup_descriptor(int oldfd, int newfd)
+{
+    if (newfd == -1)
+    {
+        /* find next empty slot in table */
+        for (newfd = next_descriptor; descriptor_table[newfd];
+            newfd = (newfd == descriptor_table_size-1) ? PREALLOC : newfd++);
+    }
+    else
+    {
+        if (descriptor_table[newfd] != NULL)
+        {
+            /* close old file in new slot */
+            pvfs_close(newfd);
+        }
+    }
+    descriptor_table[newfd] = descriptor_table[oldfd];
+    descriptor_table[newfd]->dup_cnt++;
+	descriptor_table_count++;
+}
+
+/*
+ * Return a pointer to the pvfs_descriptor for the file descriptor or null
+ * if there is no entry for the given file descriptor
+ * should probably be inline if we can get at static table that way
+ */
+pvfs_descriptor *pvfs_find_descriptor(int fd)
+{
+	return descriptor_table[fd];
+}
+
+int pvfs_free_descriptor(int fd)
+{
+    pvfs_descriptor *pd;
+
+    pd = descriptor_table[fd];
+
+	/* clear out table entry */
+	descriptor_table[fd] = NULL;
+
+	/* keep up with used descriptors */
+	descriptor_table_count++;
+
+    /* check if last copy */
+    if (--(pd->dup_cnt) <= 0)
+    {
+	    /* free buffer space */
+	    if (pd->buf)
+        {
+		    free(pd->buf);
+        }
+	    /* free descriptor - wipe memory first */
+	    memset(pd, 0, sizeof(pvfs_descriptor));
+	    free(pd);
+    }
+
+	return 0;
+}
+
+/* 
+ * takes a path that is relative to the working dir and
+ * expands it all the way to the root
+ */
+char * pvfs_qualify_path(const char *path)
+{
+    char *rc = NULL;
+    int i = 1;
+    int cdsz;
+    int psz;
+    char *curdir;
+    char *newpath;
+
+    if(path[0] != '/')
+    {
+        /* loop until our temp buffer is big enough for the */
+        /* current directory */
+        do
+        {
+            if (i > 1)
+                free(curdir);
+            curdir = (char *)malloc(i * 256);
+            if (curdir == NULL)
+                return NULL;
+            rc = getcwd(curdir, i * 256);
+            i++;
+        } while ((rc == NULL) && (errno == ERANGE));
+        if (rc == NULL)
+        {
+            /* some other error, bail out */
+            free(curdir);
+            return NULL;
+        }
+        cdsz = strlen(curdir);
+        psz = strlen(path);
+        /* allocate buffer for whole path and copy */
+        newpath = (char *)malloc(cdsz+psz+2);
+        strncpy(newpath, curdir, cdsz);
+        free(curdir);
+        strncat(newpath, "/", 1);
+        strncat(newpath, path, psz);
+    }
+    else
+        newpath = (char *)path;
+    return newpath;
+}
+
+/* 
+ *Determines if a path is part of a PVFS Filesystem 
+ */
+
+int is_pvfs_path(const char *path) {
+   struct statfs file_system;
+   char * directory = NULL ;
+   char *str;
+
+   if(path[0] != '/') {
+      directory = getcwd(NULL, 0);
+      str  = malloc((strlen(directory)+1)*sizeof(char));
+      strcpy(str, directory);
+      free(directory);
+   }
+   else {
+      str = malloc((strlen(path)+1) *sizeof(char));
+      strcpy(str, path);
+   }
+   if(str == NULL) {
+      pvfs_debug("Malloc has failed\n");
+   }
+
+   int count;
+   for(count = strlen(str) -2; count > 0; count--) {
+      if(str[count] == '/') {
+         str[count] = '\0';
+         break;
+      }
+   }
+   /* this must call standard glibc statfs */
+   glibc_ops.statfs(str, &file_system);
+   free(str);
+   if(file_system.f_type == PVFS_FS) {
+#ifdef DEBUG
+   printf("IS PVFS_PATH\n");
+#endif
+      return true;
+   }
+   else if(file_system.f_type == LINUX_FS) {
+#ifdef DEBUG
+   printf("IS NOT PVFS_PATH\n");
+#endif
+      return false;
+   }
+   else {
+      printf("NO A LINUX OR PVFS FILE SYSTEM!! (BAILING OUT!!!)\n");
+      exit(1);
+   }
+}
+
+void pvfs_debug(char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    vfprintf(stderr, fmt, ap);
+    va_end(ap);
+}
+
+/**
+ * Split a pathname into a directory and a filename.  If non-null
+ * is passed as the directory or filename, the field will be allocated and
+ * filled with the correct value
+ */
+int split_pathname( const char *path,
+                    char **directory,
+                    char **filename)
+{
+	/* chop off pvfs2 prefix */
+	if (strncmp(path,"pvfs2:",strlen("pvfs2:")) == 0)
+		path = &path[strlen("pvfs2:")];
+
+    /* Split path into a directory and filename */
+    int path_length = strlen(path);
+    if ('/' == path[0])
+    {
+        int i;
+        for (i = path_length - 1; i >= 0; --i)
+        {
+            if ( '/' == path[i] )
+            {
+                /* parse the directory */
+                if (0 != directory)
+                {
+                    *directory = malloc(i + 1);
+                    if (0 != directory)
+                    {
+                        strncpy(*directory, path, i);
+                        (*directory)[i] = '\0';
+                    }
+                }
+                /* parse the filename */
+                if (0 != filename)
+                {
+                    *filename = malloc(path_length - i + 1);
+                    if (0 != filename)
+                    {
+                        strncpy(*filename, path + i + 1, path_length - i);
+                        (*filename)[path_length - i] = '\0';
+                    }
+                }
+                break;
+            }
+        }
+    }
+    else
+    {
+        fprintf(stderr, "Error: Not an absolute path: %s\n", path);
+        return PVFS_FD_FAILURE;
+    }
+    return PVFS_FD_SUCCESS;
+}
+
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=4 sts=4 sw=4 expandtab
+ */

--- /dev/null	2004-06-24 14:04:38.000000000 -0400
+++ openfile-util.h	2011-02-08 16:39:34.000000000 -0500
@@ -0,0 +1,43 @@
+#ifndef OPENFILE_UTIL_H
+#define OPENFILE_UTIL_H 1
+
+//Define success and error return values
+#define PVFS_FD_SUCCESS 0
+#define PVFS_FD_FAILURE -1
+
+int split_pathname( const char *path, char **directory, char **filename);
+
+int pvfs_sys_init(); 
+
+char *pvfs_qualify_path(const char *path);
+
+int is_pvfs_path(const char *path); 
+
+void pvfs_debug(char *fmt, ...); 
+
+void load_glibc(void); 
+
+int pvfs_split_pathname(const char *path,
+                               char **directory,
+                               char **filename); 
+
+int pvfs_lookup_dir(const char *directory,
+                           PVFS_object_ref *ref,
+                           int *fs_id);
+
+int pvfs_lookup_file(const char *filename,
+                            int fs_id,
+                            PVFS_object_ref parent_ref,
+                            int follow_links,
+                            PVFS_object_ref *ref);
+
+pvfs_descriptor* pvfs_alloc_descriptor(posix_ops *fsops);
+
+pvfs_descriptor* pvfs_find_descriptor(int fd);
+
+
+int pvfs_create_file(const char *filename,
+                            mode_t mode,
+                            PVFS_object_ref parent_ref,
+                            PVFS_object_ref *ref);
+#endif

--- /dev/null	2004-06-24 14:04:38.000000000 -0400
+++ posix-pvfs.c	2011-02-08 16:39:34.000000000 -0500
@@ -0,0 +1,869 @@
+#include <usrint.h>
+
+static mode_t mask_val = 0022; /* implements umask for pvfs library */
+
+/* pvfs_open */
+int pvfs_open(const char *path, int flags, ...)
+{
+    va_list ap;
+    int mode;
+    PVFS_hint hints;
+    char *newpath;
+    pvfs_descriptor *pd;
+
+    va_start(ap, flags);
+    if (flags & O_CREAT)
+        mode = va_arg(ap, int);
+    else
+        mode = 0777;
+    if (flags & O_HINTS)
+        hints = va_arg(ap, PVFS_hint);
+    else
+        hints = PVFS_HINT_NULL;
+    va_end(ap);
+
+    /* fully qualify pathname */
+    newpath = pvfs_qualify_path(path);
+    pd = iocommon_open(newpath, flags, hints, mode, NULL);
+    if (newpath != path)
+    {
+        free(newpath);
+    }
+    return pd->fd;
+}
+
+/* pvfs_open64 */
+int pvfs_open64(const char *path, int flags, ...)
+{
+    va_list ap;
+    int mode;
+    PVFS_hint hints;
+
+    va_start(ap, flags);
+    if (flags & O_CREAT)
+        mode = va_arg(ap, int);
+    else
+        mode = 0777;
+    if (flags & O_HINTS)
+        hints = va_arg(ap, PVFS_hint);
+    else
+        hints = PVFS_HINT_NULL;
+    va_end(ap);
+    flags |= O_LARGEFILE;
+    return pvfs_open(path, flags, mode);
+}
+
+/* pvfs_openat */
+int pvfs_openat(int dirfd, const char *path, int flags, ...)
+{
+    va_list ap;
+    int mode;
+    PVFS_hint hints;
+    pvfs_descriptor *dpd, *fpd;
+
+    va_start(ap, flags);
+    if (flags & O_CREAT)
+        mode = va_arg(ap, int);
+    else
+        mode = 0777;
+    if (flags & O_HINTS)
+        hints = va_arg(ap, PVFS_hint);
+    else
+        hints = PVFS_HINT_NULL;
+    va_end(ap);
+    if (path[0] == '/')
+    {
+        return pvfs_open(path, flags, mode);
+    }
+    else
+    {
+        dpd = pvfs_find_descriptor(dirfd);
+        fpd = iocommon_open(path, flags, hints, mode, &dpd->pvfs_ref);
+        return fpd->fd;
+    }
+        
+}
+
+/* pvfs_openat64 */
+int pvfs_openat64(int dirfd, const char *path, int flags, ...)
+{
+    va_list ap;
+    int mode;
+    PVFS_hint hints;
+    pvfs_descriptor *pd;
+
+    va_start(ap, flags);
+    if (flags & O_CREAT)
+        mode = va_arg(ap, int);
+    else
+        mode = 0777;
+    if (flags & O_HINTS)
+        hints = va_arg(ap, PVFS_hint);
+    else
+        hints = PVFS_HINT_NULL;
+    va_end(ap);
+    flags |= O_LARGEFILE;
+    return pvfs_openat(dirfd, path, flags, mode);
+}
+
+int pvfs_creat(const char *path, mode_t mode, ...)
+{
+}
+
+int pvfs_creat64(const char *path, mode_t mode, ...)
+{
+}
+
+/* pvfs_unlink */
+int pvfs_unlink (const char *path)
+{
+    return iocommon_unlink(path);
+}
+
+int pvfs_unlinkat (int dirfd, const char *path)
+{
+    pvfs_descriptor *pd, *pd2;
+    if (path[0] == '/' || dirfd == AT_FDCWD)
+        pvfs_unlink(path);
+    else
+    {
+        int flags = O_RDONLY;
+        pd = pvfs_find_descriptor(dirfd);
+        /* not sure what to do with this ... */
+        return -1;
+    }
+}
+
+int pvfs_rename(const char *oldpath, const char *newpath)
+{
+    int rc;
+    char *absoldpath, *absnewpath;
+
+    absoldpath = pvfs_qualify_path(oldpath);
+    absnewpath = pvfs_qualify_path(newpath);
+    rc = iocommon_rename(NULL, absoldpath, NULL, absnewpath);
+    if (oldpath != absoldpath)
+    {
+        free(absoldpath);
+    }
+    if (newpath != absnewpath)
+    {
+        free(absnewpath);
+    }
+    return rc;
+}
+
+int pvfs_renameat(int olddirfd, const char *oldpath,
+                  int newdirfd, const char *newpath)
+{
+    int rc;
+    pvfs_descriptor *olddes, *newdes;
+    char *absoldpath, *absnewpath;
+
+    if (oldpath[0] != '/')
+    {
+        olddes = pvfs_find_descriptor(olddirfd);
+        absoldpath = (char *)oldpath;
+    }
+    else
+    {
+        olddes = NULL;
+        absoldpath = pvfs_qualify_path(oldpath);
+    }
+    if (oldpath[0] != '/')
+    {
+        newdes = pvfs_find_descriptor(newdirfd);
+        absnewpath = (char *)newpath;
+    }
+    else
+    {
+        newdes = NULL;
+        absnewpath = pvfs_qualify_path(newpath);
+    }
+    rc = iocommon_rename(olddes, absoldpath, newdes, absnewpath);
+    if (oldpath != absoldpath)
+    {
+        free(absoldpath);
+    }
+    if (newpath != absnewpath)
+    {
+        free(absnewpath);
+    }
+    return rc;
+}
+
+/* pvfs_read */
+ssize_t pvfs_read( int fd, void *buf, size_t count )
+{
+    int rc;
+    pvfs_descriptor *pd = pvfs_find_descriptor(fd);
+    rc = pvfs_pread64(fd, buf, count, pd->file_pointer);
+    if (rc > 0)
+        pd->file_pointer += rc;
+    return rc;
+}
+
+/* pvfs_pread */
+ssize_t pvfs_pread( int fd, void *buf, size_t count, off_t offset )
+{
+    return pvfs_pread_64(fd, buf, count, (off64_t) offset);
+}
+
+ssize_t pvfs_readv(int fd, const struct iovec *vector, int count)
+{
+}
+
+/* pvfs_pread64 */
+ssize_t pvfs_pread64( int fd, void *buf, size_t count, off64_t offset )
+{
+    int rc;
+    pvfs_descriptor* pd;
+    PVFS_Request freq;
+
+    memset(&freq, 0, sizeof(freq));
+
+    /* Find the descriptor */
+    pd = pvfs_find_descriptor(fd);
+    if (pd == NULL) {
+        errno = EBADF;
+        return PVFS_FD_FAILURE;
+    }
+
+    /* Ensure descriptor is available for read access */
+    if (O_WRONLY & pd->flags) {
+        errno = EBADF;
+        return PVFS_FD_FAILURE;
+    }
+
+    rc = PVFS_Request_contiguous(count, PVFS_BYTE, &freq);
+
+    iocommon_readorwrite(PVFS_IO_READ, pd, offset, buf, PVFS_BYTE, freq, count);
+
+    PVFS_Request_free(&freq);
+
+    return count;
+}
+
+/* pvfs_write */
+ssize_t pvfs_write( int fd, void *buf, size_t count )
+{
+    int rc;
+    pvfs_descriptor *pd = pvfs_find_descriptor(fd);
+    rc = pvfs_pwrite64(fd, buf, count, pd->file_pointer);
+    if (rc > 0)
+        pd->file_pointer += rc;
+    return rc;
+}
+
+/* pvfs_pwrite */
+ssize_t pvfs_pwrite( int fd, void *buf, size_t count, off_t offset )
+{
+    return pvfs_pwrite64(fd, buf, count, (off64_t) offset);
+}
+
+ssize_t pvfs_writev( int fd, const struct iovec *vector, int count )
+{
+}
+
+/* pvfs_pwrite64 */
+ssize_t pvfs_write64( int fd, void *buf, size_t count, off64_t offset )
+{
+    int rc;
+    pvfs_descriptor* pd;
+    PVFS_Request freq;
+
+    memset(&freq, 0, sizeof(freq));
+
+    /* Find the descriptor */
+    pd = pvfs_find_descriptor(fd);
+    if (pd == NULL) {
+        errno = EBADF;
+        return PVFS_FD_FAILURE;
+    }
+
+    /* Ensure descriptor is available for read access */
+    if (O_RDONLY & pd->flags) {
+        errno = EBADF;
+        return PVFS_FD_FAILURE;
+    }
+
+    rc = PVFS_Request_contiguous(count, PVFS_BYTE, &freq);
+
+    iocommon_readorwrite(PVFS_IO_WRITE, pd, offset, buf, PVFS_BYTE, freq, count);
+
+    PVFS_Request_free(&freq);
+
+    return count;
+}
+
+/* pvfs_lseek */
+off_t pvfs_lseek(int fd, off_t offset, int whence)
+{
+    return (off_t) pvfs_lseek64(fd, (off64_t)offset, whence);
+}
+
+/* pvfs_lseek64 */
+off64_t pvfs_lseek64(int fd, off64_t offset, int whence)
+{
+    pvfs_descriptor* pd;
+
+    /* Find the descriptor */
+    pd = pvfs_find_descriptor(fd);
+    if (pd == 0) {
+        errno = EBADF;
+        return PVFS_FD_FAILURE;
+    }
+
+    iocommon_lseek(pd, offset, 1, whence);
+
+    return pd->file_pointer;
+}
+
+int pvfs_truncate(const char *path, off_t length)
+{
+    return pvfs_truncate64(path, (off64_t) length);
+}
+
+int pvfs_truncate64 (const char *path, off64_t length)
+{
+    int rc;
+    pvfs_descriptor *pd;
+
+    pd = iocommon_open(path, O_WRONLY, PVFS_HINT_NULL, 0 , NULL);
+    rc = iocommon_truncate(pd->pvfs_ref, length);
+    pvfs_close(pd->fd);
+    return rc;
+}
+
+int pvfs_ftruncate (int fd, off_t length)
+{
+    return pvfs_ftruncate64(fd, (off64_t) length);
+}
+
+int pvfs_ftruncate64 (int fd, off64_t length)
+{
+    pvfs_descriptor *pd;
+    
+    pd = pvfs_find_descriptor(fd);
+    return iocommon_truncate(pd->pvfs_ref, length);
+}
+
+/* pvfs_close */
+int pvfs_close( int fd )
+{
+    pvfs_descriptor* pd;
+
+    pd = pvfs_find_descriptor(fd);
+    if (pd == 0) {
+        errno = EBADF;
+        return PVFS_FD_FAILURE;
+    }
+
+    /* flush buffers */
+    pvfs_flush(fd);
+
+    /* free buffers */
+    if (pd->buf)
+        free(pd->buf);
+
+    /* free descriptor */
+    pvfs_free_descriptor(fd);
+
+    return PVFS_FD_SUCCESS;
+}
+
+int pvfs_flush(int fd)
+{
+    pvfs_descriptor* pd;
+    int rc;
+
+#ifdef DEBUG
+    pvfs_debug("in pvfs_flush(%ld)\n", fd);
+#endif
+
+    /* Find the descriptor */
+    pd = pvfs_find_descriptor(fd);
+    if (pd == 0) {
+        errno = EBADF;
+        return PVFS_FD_FAILURE;
+    }
+
+    /* write any buffered data to the server */
+    if (pd->buf && pd->dirty)
+    {
+        pd->file_pointer = pd->buf_off;
+        rc = pvfs_write(fd, pd->buf,
+                (pd->buftotal < pd->bufsize) ?  pd->buftotal : pd->bufsize);
+        pd->dirty = 0;
+    }
+
+    /* tell the server to flush data to disk */
+    rc = iocommon_fsync(pd);
+    if (rc == 0) {
+        return PVFS_FD_SUCCESS;
+    }
+    else {
+        errno = EINVAL;
+        return PVFS_FD_FAILURE;
+    }
+}
+
+/* various flavors of stat */
+int pvfs_stat(const char *path, struct stat *buf)
+{
+    char *newpath;
+    pvfs_descriptor *pd;
+
+    newpath = pvfs_qualify_path(path);
+    pd = iocommon_open(newpath, O_RDONLY, PVFS_HINT_NULL, 0, NULL);
+    if (newpath != path)
+    {
+        free(newpath);
+    }
+    iocommon_stat(pd, buf);
+    pvfs_close(pd->fd);
+}
+
+int pvfs_stat64(const char *path, struct stat64 *buf)
+{
+    char *newpath;
+    pvfs_descriptor *pd;
+
+    newpath = pvfs_qualify_path(path);
+    pd = iocommon_open(newpath, O_RDONLY, PVFS_HINT_NULL, 0, NULL);
+    if (newpath != path)
+    {
+        free(newpath);
+    }
+    iocommon_stat64(pd, buf);
+    pvfs_close(pd->fd);
+}
+
+int pvfs_fstat(int fd, struct stat *buf)
+{
+    pvfs_descriptor *pd;
+    pd = pvfs_find_descriptor(fd);
+    iocommon_stat(pd, buf);
+}
+
+int pvfs_fstat64(int fd, struct stat64 *buf)
+{
+    pvfs_descriptor *pd;
+    pd = pvfs_find_descriptor(fd);
+    iocommon_stat64(pd, buf);
+}
+
+int pvfs_fstatat(int fd, char *path, struct stat *buf, int flag)
+{
+    pvfs_descriptor *pd, *pd2;
+    if (path[0] == '/' || fd == AT_FDCWD)
+        if (flag & AT_SYMLINK_NOFOLLOW)
+            pvfs_lstat(path, buf);
+        else
+            pvfs_stat(path, buf);
+    else
+    {
+        int flags = O_RDONLY;
+        if (flag & AT_SYMLINK_NOFOLLOW)
+            flags |= O_NOFOLLOW;
+        pd = pvfs_find_descriptor(fd);
+        pd2 = iocommon_open(path, flags, PVFS_HINT_NULL, 0, &pd->pvfs_ref);
+        iocommon_stat(pd2, buf);
+        pvfs_close(pd2->fd);
+    }
+}
+
+int pvfs_fstatat64(int fd, char *path, struct stat64 *buf, int flag)
+{
+    pvfs_descriptor *pd, *pd2;
+    if (path[0] == '/' || fd == AT_FDCWD)
+        if (flag & AT_SYMLINK_NOFOLLOW)
+            pvfs_lstat64(path, buf);
+        else
+            pvfs_stat64(path, buf);
+    else
+    {
+        int flags = O_RDONLY;
+        if (flag & AT_SYMLINK_NOFOLLOW)
+            flags |= O_NOFOLLOW;
+        pd = pvfs_find_descriptor(fd);
+        pd2 = iocommon_open(path, flags, PVFS_HINT_NULL, 0, &pd->pvfs_ref);
+        iocommon_stat64(pd2, buf);
+        pvfs_close(pd2->fd);
+    }
+}
+
+int pvfs_lstat(const char *path, struct stat *buf)
+{
+    char *newpath;
+    pvfs_descriptor *pd;
+
+    newpath = pvfs_qualify_path(path);
+    pd = iocommon_open(newpath, O_RDONLY|O_NOFOLLOW, PVFS_HINT_NULL, 0, NULL);
+    if (newpath != path)
+    {
+       free(newpath);
+    }
+    iocommon_stat(pd, buf);
+    pvfs_close(pd->fd);
+}
+
+int pvfs_lstat64(const char *path, struct stat64 *buf)
+{
+    char *newpath;
+    pvfs_descriptor *pd;
+
+    newpath = pvfs_qualify_path(path);
+    pd = iocommon_open(newpath, O_RDONLY|O_NOFOLLOW, PVFS_HINT_NULL, 0, NULL);
+    if (newpath != path)
+    {
+        free(newpath);
+    }
+    iocommon_stat64(pd, buf);
+    pvfs_close(pd->fd);
+}
+
+int pvfs_dup(int oldfd)
+{
+    return pvfs_dup_descriptor(oldfd, -1);
+}
+
+int pvfs_dup2(int oldfd, int newfd)
+{
+    return pvfs_dup_descriptor(oldfd, newfd);
+}
+
+int pvfs_chown (const char *path, uid_t owner, gid_t group)
+{
+    char *newpath;
+    pvfs_descriptor *pd;
+
+    newpath = pvfs_qualify_path(path);
+    pd = iocommon_open(newpath, O_RDONLY, PVFS_HINT_NULL, 0, NULL);
+    if (newpath != path)
+    {
+        free(newpath);
+    }
+    iocommon_chown(pd, owner, group);
+    pvfs_close(pd->fd);
+}
+
+int pvfs_fchown (int fd, uid_t owner, gid_t group)
+{
+    pvfs_descriptor *pd;
+    pd = pvfs_find_descriptor(fd);
+    iocommon_chown(pd, owner, group);
+}
+
+int pvfs_fchownat(int fd, char *path, uid_t owner, gid_t group, int flag)
+{
+    pvfs_descriptor *pd, *pd2;
+    if (path[0] == '/' || fd == AT_FDCWD)
+        if (flag & AT_SYMLINK_NOFOLLOW)
+            pvfs_lchown(path, owner, group);
+        else
+            pvfs_chown(path, owner, group);
+    else
+    {
+        int flags = O_RDONLY;
+        if (flag & AT_SYMLINK_NOFOLLOW)
+            flags |= O_NOFOLLOW;
+        pd = pvfs_find_descriptor(fd);
+        pd2 = iocommon_open(path, flags, PVFS_HINT_NULL, 0, &pd->pvfs_ref);
+        iocommon_chown(pd2, owner, group);
+        pvfs_close(pd2->fd);
+    }
+}
+
+int pvfs_lchown (const char *path, uid_t owner, gid_t group)
+{
+    char *newpath;
+    pvfs_descriptor *pd;
+
+    newpath = pvfs_qualify_path(path);
+    pd = iocommon_open(newpath, O_RDONLY|O_NOFOLLOW, PVFS_HINT_NULL, 0, NULL);
+    if (newpath != path)
+    {
+        free(newpath);
+    }
+    iocommon_chown(pd, owner, group);
+    pvfs_close(pd->fd);
+}
+
+int pvfs_chmod (const char *path, mode_t mode)
+{
+    char *newpath;
+    pvfs_descriptor *pd;
+
+    newpath = pvfs_qualify_path(path);
+    pd = iocommon_open(newpath, O_RDONLY, PVFS_HINT_NULL, 0, NULL);
+    if (newpath != path)
+    {
+        free(newpath);
+    }
+    iocommon_chmod(pd, mode);
+    pvfs_close(pd->fd);
+}
+
+int pvfs_fchmod (int fd, mode_t mode)
+{
+    pvfs_descriptor *pd;
+    pd = pvfs_find_descriptor(fd);
+    iocommon_chmod(pd, mode);
+}
+
+int pvfs_fchmodat(int fd, char *path, mode_t mode, int flag)
+{
+    pvfs_descriptor *pd, *pd2;
+    if (path[0] == '/' || fd == AT_FDCWD)
+        if (flag & AT_SYMLINK_NOFOLLOW)
+            pvfs_lchmod(path, mode);
+        else
+            pvfs_chmod(path, mode);
+    else
+    {
+        int flags = O_RDONLY;
+        if (flag & AT_SYMLINK_NOFOLLOW)
+            flags |= O_NOFOLLOW;
+        pd = pvfs_find_descriptor(fd);
+        pd2 = iocommon_open(path, flags, PVFS_HINT_NULL, 0, &pd->pvfs_ref);
+        iocommon_chmod(pd2, mode);
+        pvfs_close(pd2->fd);
+    }
+}
+
+/* this is not a Linux syscall, but its useful above */
+int pvfs_lchmod (const char *path, mode_t mode)
+{
+    char *newpath;
+    pvfs_descriptor *pd;
+
+    newpath = pvfs_qualify_path(path);
+    pd = iocommon_open(newpath, O_RDONLY|O_NOFOLLOW, PVFS_HINT_NULL, 0, NULL);
+    if (newpath != path)
+    {
+        free(newpath);
+    }
+    iocommon_chmod(pd, mode);
+    pvfs_close(pd->fd);
+}
+
+int pvfs_mkdir (const char *path, mode_t mode)
+{
+    char *newpath;
+    int rc;
+
+    newpath = pvfs_qualify_path(path);
+    rc = iocommon_make_directory(newpath, (mode & ~mask_val & 0777));
+    if (newpath != path)
+    {
+        free(newpath);
+    }
+    return rc;
+}
+
+int pvfs_mkdirat (int dirfd, const char *path, mode_t mode)
+{
+    pvfs_descriptor *pd, *pd2;
+    if (path[0] == '/' || dirfd == AT_FDCWD)
+        pvfs_mkdir(path, mode);
+    else
+    {
+        int flags = O_RDONLY;
+        pd = pvfs_find_descriptor(dirfd);
+        /* not sure what to do with this ... */
+        return -1;
+    }
+}
+
+int pvfs_rmdir (const char *path)
+{
+    char *newpath;
+    int rc;
+
+    newpath = pvfs_qualify_path(path);
+    rc = iocommon_rmdir(newpath);
+    if (newpath != path)
+    {
+        free(newpath);
+    }
+    return rc;
+}
+
+ssize_t pvfs_readlink (const char *path, char *buf, size_t bufsiz)
+{
+}
+
+int pvfs_readlinkat (int dirfd, const char *path, char *buf, size_t bufsiz)
+{
+}
+
+ssize_t pvfs_symlink (const char *oldpath, const char *newpath)
+{
+}
+
+int pvfs_symlinkat (const char *oldpath, int newdirfd, const char *newpath)
+{
+}
+
+/* PVFS does not have hard links */
+ssize_t pvfs_link (const char *oldpath, const char *newpath)
+{
+}
+
+/* PVFS does not have hard links */
+int pvfs_linkat (const char *oldpath, int newdirfd,
+                 const char *newpath, int flags)
+{
+}
+
+/* this reads exactly one dirent, count is ignored */
+int pvfs_readdir(unsigned int fd, struct dirent *dirp, unsigned int count)
+{
+
+    return 1; /* success */
+    return 0; /* end of file */
+    return -1; /* error */
+}
+
+/* this reads multiple dirents, up to count */
+int pvfs_getdents(unsigned int fd, struct dirent *dirp, unsigned int count)
+{
+    int bytes;
+    return bytes; /* success */
+    return 0; /* end of file */
+    return -1; /* error */
+}
+
+int pvfs_access (const char * path, int mode)
+{
+}
+
+int pvfs_faccessat (int dirfd, const char * path, int mode, int flags)
+{
+}
+
+int pvfs_flock(int fd, int op)
+{
+}
+
+int pvfs_fcntl(int fd, int cmd, ...)
+{
+    va_list ap;
+    long arg;
+    struct flock *lock;
+}
+
+/* sync all disk data */
+void pvfs_sync(void )
+{
+}
+
+/* sync file, but not dir it is in */
+int pvfs_fsync(int fd)
+{
+    return 0; /* success */
+}
+
+/* does not sync file metadata */
+int pvfs_fdatasync(int fd)
+{
+    return 0; /* success */
+}
+
+mode_t pvfs_umask(mode_t mask)
+{
+    mode_t old_mask = mask_val;
+    mask_val = mask & 0777;
+    return old_mask;
+}
+
+mode_t pvfs_getumask(void)
+{
+    return mask_val;
+}
+
+int pvfs_getdtablesize(void)
+{
+    return pvfs_descriptor_table_size();
+}
+
+posix_ops pvfs_ops = 
+{
+    .statfs = statfs,
+    .open = pvfs_open,
+    .open64 = pvfs_open64,
+    .openat = pvfs_openat,
+    .openat64 = pvfs_openat64,
+    .creat = pvfs_creat,
+    .creat64 = pvfs_creat64,
+    .unlink = pvfs_unlink,
+    .unlinkat = pvfs_unlinkat,
+    .rename = pvfs_rename,
+    .renameat = pvfs_renameat,
+    .read = pvfs_read,
+    .pread = pvfs_pread,
+    .readv = pvfs_readv,
+    .pread64 = pvfs_pread64,
+    .write = pvfs_write,
+    .pwrite = pvfs_pwrite,
+    .writev = pvfs_writev,
+    .write64 = pvfs_write64,
+    .lseek = pvfs_lseek,
+    .lseek64 = pvfs_lseek64,
+    .truncate = pvfs_truncate,
+    .truncate64 = pvfs_truncate64,
+    .ftruncate = pvfs_ftruncate,
+    .ftruncate64 = pvfs_ftruncate64,
+    .close = pvfs_close,
+    .flush = pvfs_flush,
+    .stat = pvfs_stat,
+    .stat64 = pvfs_stat64,
+    .fstat = pvfs_fstat,
+    .fstat64 = pvfs_fstat64,
+    .fstatat = pvfs_fstatat,
+    .fstatat64 = pvfs_fstatat64,
+    .lstat = pvfs_lstat,
+    .lstat64 = pvfs_lstat64,
+    .dup = pvfs_dup,
+    .dup2 = pvfs_dup2,
+    .chown = pvfs_chown,
+    .fchown = pvfs_fchown,
+    .fchownat = pvfs_fchownat,
+    .lchown = pvfs_lchown,
+    .chmod = pvfs_chmod,
+    .fchmod = pvfs_fchmod,
+    .fchmodat = pvfs_fchmodat,
+    .lchmod = pvfs_lchmod,
+    .mkdir = pvfs_mkdir,
+    .mkdirat = pvfs_mkdirat,
+    .rmdir = pvfs_rmdir,
+    .readlink = pvfs_readlink,
+    .readlinkat = pvfs_readlinkat,
+    .symlink = pvfs_symlink,
+    .symlinkat = pvfs_symlinkat,
+    .link = pvfs_link,
+    .linkat = pvfs_linkat,
+    .readdir = pvfs_readdir,
+    .getdents = pvfs_getdents,
+    .access = pvfs_access,
+    .faccessat = pvfs_faccessat,
+    .flock = pvfs_flock,
+    .fcntl = pvfs_fcntl,
+    .sync = pvfs_sync,
+    .fsync = pvfs_fsync,
+    .fdatasync = pvfs_fdatasync,
+    .umask = pvfs_umask,
+    .getumask = pvfs_getumask,
+    .getdtablesize = pvfs_getdtablesize
+};
+
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
+

--- /dev/null	2004-06-24 14:04:38.000000000 -0400
+++ posix-pvfs.h	2011-02-08 16:39:34.000000000 -0500
@@ -0,0 +1,170 @@
+
+#ifndef POSIX_PVFS_H
+#define POSIX_PVFS_H 1
+
+/* pvfs_open */
+int pvfs_open(const char *path, int flags, ...);
+
+/* pvfs_open64 */
+int pvfs_open64(const char *path, int flags, ...);
+
+/* pvfs_openat */
+int pvfs_openat(int dirfd, const char *path, int flags, ...);
+
+/* pvfs_openat64 */
+int pvfs_openat64(int dirfd, const char *path, int flags, ...);
+
+int pvfs_creat(const char *path, mode_t mode, ...);
+
+int pvfs_creat64(const char *path, mode_t mode, ...);
+
+/* pvfs_unlink */
+int pvfs_unlink (const char *path);
+
+int pvfs_unlinkat (int dirfd, const char *path);
+
+int pvfs_rename(const char *oldpath, const char *newpath);
+
+int pvfs_renameat(int olddirfd, const char *oldpath,
+                  int newdirfd, const char *newpath);
+
+/* pvfs_read */
+ssize_t pvfs_read( int fd, void *buf, size_t count );
+
+/* pvfs_pread */
+ssize_t pvfs_pread( int fd, void *buf, size_t count, off_t offset );
+
+ssize_t pvfs_readv(int fd, const struct iovec *vector, int count);
+
+/* pvfs_pread64 */
+ssize_t pvfs_pread64( int fd, void *buf, size_t count, off64_t offset );
+
+/* pvfs_write */
+ssize_t pvfs_write( int fd, void *buf, size_t count );
+
+/* pvfs_pwrite */
+ssize_t pvfs_pwrite( int fd, void *buf, size_t count, off_t offset );
+
+ssize_t pvfs_writev( int fd, const struct iovec *vector, int count );
+
+/* pvfs_pwrite64 */
+ssize_t pvfs_write64( int fd, void *buf, size_t count, off64_t offset );
+
+/* pvfs_lseek */
+off_t pvfs_lseek(int fd, off_t offset, int whence);
+
+/* pvfs_lseek64 */
+off64_t pvfs_lseek64(int fd, off64_t offset, int whence);
+
+int pvfs_truncate(const char *path, off_t length);
+
+int pvfs_truncate64 (const char *path, off64_t length);
+
+int pvfs_ftruncate (int fd, off_t length);
+
+int pvfs_ftruncate64 (int fd, off64_t length);
+
+/* pvfs_close */
+int pvfs_close( int fd );
+
+int pvfs_flush(int fd);
+
+/* various flavors of stat */
+int pvfs_stat(const char *path, struct stat *buf);
+
+int pvfs_stat64(const char *path, struct stat64 *buf);
+
+int pvfs_fstat(int fd, struct stat *buf);
+
+int pvfs_fstat64(int fd, struct stat64 *buf);
+
+int pvfs_fstatat(int fd, char *path, struct stat *buf, int flag);
+
+int pvfs_fstatat64(int fd, char *path, struct stat64 *buf, int flag);
+
+int pvfs_lstat(const char *path, struct stat *buf);
+
+int pvfs_lstat64(const char *path, struct stat64 *buf);
+
+int pvfs_dup(int oldfd);
+
+int pvfs_dup2(int oldfd, int newfd);
+
+int pvfs_chown (const char *path, uid_t owner, gid_t group);
+
+int pvfs_fchown (int fd, uid_t owner, gid_t group);
+
+int pvfs_fchownat(int fd, char *path, uid_t owner, gid_t group, int flag);
+
+int pvfs_lchown (const char *path, uid_t owner, gid_t group);
+
+int pvfs_chmod (const char *path, mode_t mode);
+
+int pvfs_fchmod (int fd, mode_t mode);
+
+int pvfs_fchmodat(int fd, char *path, mode_t mode, int flag);
+
+/* this is not a Linux syscall, but its useful above */
+int pvfs_lchmod (const char *path, mode_t mode);
+
+int pvfs_mkdir (const char *path, mode_t mode);
+
+int pvfs_mkdirat (int dirfd, const char *path, mode_t mode);
+
+int pvfs_rmdir (const char *path);
+
+ssize_t pvfs_readlink (const char *path, char *buf, size_t bufsiz);
+
+int pvfs_readlinkat (int dirfd, const char *path, char *buf, size_t bufsiz);
+
+ssize_t pvfs_symlink (const char *oldpath, const char *newpath);
+
+int pvfs_symlinkat (const char *oldpath, int newdirfd, const char *newpath);
+
+/* PVFS does not have hard links */
+ssize_t pvfs_link (const char *oldpath, const char *newpath);
+
+/* PVFS does not have hard links */
+int pvfs_linkat (const char *oldpath, int newdirfd,
+                 const char *newpath, int flags);
+
+/* this reads exactly one dirent, count is ignored */
+int pvfs_readdir(unsigned int fd, struct dirent *dirp, unsigned int count);
+
+/* this reads multiple dirents, up to count */
+int pvfs_getdents(unsigned int fd, struct dirent *dirp, unsigned int count);
+
+int pvfs_access (const char * path, int mode);
+
+int pvfs_faccessat (int dirfd, const char * path, int mode, int flags);
+
+int pvfs_flock(int fd, int op);
+
+int pvfs_fcntl(int fd, int cmd, ...);
+
+/* sync all disk data */
+void pvfs_sync(void );
+
+/* sync file, but not dir it is in */
+int pvfs_fsync(int fd);
+
+/* does not sync file metadata */
+int pvfs_fdatasync(int fd);
+
+mode_t pvfs_umask(mode_t mask);
+
+mode_t pvfs_getumask(void);
+
+int pvfs_getdtablesize(void);
+
+#endif
+
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
+

--- /dev/null	2004-06-24 14:04:38.000000000 -0400
+++ posix.c	2011-02-08 16:39:34.000000000 -0500
@@ -0,0 +1,633 @@
+#include <usrint.h>
+
+static int pvfs_lib_init = 0; 
+
+posix_ops glibc_ops =
+{
+    .statfs = statfs
+};
+
+void load_glibc(void)
+{ 
+    pvfs_lib_init = 1; 
+    glibc_ops.open = dlsym(RTLD_NEXT, "open");
+    glibc_ops.open64 = dlsym(RTLD_NEXT, "open64");
+    glibc_ops.unlink = dlsym(RTLD_NEXT, "unlink");
+    glibc_ops.close = dlsym(RTLD_NEXT, "close");
+    glibc_ops.read = dlsym(RTLD_NEXT, "read");
+    glibc_ops.write = dlsym(RTLD_NEXT, "write");
+    glibc_ops.lseek = dlsym(RTLD_NEXT, "lseek");
+    glibc_ops.lseek64 = dlsym(RTLD_NEXT, "lseek64");
+    glibc_ops.pread = dlsym(RTLD_NEXT, "pread"); 
+    glibc_ops.pwrite = dlsym(RTLD_NEXT, "pwrite"); 
+    glibc_ops.readv = dlsym(RTLD_NEXT, "readv"); 
+    glibc_ops.writev = dlsym(RTLD_NEXT, "writev"); 
+}
+
+/*
+ * SYSTEM CALLS
+ */
+
+/*
+ * open wrapper
+ */ 
+int open(const char *path, int flags, ...)
+{ 
+    va_list ap; 
+    mode_t mode = 0; 
+    PVFS_hint hints;  /* need to figure out how to set default */
+    pvfs_descriptor *pd;
+    
+    if(!pvfs_lib_init) { 
+        load_glibc(); 
+    }
+
+    va_start(ap, flags); 
+    if (flags & O_CREAT)
+        mode = va_arg(ap, mode_t); 
+    else
+        mode = 0777;
+    if (flags & O_HINTS)
+        hints = va_arg(ap, PVFS_hint);
+    else
+       hints = PVFS_HINT_NULL;
+    va_end(ap); 
+
+    if(is_pvfs_path(path)) { 
+#ifdef DEBUG
+        printf("PVFS_OPEN\n"); 
+#endif
+        return pvfs_open(path, flags, mode, hints);
+    }
+    else {
+#ifdef DEBUG
+        printf("GLIBC_OPEN\n"); 
+#endif
+        pd = pvfs_alloc_descriptor(&glibc_ops);
+        pd->posix_fd = pd->fsops->open(path, flags, mode);
+        pd->flags = flags;
+        pd->is_in_use = 1;
+        return pd->fd; 
+    }
+}
+
+/*
+ * open64 wrapper 
+ */
+int open64(const char *path, int flags, ...)
+{ 
+    va_list ap; 
+    mode_t mode = 0; 
+    PVFS_hint hints;  /* need to figure out how to set default */
+    
+    if(!pvfs_lib_init) { 
+        load_glibc(); 
+    }
+
+    va_start(ap, flags); 
+    if (flags & O_HINTS)
+        hints = va_arg(ap, PVFS_hint);
+    else
+        hints = PVFS_HINT_NULL;
+    va_end(ap); 
+
+    return open(path, flags|O_LARGEFILE, mode, hints); 
+}
+
+int openat(int dirfd, const char *path, int flags, ...)
+{
+}
+
+int openat64(int dirfd, const char *path, int flags, ...)
+{
+}
+
+/*
+ * creat wrapper
+ */ 
+int creat(const char *path, mode_t mode)
+{ 
+    if(!pvfs_lib_init) { 
+        load_glibc(); 
+    }
+
+    return open(path, O_CREAT|O_WRONLY|O_TRUNC, mode); 
+}
+
+/*
+ * creat64 wrapper
+ */ 
+int creat64(const char *path, mode_t mode)
+{ 
+    if(!pvfs_lib_init) { 
+        load_glibc(); 
+    }
+
+    return open64(path, O_CREAT|O_WRONLY|O_TRUNC, mode); 
+}
+
+/*
+ * unlink wrapper 
+ */
+int unlink(const char *path)
+{
+    if (!pvfs_lib_init) {
+        load_glibc();
+    }
+    if (is_pvfs_path(path)) {
+#ifdef DEBUG
+        pvfs_debug("unlink: calling pvfs_unlink\n");
+#endif
+        return pvfs_ops.unlink(path);
+    }
+    else {
+#ifdef DEBUG
+        pvfs_debug("unlink: calling glibc_ops.unlink\n");
+#endif
+        return glibc_ops.unlink(path);
+    }
+}
+
+int unlinkat(int dirfd, const char *path)
+{
+}
+
+/*
+ * rename wrapper
+ */
+int rename (const char *old, const char *new)
+{
+}
+
+/* READING and WRITING SYSTEM CALL */
+
+/*
+ * read wrapper 
+ */
+ssize_t read(int fd, void *buf, size_t count)
+{
+    ssize_t rc; 
+    pvfs_descriptor *pd; 
+    
+    pd = pvfs_find_descriptor(fd);
+    if (pd)
+    {
+        rc = pd->fsops->read(fd, buf, count);
+        if (rc > 0)
+            pd->file_pointer += rc;
+    }
+    else
+    {
+        errno = EINVAL;
+        rc = -1;
+    }
+    return rc;
+}
+
+/*
+ * write wrapper 
+ */
+ssize_t write(int fd, const void *buf, size_t count)
+{
+    ssize_t rc; 
+    pvfs_descriptor *pd; 
+    
+    pd = pvfs_find_descriptor(fd);
+    if (pd)
+    {
+        rc = pd->fsops->write(fd, (void *)buf, count);
+        if (rc > 0)
+            pd->file_pointer += rc;
+    }
+    else
+    {
+        errno = EINVAL;
+        rc = -1;
+    }
+    return rc;
+}
+
+/*
+ * write wrapper 
+ */
+ssize_t pread(int fd, void *buf, size_t nbytes, off_t offset)
+{
+    ssize_t rc; 
+    pvfs_descriptor *pd; 
+    
+    pd = pvfs_find_descriptor(fd); 
+    if (pd)
+    {
+        rc = pd->fsops->pread(fd, (void *)buf, nbytes, offset); 
+        if (rc > 0)
+            pd->file_pointer += rc;
+    }
+    else
+    {
+        errno = EINVAL;
+        rc = -1;
+    }
+    return rc;
+} 
+
+/*
+ * write wrapper 
+ */
+ssize_t pwrite(int fd, const void *buf, size_t nbytes, off_t offset)
+{
+    ssize_t rc;
+    pvfs_descriptor *pd;
+    
+    pd = pvfs_find_descriptor(fd);
+    if (pd)
+    {
+        rc = pd->fsops->pwrite(fd, buf, nbytes, offset);
+        if (rc > 0)
+            pd->file_pointer += rc;
+    }
+    else
+    {
+        errno = EINVAL;
+        rc = -1;
+    }
+    return rc;
+}
+
+/*
+ * write wrapper 
+ */
+ssize_t readv(int fd, const struct iovec *iov, int iovcnt)
+{ 
+    ssize_t rc;
+    pvfs_descriptor *pd; 
+    
+    pd = pvfs_find_descriptor(fd); 
+    if (pd)
+    {
+        rc = pd->fsops->readv(fd, iov, iovcnt); 
+        if (rc > 0)
+            pd->file_pointer += rc;
+    }
+    else
+    {
+        errno = EINVAL;
+        rc = -1;
+    }
+    return rc;
+}
+
+/*
+ * write wrapper 
+ */
+ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
+{ 
+    ssize_t rc;
+    pvfs_descriptor *pd;
+    
+    pd = pvfs_find_descriptor(fd);
+    if (pd)
+    {
+        rc = pd->fsops->writev(fd, iov, iovcnt);
+        if (rc > 0)
+            pd->file_pointer += rc;
+    }
+    else
+    {
+        errno = EINVAL;
+        rc = -1;
+    }
+    return rc;
+}
+
+/* SEEK system calls */
+
+/*
+ * lseek wrapper 
+ */
+off_t lseek(int fd, off_t offset, int whence)
+{
+    off64_t rc = lseek64(fd, (off64_t)offset, whence);
+    if (rc & 0xffffffff00000000)
+    {
+        errno = EINVAL;
+        rc = -1;
+    }
+    return (off_t)rc;
+}
+
+/* 
+ * lseek64 wrapper 
+ */ 
+off64_t lseek64(int fd, off64_t offset, int whence)
+{
+    off64_t rc;
+    pvfs_descriptor *pd;
+    
+    pd = pvfs_find_descriptor(fd);
+    if (pd)
+    {
+        rc = pd->fsops->lseek64(fd, offset, whence);
+        if (rc != -1)
+            pd->file_pointer = rc;
+    }
+    else
+    {
+        errno = EBADF;
+        rc = (off64_t)-1;
+    }
+    return rc;
+}
+
+int truncate(const char *path, off_t length)
+{
+}
+
+int truncate64(const char *path, off64_t length)
+{
+}
+
+int ftruncate(int fd, off_t length)
+{
+}
+
+int ftruncate64(int fd, off64_t length)
+{
+}
+
+/*
+ * close wrapper 
+ */
+int close(int fd)
+{
+    pvfs_descriptor *pd;
+    
+    pd = pvfs_find_descriptor(fd);
+    if (pd)
+    {
+        pd->fsops->flush(pd->posix_fd);
+        pd->fsops->close(pd->posix_fd);
+        pvfs_free_descriptor(pd);
+        return 0;
+    }
+    else
+    {
+        errno = EBADF;
+        return -1;
+    }
+}
+
+int flush(int fd)
+{
+}
+
+/* various flavors of stat */
+int stat(const char *path, struct stat *buf)
+{
+    if(is_pvfs_path(path))
+    { 
+        return pvfs_stat(path, buf);
+    }
+    else
+    {
+        return glibc_ops.stat(path, buf);
+    }
+}
+
+int __xstat(int ver, const char *path, struct stat *buf)
+{
+    return stat(path, buf);
+}
+
+int stat64(const char *path, struct stat64 *buf)
+{
+    if(is_pvfs_path(path))
+    { 
+        return pvfs_stat64(path, buf);
+    }
+    else
+    {
+        return glibc_ops.stat64(path, buf);
+    }
+}
+
+int __xstat64(int ver, const char *path, struct stat64 *buf)
+{
+    return stat64(path, buf);
+}
+
+int fstat(int fd, struct stat *buf)
+{
+    int rc;
+    pvfs_descriptor *pd;
+    
+    pd = pvfs_find_descriptor(fd);
+    if (pd)
+    {
+        rc = pd->fsops->fstat(pd->posix_fd, buf);
+    }
+    else
+    {
+        errno = EINVAL;
+        rc = -1;
+    }
+    return rc;
+}
+
+int __fxstat(int ver, int fd, struct stat *buf)
+{
+    return fstat(fd, buf);
+}
+
+int fstat64(int fd, struct stat64 *buf)
+{
+    int rc;
+    pvfs_descriptor *pd;
+    
+    pd = pvfs_find_descriptor(fd);
+    if (pd)
+    {
+        rc = pd->fsops->fstat64(pd->posix_fd, buf);
+    }
+    else
+    {
+        errno = EINVAL;
+        rc = -1;
+    }
+    return rc;
+}
+
+int __fxstat64(int ver, int fd, struct stat64 *buf)
+{
+    return fstat64(fd, buf);
+}
+
+int lstat(const char *path, struct stat *buf)
+{
+    if(is_pvfs_path(path))
+    { 
+        return pvfs_lstat(path, buf);
+    }
+    else
+    {
+        return glibc_ops.lstat(path, buf);
+    }
+}
+
+int __lxstat(int ver, const char *path, struct stat *buf)
+{
+    return lstat(path, buf);
+}
+
+int lstat64(const char *path, struct stat64 *buf)
+{
+    if(is_pvfs_path(path))
+    { 
+        return pvfs_lstat64(path, buf);
+    }
+    else
+    {
+        return glibc_ops.lstat64(path, buf);
+    }
+}
+
+int __lxstat64(int ver, const char *path, struct stat64 *buf)
+{
+    return lstat64(path, buf);
+}
+
+#if 0
+int dup()
+{
+}
+
+int dup2()
+{
+}
+
+int chown()
+{
+}
+
+int fchown()
+{
+}
+
+int fchownat()
+{
+}
+
+int lchown()
+{
+}
+
+int chmod()
+{
+}
+
+int fchmod()
+{
+}
+
+int fchmodat()
+{
+}
+
+int lchmod()
+{
+}
+
+int mkdir()
+{
+}
+
+int mdirat()
+{
+}
+
+int rmdir()
+{
+}
+
+ssize_t readlink()
+{
+}
+
+int readlinkat()
+{
+}
+
+ssize_t symlink()
+{
+}
+
+int symlinkat()
+{
+}
+
+ssize_t link()
+{
+}
+
+int linkat()
+{
+}
+
+#endif
+
+/* linux discourages using readdir system calls, so for now
+ * we will leave them out - there are stdio calls that can
+ * be used
+ */
+
+#if 0
+
+int access (int fd, int op)
+{
+}
+
+int faccessat (int fd, int op)
+{
+}
+
+int flock (int fd, int op)
+{
+}
+
+int fcntl (int fd, int op)
+{
+}
+
+int sync (int fd, int op)
+{
+}
+
+int fsync (int fd, int op)
+{
+}
+
+int fdatasync (int fd, int op)
+{
+}
+
+int umask (int fd, int op)
+{
+}
+
+int getumask (int fd, int op)
+{
+}
+
+int getdtablesize (int fd, int op)
+{
+}
+
+#endif
+
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */

--- /dev/null	2004-06-24 14:04:38.000000000 -0400
+++ stdio-pvfs.h	2011-02-08 16:39:34.000000000 -0500
@@ -0,0 +1,24 @@
+
+#ifdef stdin
+#undef stdin
+#endif
+
+#define stdin (&pvfs_stdin)
+
+#ifdef stdout
+#undef stdout
+#endif
+
+#define stdout (&pvfs_stdout)
+
+#ifdef stderr
+#undef stderr
+#endif
+
+#define stderr (&pvfs_stderr)
+
+#ifdef FILE
+#undef FILE
+#endif
+
+#define FILE pvfs_descriptor

--- /dev/null	2004-06-24 14:04:38.000000000 -0400
+++ stdio.c	2011-02-08 16:39:34.000000000 -0500
@@ -0,0 +1,867 @@
+#include <usrint.h>
+#include <dirent.h>
+
+/* STDIO implementation - this gives users something to link to
+ * that will call back to the PVFS lib - also lets us optimize
+ * in a few spots like buffer sizes and stuff
+ */
+
+
+/*
+ *fopen wrapper 
+ */ 
+
+FILE *fopen(const char * path, const char * mode)
+{ 
+    int flags = 0, fd = 0;
+    mode_t perm = 0;
+    pvfs_descriptor *pd = NULL;
+    const char *p = NULL;
+    int append = false, read = false, write = false, update = false;
+    int exclusive = false;
+
+    if(!pvfs_lib_init)
+    { 
+        load_glibc(); 
+    } 
+
+    /* look for fopen modes */ 
+    for(p = mode; *p; p++)
+    { 
+        switch(*p) { 
+            case 'a':
+                append = true; 
+                if (read || write)
+                {
+                    errno = EINVAL;
+                    return NULL;
+                }
+                break; 
+            case 'r':
+                read = true; 
+                if (append || write)
+                {
+                    errno = EINVAL;
+                    return NULL;
+                }
+                break; 
+            case 'w':
+                write = true; 
+                if (read || append)
+                {
+                    errno = EINVAL;
+                    return NULL;
+                }
+                break; 
+            case '+':
+                update = true; 
+                if (!(read || write || append))
+                {
+                    errno = EINVAL;
+                    return NULL;
+                }
+                break;
+            case 'b': /* this is ignored in POSIX */
+            case 'c': /* used in glibc ignored here */
+            case 'm': /* used in glibc ignored here */
+                break;
+            case 'x': /* glibc extension */
+                exclusive = true;
+                if (!(read || write || append))
+                {
+                    errno = EINVAL;
+                    return NULL;
+                }
+                break;
+            default:
+                errno = EINVAL;
+                return NULL;
+                break; 
+        }
+    }
+    /* this catches an empty mode */
+    if (!(read || write || append))
+    {
+        errno = EINVAL;
+        return NULL;
+    }
+    if (read)
+    { 
+        flags = O_RDONLY; 
+    }
+    else if(read && update)
+    { 
+        flags = O_RDWR; 
+    }
+    else if(write)
+    { 
+        flags = O_WRONLY | O_CREAT | O_TRUNC; 
+    } 
+    else if(write && update)
+    { 
+        flags = O_RDWR | O_CREAT | O_TRUNC; 
+    }
+    else if(append)
+    { 
+        flags = O_WRONLY | O_APPEND | O_CREAT; 
+    } 
+    else if (append && update)
+    { 
+        flags = O_RDWR | O_APPEND | O_CREAT; 
+    }
+    if (exclusive) /* check this regardless of the above */
+    {
+        flags |= O_EXCL;
+    }
+     
+    /* this is our version of open */
+    fd = open(path, flags, 0666); 
+
+    if(fd)
+    { 
+        pd = pvfs_find_descriptor(fd);
+        /* set up buffering here */
+        pd->bufsize = pd->fsops->buffsize();
+        pd->buf = malloc(pd->bufsize);
+        pd->buftotal = 0;
+        pd->buf_off = 0;
+        pd->bufptr = 0;
+        return PFILE2FILE(pd); 
+    }
+    else
+    { 
+        pvfs_debug("pvfs call to open failed\n"); 
+        return NULL; 
+    }
+}
+
+FILE *fdopen(int fd, const char *mode)
+{
+    pvfs_descriptor *pd;
+    pd = pvfs_find_descriptor(fd);
+    /* check for valid mode here */
+    /* set up buffering here */
+    return PFILE2FILE(pd); 
+}
+
+FILE *freopen(const char *path, const char *mode, FILE *stream)
+{
+    pvfs_descriptor *pd = FILE2PFILE(stream)
+    /* see if stream is in use - if so close the file */
+    /* open the file and put its info in the given descriptor */
+    return PFILE2FILE(pd);
+}
+
+/*
+ * fwrite wrapper
+ */
+size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
+{
+    off64_t rsz, rstart, rend;
+    off64_t firstblk, firstoff, firstsize;
+    off64_t lastblk, lastoff, lastsize;
+    off64_t curblk, numblk;
+
+    if (!stream || !stream->is_in_use || !ptr) {
+        errno = EBADF;
+        return 0;
+    }
+    /* rsz: request size in bytes */
+    rsz = size * nmemb;
+    /* rstart: first byte of request */
+    rstart = stream->file_pointer;
+    /* rend: last byte of request */
+    rend = rstart + rsz - 1;
+
+    /* file is divided into blocks from 0..N-1 */
+    /* curblk: block number of current buffer */
+    if (stream->buf_off == -1)
+    {
+        curblk = -1;
+        stream->dirty = 0;
+    }
+    else
+    {
+        curblk = stream->buff_off/stream->bufsize;
+    }
+    /* firstblk: block number with first byte of request */
+    firstblk = rstart/stream->bufsize;
+    /* firstoff: offset from start of first block */
+    /* firstoff is in 0..blocksize */
+    firstoff = rstart%stream->bufsize;
+    /* lastblk: block number with last byte of request */
+    lastblk = rend/stream->bufsize;
+    /* lastoff: offset from start of last block */
+    /* lastoff is in 0..blocksize */
+    lastoff = rend%stream->bufsize;
+    /* numblk: number of blocks involved in request */
+    numblk = (lastblk - firstblk) + 1;
+    /* firstsize: number of bytes on first block of request */
+    /* firstsize is in 1..blocksize */
+    firstsize = (firstblk==lastblk) ? lastoff-firstoff+1 :
+    stream->bufsize-firstoff;
+    /* lastsize: number of bytes on last block of request */
+    /* lastsize is in 0..blocksize */
+    lastsize = (firstblk == lastblk) ? 0 : lastoff+1;
+    
+
+    /* if the current buffer is not involved, flush it */
+    if (curblk < firstblk || curblk > lastblk)
+    {
+        if (stream->dirty)
+            write(stream->fd, stream->buffer, stream->bufsize);
+        stream->dirty = 0;
+        stream->buf_off = -1;
+        curblk = -1;
+        /* write completes below - file pointer already in position */
+    }
+    /* if current buffer is completely overwritten, ignore it */
+    else if ((curblk > firstblk && curblk < lastblk) ||
+            (curblk == firstblk && firstsize == stream->bufsize) ||
+            (curblk == lastblk && lastsize = stream->bufsize))
+    {
+        stream->dirty = 0;
+        stream->buf_off = -1;
+        curblk = -1;
+        /* write completes below - file pointer already in position */
+    }
+    /* if current buffer is first, copy bytes */
+    else if (curblk == firstblk && firstsize < stream->bufsize)
+    {
+        memcopy(stream->buf+firstoff, ptr, firstsize);
+        if (numblk > 1)
+        {
+            lseek(stream->fd, stream->buf_off, SEEK_SET);
+            write(stream->fd, stream->buf, stream->bufsize);
+            stream->dirty = 0;
+            stream->buf_off = -1;
+        }
+        ptr += firstsize;
+        rsz -= firstsize;
+        /* write completes below - file pointer left in position */
+    }
+    /* now write the data */
+    if (lastsize > 0) /* write to the middle of a block */
+    {
+        /* should already be in position to write request data */
+        write(stream->fd, ptr, rsz-lastsize);
+        /* see if the last block is not the one already loaded */
+        if (curblk != lastblk)
+        {
+            /* cannot have a valid block in the buffer */
+            if (curblk != -1)
+            {
+                errno = 100;
+                return -1;
+            }
+            /* locate new buffer block */
+            stream->buf_off = lastblock * stream->bufsize;
+            /* load a new buffer - file pointer should be in position */
+            stream->buftotal = read(stream->fd, stream->buf, stream->bufsize);
+        }
+        /* move last of request data to buffer */
+        memcopy(stream->buf, ptr+(rsz-lastsize), lastsize);
+        /* move file pointer back to end of request */
+        stream->file_pointer = stream->buf_off+lastsize;
+        /* see of we extended the file */
+        if (lastsize > stream->buftotal)
+            stream->buftotal = lastsize;
+    }
+    else /* writes to the end of a block */
+    {
+        /* should already be in position */
+        write(stream->fd, ptr, rsz);
+    }
+    /* file pointer should be in right place */
+    return rsz;
+}
+
+/*
+ * fread wrapper
+ */
+size_t fread(const void *ptr, size_t size, size_t nmemb, FILE *stream)
+{
+    off64_t rsz, rstart, rend;
+    off64_t firstblk, firstoff, firstsize;
+    off64_t lastblk, lastoff, lastsize;
+    off64_t curblk, numblk;
+
+    if (!stream || !stream->is_in_use || !ptr) {
+        errno = EBADF;
+        return 0;
+    }
+    /* rsz: request size in bytes */
+    rsz = size * nmemb;
+    /* rstart: first byte of request */
+    rstart = stream->file_pointer;
+    /* rend: last byte of request */
+    rend = rstart + rsz - 1;
+
+    /* file is divided into blocks from 0..N-1 */
+    /* curblk: block number of current buffer */
+    if (stream->buf_off == -1)
+    {
+        curblk = -1;
+        stream->dirty = 0;
+    }
+    else
+    {
+        curblk = stream->buff_off/stream->bufsize;
+    }
+    /* firstblk: block number with first byte of request */
+    firstblk = rstart/stream->bufsize;
+    /* firstoff: offset from start of first block */
+    /* firstoff is in 0..blocksize */
+    firstoff = rstart%stream->bufsize;
+    /* lastblk: block number with last byte of request */
+    lastblk = rend/stream->bufsize;
+    /* lastoff: offset from start of last block */
+    /* lastoff is in 0..blocksize */
+    lastoff = rend%stream->bufsize;
+    /* numblk: number of blocks involved in request */
+    numblk = (lastblk - firstblk) + 1;
+    /* firstsize: number of bytes on first block of request */
+    /* firstsize is in 1..blocksize */
+    firstsize = (firstblk==lastblk) ? lastoff-firstoff+1 :
+    stream->bufsize-firstoff;
+    /* lastsize: number of bytes on last block of request */
+    /* lastsize is in 0..blocksize */
+    lastsize = (firstblk == lastblk) ? 0 : lastoff+1;
+    
+
+    /* if the current buffer is not involved, flush it */
+    if (curblk < firstblk || curblk > lastblk)
+    {
+        if (stream->dirty)
+            write(stream->fd, stream->buffer, stream->bufsize);
+        stream->dirty = 0;
+        stream->buf_off = -1;
+        curblk = -1;
+        /* write completes below - file pointer already in position */
+    }
+    /* if current buffer is completely read, break into two reads */
+    else if ((curblk > firstblk && curblk < lastblk) ||
+            (curblk == firstblk && firstsize == stream->bufsize) ||
+            (curblk == lastblk && lastsize = stream->bufsize))
+    {
+        /* read from start up to buffer */
+        /* copy buffer */
+        /* if buffer dirty, flush */
+        if (stream->dirty)
+        {
+            lseek(stream->fd, stream->buf_off, SEEK_SET);
+            write(stream->fd, stream->buf, stream->bufsize);
+            stream->dirty = 0;
+            stream->buf_off = -1;
+            curblk = -1;
+        }
+        /* read completes below - file pointer already in position */
+    }
+    /* if current buffer is first, copy bytes */
+    else if (curblk == firstblk && firstsize < stream->bufsize)
+    {
+        memcopy(ptr, stream->buf+firstoff, firstsize);
+        /* if buffer dirty, flush */
+        if (stream->dirty)
+        {
+            lseek(stream->fd, stream->buf_off, SEEK_SET);
+            write(stream->fd, stream->buf, stream->bufsize);
+            stream->dirty = 0;
+            stream->buf_off = -1;
+        }
+        ptr += firstsize;
+        rsz -= firstsize;
+        /* read completes below - file pointer left in position */
+    }
+    /* now read the data */
+    if (lastsize > 0) /* read to the middle of a block */
+    {
+        /* should already be in position to read request data */
+        read(stream->fd, ptr, rsz-lastsize);
+        /* see if the last block is not the one already loaded */
+        if (curblk != lastblk)
+        {
+            /* cannot have a valid block in the buffer */
+            if (curblk != -1)
+            {
+                errno = 100;
+                return -1;
+            }
+            /* locate new buffer block */
+            stream->buf_off = lastblock * stream->bufsize;
+            /* load a new buffer - file pointer should be in position */
+            stream->buftotal = read(stream->fd, stream->buf, stream->bufsize);
+        }
+        /* move last of request data to buffer */
+        memcopy(ptr+(rsz-lastsize), stream->buf, lastsize);
+        /* move file pointer back to end of request */
+        stream->file_pointer = stream->buf_off+lastsize;
+    }
+    else /* writes to the end of a block */
+    {
+        /* should already be in position */
+        read(stream->fd, ptr, rsz);
+    }
+    /* file pointer should be in right place */
+    return rsz;
+}
+
+/*
+ * fclose wrapper
+ */
+int fclose(FILE *stream)
+{
+    return close(stream->fd);
+}
+
+/*
+ * fseek wrapper
+ */
+off_t fseek(FILE *stream, off_t offset, int whence)
+{
+    return (off_t)lseek64(stream->fd, (off64_t)offset, whence);
+}
+
+/*
+ * fseek64 wrapper
+ */
+off64_t fseek64(FILE *stream, off64_t offset, int whence)
+{
+    return lseek64(stream->fd, offset, whence);
+}
+
+/*
+ * fsetpos wrapper
+ */
+int fsetpos(FILE *stream, fpos_t *pos)
+{
+    return lseek(stream->fd, *pos, SEEK_SET);
+}
+
+/*
+ * rewind wrapper
+ */
+void rewind(FILE *stream)
+{
+    lseek(stream->fd, 0, SEEK_SET);
+}
+
+/*
+ * ftell wrapper
+ */
+long ftell(FILE *stream)
+{
+    return (long)stream->file_pointer;
+}
+
+/*
+ * fgetpos wrapper
+ */
+int fgetpos(FILE *stream, fpos_t *pos)
+{
+    *pos = stream->file_pointer;
+    return 0;
+}
+
+/*
+ * fflush wrapper
+ */
+int fflush(FILE *stream)
+{
+    int rc = 0;
+    if (stream)
+    {
+        if (stream->buf && stream->dirty)
+        {
+            lseek64(stream->fd, stream->buf_off, SEEK_SET);
+            /* buftotal should equal bufsize unless the buffer */
+            /* is at the end of the file and the buffer is too */
+            /* big - then buftotal is smaleer */
+            write(stream->fd, stream->buf, stream->buftotal);
+            stream->dirty = 0;
+        }
+    }
+    else
+    {
+        errno = EINVAL;
+        rc = -1;
+    }
+    return rc;
+}
+
+/*
+ * fputc wrapper
+ */
+int fputc(int c, FILE *stream)
+{
+    size_t len;
+    int rc;
+    if (!stream || !stream->is_in_use || !s)
+    {
+        errno = EBADF;
+        return 0;
+    }
+    rc = fwrite (&c, 1, 1, stream);
+    if (rc != 1)
+        rc = -1;
+    else
+        rc = c;
+    return rc;
+}
+
+/*
+ * fputs wrapper
+ */
+int fputs(const char *s, FILE *stream)
+{
+    size_t len;
+    int rc;
+    if (!stream || !stream->is_in_use || !s)
+    {
+        errno = EBADF;
+        return 0;
+    }
+    len = strlen(s);
+    return fwrite (s, len, 1, stream);
+}
+
+int putc(int c, FILE *stream)
+{
+    return fputc(c, stream);
+}
+
+int putchar(int c)
+{
+    return fputc(c, stdout);
+}
+
+int puts(const char *s, FILE *stream)
+{
+    fputs(s, stream);
+    return fputs("\n", stream);
+}
+
+/**
+ *
+ * fgets wrapper
+ */
+char *fgets(char *s, int size, FILE *stream)
+{
+    char *p;
+    long pos, current;
+    int rc;
+
+    if (!pvfs_lib_init) {
+        load_glibc();
+    }
+    if (!stream || stream->_fileno < 0) {
+        errno = EBADF;
+        return 0;
+    }
+    if (pvfs_find_descriptor(stream->_fileno)) {
+        pos = ftell(stream);
+#ifdef DEBUG
+        pvfs_debug("fgets: pos=%ld\n", pos);
+#endif
+        rc = pvfs_read(stream->_fileno, s, size);
+        if (rc > 0) {
+            p = strchr(s, '\n');
+            if (p) {
+                ++p;
+                *p = '\0';
+                pos += strlen(s);
+                current = ftell(stream);
+#ifdef DEBUG
+                pvfs_debug("fgets: s=%s (len=%d)", s, strlen(s));
+#endif
+                if (pos != current) {
+#ifdef DEBUG
+                    pvfs_debug("fgets: new pos=%ld, current=%ld\n", pos, current);
+#endif
+                    pvfs_lseek(stream->_fileno, pos, SEEK_SET);
+#ifdef DEBUG
+                    pvfs_debug("fgets: set pos=%ld\n", ftell(stream));
+#endif
+                }
+                return s;
+            }
+        }
+        return NULL;
+    }
+    else {
+#ifdef DEBUG
+        pvfs_debug("fgets: calling glibc_ops.fgets, s=%p, size=%ld, fd=%d\n",
+                    s, size, fileno(stream));
+#endif
+        return glibc_ops.fgets(s, size, stream);
+    }
+}
+
+/**
+ *
+ * fgetc wrapper
+ */
+int fgetc(FILE *stream)
+{
+    int rc, ch;
+
+    if (!pvfs_lib_init) {
+        load_glibc();
+    }
+    if (!stream || stream->_fileno < 0) {
+        errno = EBADF;
+        return 0;
+    }
+    if (pvfs_find_descriptor(stream->_fileno)) {
+#ifdef DEBUG
+        pvfs_debug("fgetc: calling pvfs_read\n");
+#endif
+        rc = pvfs_read(stream->_fileno, &ch, 1);
+        if (rc > 0) {
+            return ch;
+        }
+        else {
+            errno = EBADF;
+            return EOF;
+        }
+    }
+    else {
+#ifdef DEBUG
+        pvfs_debug("fgetc: calling glibc_ops.fgetc\n");
+#endif
+        return glibc_ops.fgetc(stream);
+    }
+}
+
+/**
+ *
+ * getc wrapper
+ */
+int getc(FILE *stream)
+{
+    return fgetc(stream);
+}
+
+int getchar(void)
+{
+    return fgetc(stream);
+}
+
+char *gets(char * s)
+{
+}
+
+/**
+ *
+ * ungetc wrapper
+ */
+int ungetc(int c, FILE *stream)
+{
+    long pos;
+
+    if (!pvfs_lib_init) {
+        load_glibc();
+    }
+    if (!stream || stream->_fileno < 0) {
+        errno = EBADF;
+        return 0;
+    }
+    if (pvfs_find_descriptor(stream->_fileno)) {
+#ifdef DEBUG
+        pvfs_debug("ungetc: current pos=%ld\n", ftell(stream));
+#endif
+        pos = ftell(stream) - 1;
+        pvfs_lseek(stream->_fileno, pos, SEEK_SET);
+#ifdef DEBUG
+        pvfs_debug("ungetc: set pos=%ld\n", ftell(stream));
+#endif
+        return c;
+    }
+    else {
+#ifdef DEBUG
+        pvfs_debug("ungetc: calling glibc_ops.ungetc\n");
+#endif
+        return glibc_ops.ungetc(c, stream);
+    }
+}
+
+/**
+ *
+ * fprintf wrapper
+ */
+int fprintf(FILE *stream, const char *format, ...)
+{
+    char *buf = NULL;
+    size_t len;
+    va_list ap;
+    int rc;
+
+    if (!pvfs_lib_init) {
+        load_glibc();
+    }
+    if (!stream || stream->_fileno < 0) {
+        errno = EBADF;
+        return 0;
+    }
+    if (pvfs_find_descriptor(stream->_fileno)) {
+        va_start(ap, format);
+        len = vasprintf(&buf, format, ap);
+        va_end(ap);
+        if (len > 0 && buf) {
+            rc = pvfs_write(stream->_fileno, buf, len);
+        }
+        else {
+#ifdef DEBUG
+            pvfs_debug("fprintf: vasprintf error\n", buf);
+#endif
+            errno = EIO;
+            rc = -1;
+        }
+        if (buf) {
+            free(buf);
+        }
+        return rc;
+    }
+    else {
+#ifdef DEBUG
+        pvfs_debug("fprintf: calling glibc_ops.fprintf for %d\n", stream->_fileno );
+#endif
+        return glibc_ops.fprintf(stream, format, ap);
+    }
+}
+
+#if 0
+printf()
+{
+}
+
+fscanf()
+{
+}
+
+scanf()
+{
+}
+#endif
+
+/*
+ * Stdio utilities for EOF, error, etc
+ */
+void clearerr (FILE *pf)
+{
+    if (pf && pf->is_in_use)
+    {
+        pf->eof = 0;
+        pf->error = 0;
+    }
+}
+
+int feof (FILE *pf)
+{
+    if (pf && pf->is_in_use)
+    {
+        if (pf->eof)
+            return -1;
+        return 0;
+    }
+    return 0;
+}
+
+int ferror (FILE *pf)
+{
+    if (pf && pf->is_in_use)
+    {
+        if (pf->error)
+            return -1;
+        return 0;
+    }
+    return 0;
+}
+
+int fileno (FILE *pf)
+{
+    if (pf && pf->is_in_use)
+        return pf->fd;
+    errno = EBADF;
+    return -1;
+}
+
+int remove (const char *path)
+{
+    int rc;
+    struct stat buf;
+
+    rc = stat(path, &buf);
+    if (S_ISDIR(buf.st_mode))
+        return rmdir (path);
+    return unlink (path);
+}
+
+void setbuf (FILE *pf, char *buf)
+{
+    setvbuf(pd, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
+}
+
+void setbuffer (FILE *pf, char *buf, size_t size)
+{
+    setvbuf(pd, buf, buf ? _IOFBF : _IONBF, size);
+}
+
+void setlinbuf (FILE *pf)
+{
+    setvbuf(pd, (chat *)NULL, buf ? _IOLBF : 0);
+}
+
+int setvbuf (FILE *pf, char *buf, int mode, size_t size)
+{
+}
+
+FILE *tmpfile(void)
+{
+}
+
+DIR *opendir (const char *name)
+{
+}
+
+int dirfd (DIR *dir)
+{
+}
+
+int readdir (unsigned in fd, sruct dirent *dirp, unsigned in count)
+{
+}
+
+void rewinddir (DIR *dir)
+{
+}
+
+int scandir (const char *dir, struct dirent ***namelist,
+             int(*filter)(const struct dirent *),
+             int(*compar)(const struct dirent **,cost struct dirent **))
+{
+}
+
+void seekdir (DIR *dir, off_t offset)
+{
+}
+
+off_t telldir (DIR *dir)
+{
+}
+
+int closedir (DIR *dir)
+{
+}
+
+
+/* tmpname ??? */
+
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */

--- /dev/null	2004-06-24 14:04:38.000000000 -0400
+++ usrint.h	2011-02-08 16:39:34.000000000 -0500
@@ -0,0 +1,194 @@
+
+#ifndef USRINT_H
+#define USRINT_H 1
+
+#define _LARGEFILE64_SOURCE 1
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <libgen.h>
+#include <string.h>
+#include <stdarg.h>
+#include <memory.h>
+#include <limits.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/resource.h>
+/* #include <sys/statvfs.h> /* struct statfs on OS X */
+#include <sys/vfs.h> /* struct statfs on Linux */
+#include <sys/stat.h>
+#include <linux/types.h>
+#include <linux/dirent.h>
+#define __USE_ATFILE 1
+#include <fcntl.h>
+#include <time.h>
+#include <sys/uio.h>
+#define __USE_GNU 1
+#include <dlfcn.h>
+
+//#include <mpi.h>
+#include <pvfs2.h>
+#include <pvfs2-hint.h>
+
+#include <posix-pvfs.h>
+
+#define _GNU_SOURCE
+
+/* magic numbers for PVFS filesystem */
+#define PVFS_FS 537068840
+#define LINUX_FS 61267
+
+#define PVFS_FD_SUCCESS 0
+#define PVFS_FD_FAILURE -1
+
+/* Defines GNU's O_NOFOLLOW flag to be false if its not set */ 
+#ifndef O_NOFOLLOW
+#define O_NOFOLLOW 0
+#endif
+#define max(x, y) (((x) > (y)) ? (x) : (y))
+#define true   1 
+#define false  0 
+#define O_HINTS 02000000
+
+/* POSIX functions */ 
+
+typedef struct posix_ops_s
+{   
+    int (*statfs)(const char *path, struct statfs *buf);
+    int (*open)(const char *path, int flags, ...);
+    int (*open64)(const char *path, int flags, ...);
+    int (*openat)(int dirfd, const char *path, int flags, ...);
+    int (*openat64)(int dirfd, const char *path, int flags, ...);
+    int (*creat)(const char *path, mode_t mode, ...);
+    int (*creat64)(const char *path, mode_t mode, ...);
+    int (*unlink)(const char *path);
+    int (*unlinkat)(int dirfd, const char *path);
+    int (*rename)(const char *oldpath, const char *newpath);
+    int (*renameat)(int olddirfd, const char *oldpath,
+                    int newdirfd, const char *newpath);
+    ssize_t (*read)( int fd, void *buf, size_t count);
+    ssize_t (*pread)( int fd, void *buf, size_t count, off_t offset);
+    ssize_t (*readv)(int fd, const struct iovec *vector, int count);
+    ssize_t (*pread64)( int fd, void *buf, size_t count, off64_t offset);
+    ssize_t (*write)( int fd, void *buf, size_t count);
+    ssize_t (*pwrite)( int fd, void *buf, size_t count, off_t offset);
+    ssize_t (*writev)( int fd, const struct iovec *vector, int count);
+    ssize_t (*write64)( int fd, void *buf, size_t count, off64_t offset);
+    off_t (*lseek)(int fd, off_t offset, int whence);
+    off64_t (*lseek64)(int fd, off64_t offset, int whence);
+    int (*truncate)(const char *path, off_t length);
+    int (*truncate64)(const char *path, off64_t length);
+    int (*ftruncate)(int fd, off_t length);
+    int (*ftruncate64)(int fd, off64_t length);
+    int (*close)( int fd);
+    int (*flush)(int fd);
+    int (*stat)(const char *path, struct stat *buf);
+    int (*stat64)(const char *path, struct stat64 *buf);
+    int (*fstat)(int fd, struct stat *buf);
+    int (*fstat64)(int fd, struct stat64 *buf);
+    int (*fstatat)(int fd, char *path, struct stat *buf, int flag);
+    int (*fstatat64)(int fd, char *path, struct stat64 *buf, int flag);
+    int (*lstat)(const char *path, struct stat *buf);
+    int (*lstat64)(const char *path, struct stat64 *buf);
+    int (*dup)(int oldfd);
+    int (*dup2)(int oldfd, int newfd);
+    int (*chown)(const char *path, uid_t owner, gid_t group);
+    int (*fchown)(int fd, uid_t owner, gid_t group);
+    int (*fchownat)(int fd, char *path, uid_t owner, gid_t group, int flag);
+    int (*lchown)(const char *path, uid_t owner, gid_t group);
+    int (*chmod)(const char *path, mode_t mode);
+    int (*fchmod)(int fd, mode_t mode);
+    int (*fchmodat)(int fd, char *path, mode_t mode, int flag);
+    int (*lchmod)(const char *path, mode_t mode);
+    int (*mkdir)(const char *path, mode_t mode);
+    int (*mkdirat)(int dirfd, const char *path, mode_t mode);
+    int (*rmdir)(const char *path);
+    ssize_t (*readlink)(const char *path, char *buf, size_t bufsiz);
+    int (*readlinkat)(int dirfd, const char *path, char *buf, size_t bufsiz);
+    ssize_t (*symlink)(const char *oldpath, const char *newpath);
+    int (*symlinkat)(const char *oldpath, int newdirfd, const char *newpath);
+    ssize_t (*link)(const char *oldpath, const char *newpath);
+    int (*linkat)(const char *oldpath, int newdirfd,
+                  const char *newpath, int flags);
+    int (*readdir)(unsigned int fd, struct dirent *dirp, unsigned int count);
+    int (*getdents)(unsigned int fd, struct dirent *dirp, unsigned int count);
+    int (*access)(const char * path, int mode);
+    int (*faccessat)(int dirfd, const char * path, int mode, int flags);
+    int (*flock)(int fd, int op);
+    int (*fcntl)(int fd, int cmd, ...);
+    void (*sync)(void);
+    int (*fsync)(int fd);
+    int (*fdatasync)(int fd);
+    mode_t (*umask)(mode_t mask);
+    mode_t (*getumask)(void);
+    int (*getdtablesize)(void);
+} posix_ops;
+
+extern posix_ops glibc_ops;
+extern posix_ops pvfs_ops;
+
+/* PVFS Descriptor table entry */
+typedef struct pvfs_descriptor_s {
+    int fd;                   /* file number in PVFS descriptor_table */
+    int dup_cnt;              /* number of table slots with this des */
+    posix_ops *fsops;         /* syscalls to use for this file */
+    int posix_fd;             /* non-PVFS files, the true file number */
+    PVFS_object_ref pvfs_ref; /* PVFS fs_id and handle for PVFS file */
+    int flags;                /* the open flags used for this file */
+    off64_t file_pointer;     /* offset from the beginning of the file */
+    char is_in_use;           /* true if this descriptor is valid */
+    /* stdio fields */
+    char dirty;               /* buffer has changed data in it */
+    char eof;                 /* true if tried to read past EOF */
+    char error;               /* true if an error occured */
+    char *buf;                /* beginning of buffer */
+    size_t buftotal;          /* number of valid bytes in buffer */
+    size_t bufsize;           /* the size of the buffer */
+    off64_t buf_off;          /* offset in file that buffer holds */
+    char *bufptr;             /* convenient pointer into the buffer */
+} pvfs_descriptor;
+
+typedef struct pvfs_descriptor_s PFILE; /* these are for posix interface */
+typedef struct pvfs_descriptor_s PDIR;
+
+#include <openfile-util.h>
+#include <iocommon.h>
+
+/* These are the standard function we are overloading in this lib */
+#if 0
+int open(const char *path, int flags, ...);
+int open64(const char *path, int flags, ...); 
+ssize_t write(int fd, const void *buf, size_t count);
+ssize_t read(int fd, void *buf, size_t count); 
+off_t lseek(int fd, off_t offset, int whence); 
+off64_t lseek64(int fd, off64_t offset, int whence); 
+ssize_t pread(int fd, void *buf, size_t nbytes, off_t offset); 
+ssize_t pwrite(int fd, const void *buf, size_t nbytes, off_t offset); 
+ssize_t readv(int fd, const struct iovec *iov, int iovcnt); 
+ssize_t writev(int fd, const struct iovec *iov, int iovcnt)  ; 
+int unlink(const char *path);
+int close(int fd);
+
+FILE * fopen(const char * path, const char * mode) ;
+size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); 
+size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream); 
+int fprintf(FILE *stream, const char *format, ...); 
+int fputs(const char *s, FILE *stream); 
+int fputc(int c, FILE *stream); 
+int fgetc(FILE *stream); 
+char *fgets(char *s, int size, FILE *stream); 
+void rewind(FILE *stream); 
+int fflush(FILE *stream); 
+int getc(FILE *stream); 
+int ungetc(int c, FILE *stream); 
+int fclose(FILE *stream); 
+
+/* MPI functions */ 
+int MPI_File_open(MPI_Comm comm, char *filename, int amode, MPI_Info info, MPI_File *mpi_fh); 
+int MPI_File_write(MPI_File mpi_fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status); 
+#endif
+
+
+//typedef uint64_t off64_t;
+
+#endif



More information about the Pvfs2-cvs mailing list